[spirv-writer] Handle binary and expression.
This CL updates the binary expression to handle the bitwise and command.
Bug: tint:5
Change-Id: I64d53d6aaa1de2fd9ec7959bf084f30736146d78
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19408
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 93489a9..408ea4b 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -575,7 +575,9 @@
(lhs_type->IsVector() && lhs_type->AsVector()->type()->IsU32());
spv::Op op = spv::Op::OpNop;
- if (expr->IsAdd()) {
+ if (expr->IsAnd()) {
+ op = spv::Op::OpBitwiseAnd;
+ } else if (expr->IsAdd()) {
op = lhs_is_float_or_vec ? spv::Op::OpFAdd : spv::Op::OpIAdd;
} else if (expr->IsEqual()) {
op = lhs_is_float_or_vec ? spv::Op::OpFOrdEqual : spv::Op::OpIEqual;
diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc
index 9736ce2..8da3eb8 100644
--- a/src/writer/spirv/builder_binary_expression_test.cc
+++ b/src/writer/spirv/builder_binary_expression_test.cc
@@ -118,10 +118,11 @@
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
"%5 = " + param.name + " %1 %4 %4\n");
}
-INSTANTIATE_TEST_SUITE_P(BuilderTest,
- BinaryArithIntegerTest,
- testing::Values(BinaryData{ast::BinaryOp::kAdd,
- "OpIAdd"}));
+INSTANTIATE_TEST_SUITE_P(
+ BuilderTest,
+ BinaryArithIntegerTest,
+ testing::Values(BinaryData{ast::BinaryOp::kAdd, "OpIAdd"},
+ BinaryData{ast::BinaryOp::kAnd, "OpBitwiseAnd"}));
using BinaryArithFloatTest = testing::TestWithParam<BinaryData>;
TEST_P(BinaryArithFloatTest, Scalar) {