[spirv-reader] Add ISub, IMul, UDiv, SDiv
Bug: tint:3 Change-Id: Id2c9d91742f8bdc712d2dfbda5f4883379a29470 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19564 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
d4c8ab967b
commit
badf99be5d
|
@ -42,10 +42,14 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) {
|
||||||
case SpvOpIAdd:
|
case SpvOpIAdd:
|
||||||
case SpvOpFAdd:
|
case SpvOpFAdd:
|
||||||
return ast::BinaryOp::kAdd;
|
return ast::BinaryOp::kAdd;
|
||||||
|
case SpvOpISub:
|
||||||
case SpvOpFSub:
|
case SpvOpFSub:
|
||||||
return ast::BinaryOp::kSubtract;
|
return ast::BinaryOp::kSubtract;
|
||||||
|
case SpvOpIMul:
|
||||||
case SpvOpFMul:
|
case SpvOpFMul:
|
||||||
return ast::BinaryOp::kMultiply;
|
return ast::BinaryOp::kMultiply;
|
||||||
|
case SpvOpUDiv:
|
||||||
|
case SpvOpSDiv:
|
||||||
case SpvOpFDiv:
|
case SpvOpFDiv:
|
||||||
return ast::BinaryOp::kDivide;
|
return ast::BinaryOp::kDivide;
|
||||||
case SpvOpShiftLeftLogical:
|
case SpvOpShiftLeftLogical:
|
||||||
|
|
|
@ -200,6 +200,43 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"__vec_2__f32", AstFor("v2float_50_60"), "add",
|
"__vec_2__f32", AstFor("v2float_50_60"), "add",
|
||||||
AstFor("v2float_60_50")}));
|
AstFor("v2float_60_50")}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
SpvParserTest_ISub,
|
||||||
|
SpvBinaryTest,
|
||||||
|
::testing::Values(
|
||||||
|
// Both uint
|
||||||
|
BinaryData{"uint", "uint_10", "OpISub", "uint_20", "__u32",
|
||||||
|
"ScalarConstructor{10}", "subtract",
|
||||||
|
"ScalarConstructor{20}"},
|
||||||
|
// Both int
|
||||||
|
BinaryData{"int", "int_30", "OpISub", "int_40", "__i32",
|
||||||
|
"ScalarConstructor{30}", "subtract",
|
||||||
|
"ScalarConstructor{40}"},
|
||||||
|
// Mixed, returning uint
|
||||||
|
BinaryData{"uint", "int_30", "OpISub", "uint_10", "__u32",
|
||||||
|
"ScalarConstructor{30}", "subtract",
|
||||||
|
"ScalarConstructor{10}"},
|
||||||
|
// Mixed, returning int
|
||||||
|
BinaryData{"int", "int_30", "OpISub", "uint_10", "__i32",
|
||||||
|
"ScalarConstructor{30}", "subtract",
|
||||||
|
"ScalarConstructor{10}"},
|
||||||
|
// Both v2uint
|
||||||
|
BinaryData{"v2uint", "v2uint_10_20", "OpISub", "v2uint_20_10",
|
||||||
|
"__vec_2__u32", AstFor("v2uint_10_20"), "subtract",
|
||||||
|
AstFor("v2uint_20_10")},
|
||||||
|
// Both v2int
|
||||||
|
BinaryData{"v2int", "v2int_30_40", "OpISub", "v2int_40_30",
|
||||||
|
"__vec_2__i32", AstFor("v2int_30_40"), "subtract",
|
||||||
|
AstFor("v2int_40_30")},
|
||||||
|
// Mixed, returning v2uint
|
||||||
|
BinaryData{"v2uint", "v2int_30_40", "OpISub", "v2uint_10_20",
|
||||||
|
"__vec_2__u32", AstFor("v2int_30_40"), "subtract",
|
||||||
|
AstFor("v2uint_10_20")},
|
||||||
|
// Mixed, returning v2int
|
||||||
|
BinaryData{"v2int", "v2int_40_30", "OpISub", "v2uint_20_10",
|
||||||
|
"__vec_2__i32", AstFor("v2int_40_30"), "subtract",
|
||||||
|
AstFor("v2uint_20_10")}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvParserTest_FSub,
|
SpvParserTest_FSub,
|
||||||
SpvBinaryTest,
|
SpvBinaryTest,
|
||||||
|
@ -213,6 +250,43 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"__vec_2__f32", AstFor("v2float_50_60"), "subtract",
|
"__vec_2__f32", AstFor("v2float_50_60"), "subtract",
|
||||||
AstFor("v2float_60_50")}));
|
AstFor("v2float_60_50")}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
SpvParserTest_IMul,
|
||||||
|
SpvBinaryTest,
|
||||||
|
::testing::Values(
|
||||||
|
// Both uint
|
||||||
|
BinaryData{"uint", "uint_10", "OpIMul", "uint_20", "__u32",
|
||||||
|
"ScalarConstructor{10}", "multiply",
|
||||||
|
"ScalarConstructor{20}"},
|
||||||
|
// Both int
|
||||||
|
BinaryData{"int", "int_30", "OpIMul", "int_40", "__i32",
|
||||||
|
"ScalarConstructor{30}", "multiply",
|
||||||
|
"ScalarConstructor{40}"},
|
||||||
|
// Mixed, returning uint
|
||||||
|
BinaryData{"uint", "int_30", "OpIMul", "uint_10", "__u32",
|
||||||
|
"ScalarConstructor{30}", "multiply",
|
||||||
|
"ScalarConstructor{10}"},
|
||||||
|
// Mixed, returning int
|
||||||
|
BinaryData{"int", "int_30", "OpIMul", "uint_10", "__i32",
|
||||||
|
"ScalarConstructor{30}", "multiply",
|
||||||
|
"ScalarConstructor{10}"},
|
||||||
|
// Both v2uint
|
||||||
|
BinaryData{"v2uint", "v2uint_10_20", "OpIMul", "v2uint_20_10",
|
||||||
|
"__vec_2__u32", AstFor("v2uint_10_20"), "multiply",
|
||||||
|
AstFor("v2uint_20_10")},
|
||||||
|
// Both v2int
|
||||||
|
BinaryData{"v2int", "v2int_30_40", "OpIMul", "v2int_40_30",
|
||||||
|
"__vec_2__i32", AstFor("v2int_30_40"), "multiply",
|
||||||
|
AstFor("v2int_40_30")},
|
||||||
|
// Mixed, returning v2uint
|
||||||
|
BinaryData{"v2uint", "v2int_30_40", "OpIMul", "v2uint_10_20",
|
||||||
|
"__vec_2__u32", AstFor("v2int_30_40"), "multiply",
|
||||||
|
AstFor("v2uint_10_20")},
|
||||||
|
// Mixed, returning v2int
|
||||||
|
BinaryData{"v2int", "v2int_40_30", "OpIMul", "v2uint_20_10",
|
||||||
|
"__vec_2__i32", AstFor("v2int_40_30"), "multiply",
|
||||||
|
AstFor("v2uint_20_10")}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvParserTest_FMul,
|
SpvParserTest_FMul,
|
||||||
SpvBinaryTest,
|
SpvBinaryTest,
|
||||||
|
@ -226,6 +300,30 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
"__vec_2__f32", AstFor("v2float_50_60"), "multiply",
|
"__vec_2__f32", AstFor("v2float_50_60"), "multiply",
|
||||||
AstFor("v2float_60_50")}));
|
AstFor("v2float_60_50")}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
SpvParserTest_UDiv,
|
||||||
|
SpvBinaryTest,
|
||||||
|
::testing::Values(
|
||||||
|
// Both uint
|
||||||
|
BinaryData{"uint", "uint_10", "OpUDiv", "uint_20", "__u32",
|
||||||
|
"ScalarConstructor{10}", "divide", "ScalarConstructor{20}"},
|
||||||
|
// Both v2uint
|
||||||
|
BinaryData{"v2uint", "v2uint_10_20", "OpUDiv", "v2uint_20_10",
|
||||||
|
"__vec_2__u32", AstFor("v2uint_10_20"), "divide",
|
||||||
|
AstFor("v2uint_20_10")}));
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
SpvParserTest_SDiv,
|
||||||
|
SpvBinaryTest,
|
||||||
|
::testing::Values(
|
||||||
|
// Both int
|
||||||
|
BinaryData{"int", "int_30", "OpSDiv", "int_40", "__i32",
|
||||||
|
"ScalarConstructor{30}", "divide", "ScalarConstructor{40}"},
|
||||||
|
// Both v2int
|
||||||
|
BinaryData{"v2int", "v2int_30_40", "OpSDiv", "v2int_40_30",
|
||||||
|
"__vec_2__i32", AstFor("v2int_30_40"), "divide",
|
||||||
|
AstFor("v2int_40_30")}));
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
SpvParserTest_FDiv,
|
SpvParserTest_FDiv,
|
||||||
SpvBinaryTest,
|
SpvBinaryTest,
|
||||||
|
|
Loading…
Reference in New Issue