[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>
This commit is contained in:
dan sinclair 2020-04-14 15:04:03 +00:00 committed by dan sinclair
parent f558809b54
commit f95862b806
2 changed files with 8 additions and 5 deletions

View File

@ -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;

View File

@ -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<BinaryData>;
TEST_P(BinaryArithFloatTest, Scalar) {