[ir][spirv-writer] Implement convert instructions
These map to one of several instructions, depending on the input and
output types. Conversions to bool are implemented using OpSelect
between a zero and one value, splatted to vectors if needed.
Bug: tint:1906
Change-Id: If208873506c314e3dd1bc4026ef9ebeba7c8933a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139900
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/writer/spirv/ir/test_helper_ir.h b/src/tint/writer/spirv/ir/test_helper_ir.h
index 5fbf6e4..dfc05b8 100644
--- a/src/tint/writer/spirv/ir/test_helper_ir.h
+++ b/src/tint/writer/spirv/ir/test_helper_ir.h
@@ -41,6 +41,26 @@
kF32,
kF16,
};
+inline utils::StringStream& operator<<(utils::StringStream& out, TestElementType type) {
+ switch (type) {
+ case kBool:
+ out << "bool";
+ break;
+ case kI32:
+ out << "i32";
+ break;
+ case kU32:
+ out << "u32";
+ break;
+ case kF32:
+ out << "f32";
+ break;
+ case kF16:
+ out << "f16";
+ break;
+ }
+ return out;
+}
/// Base helper class for testing the SPIR-V generator implementation.
template <typename BASE>