From f95862b806af395b90c79ecb39976a73a63614b7 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 14 Apr 2020 15:04:03 +0000 Subject: [PATCH] [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 --- src/writer/spirv/builder.cc | 4 +++- src/writer/spirv/builder_binary_expression_test.cc | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 93489a9d41..408ea4b2eb 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -575,7 +575,9 @@ uint32_t Builder::GenerateBinaryExpression(ast::BinaryExpression* expr) { (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 9736ce2299..8da3eb8c49 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -118,10 +118,11 @@ TEST_P(BinaryArithIntegerTest, Vector) { 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; TEST_P(BinaryArithFloatTest, Scalar) {