[spirv-reader] Add UMod, SMod, FMod

Bug: tint:3
Change-Id: Idd0e5bbc51e05782d3f918e4ffeb83eab52d87d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19565
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-04-15 14:02:37 +00:00 committed by dan sinclair
parent badf99be5d
commit ac3213b4ad
2 changed files with 41 additions and 0 deletions

View File

@ -52,6 +52,10 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) {
case SpvOpSDiv:
case SpvOpFDiv:
return ast::BinaryOp::kDivide;
case SpvOpUMod:
case SpvOpSMod:
case SpvOpFMod:
return ast::BinaryOp::kModulo;
case SpvOpShiftLeftLogical:
return ast::BinaryOp::kShiftLeft;
case SpvOpShiftRightLogical:

View File

@ -337,6 +337,43 @@ INSTANTIATE_TEST_SUITE_P(
"__vec_2__f32", AstFor("v2float_50_60"), "divide",
AstFor("v2float_60_50")}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_UMod,
SpvBinaryTest,
::testing::Values(
// Both uint
BinaryData{"uint", "uint_10", "OpUMod", "uint_20", "__u32",
"ScalarConstructor{10}", "modulo", "ScalarConstructor{20}"},
// Both v2uint
BinaryData{"v2uint", "v2uint_10_20", "OpUMod", "v2uint_20_10",
"__vec_2__u32", AstFor("v2uint_10_20"), "modulo",
AstFor("v2uint_20_10")}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_SMod,
SpvBinaryTest,
::testing::Values(
// Both int
BinaryData{"int", "int_30", "OpSMod", "int_40", "__i32",
"ScalarConstructor{30}", "modulo", "ScalarConstructor{40}"},
// Both v2int
BinaryData{"v2int", "v2int_30_40", "OpSMod", "v2int_40_30",
"__vec_2__i32", AstFor("v2int_30_40"), "modulo",
AstFor("v2int_40_30")}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_FMod,
SpvBinaryTest,
::testing::Values(
// Scalar float
BinaryData{"float", "float_50", "OpFMod", "float_60", "__f32",
"ScalarConstructor{50.000000}", "modulo",
"ScalarConstructor{60.000000}"},
// Vector float
BinaryData{"v2float", "v2float_50_60", "OpFMod", "v2float_60_50",
"__vec_2__f32", AstFor("v2float_50_60"), "modulo",
AstFor("v2float_60_50")}));
INSTANTIATE_TEST_SUITE_P(
SpvParserTest_ShiftLeftLogical,
SpvBinaryTest,