[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>
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 6860e15..2d520cb 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -52,6 +52,10 @@
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:
diff --git a/src/reader/spirv/function_arithmetic_test.cc b/src/reader/spirv/function_arithmetic_test.cc
index 7f1e62c..b2945af 100644
--- a/src/reader/spirv/function_arithmetic_test.cc
+++ b/src/reader/spirv/function_arithmetic_test.cc
@@ -338,6 +338,43 @@
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,
::testing::Values(