[spirv-reader] Add FSub

Bug: tint:3
Change-Id: I6e79e19bf5feb9e0223d770f718a0d0bd9b5b147
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19501
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-04-14 16:26:29 +00:00 committed by dan sinclair
parent 79797490d8
commit 31d9036769
2 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,8 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) {
case SpvOpIAdd:
case SpvOpFAdd:
return ast::BinaryOp::kAdd;
case SpvOpFSub:
return ast::BinaryOp::kSubtract;
default:
break;
}

View File

@ -200,6 +200,20 @@ INSTANTIATE_TEST_SUITE_P(
"__vec_2__f32", AstFor("v2float_50_60"), "add",
AstFor("v2float_60_50")}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_FSub,
SpvBinaryTest,
::testing::Values(
// Scalar float
BinaryData{"float", "float_50", "OpFSub", "float_60", "__f32",
"ScalarConstructor{50.000000}", "subtract",
"ScalarConstructor{60.000000}"},
// Vector float
BinaryData{"v2float", "v2float_50_60", "OpFSub", "v2float_60_50",
"__vec_2__f32", AstFor("v2float_50_60"), "subtract",
AstFor("v2float_60_50")}));
} // namespace
} // namespace spirv
} // namespace reader