From 74d97e7282ebc363ae54d89ba71465f0217fca71 Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 14 Apr 2020 16:27:26 +0000 Subject: [PATCH] [spirv-reader] Add FDiv Change-Id: Ie24bb91276340afd77009165af471ce0f53cca39 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19503 Reviewed-by: dan sinclair --- src/reader/spirv/function.cc | 2 ++ src/reader/spirv/function_arithmetic_test.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index a1f92ef16e..0f24f1280f 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -46,6 +46,8 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) { return ast::BinaryOp::kSubtract; case SpvOpFMul: return ast::BinaryOp::kMultiply; + case SpvOpFDiv: + return ast::BinaryOp::kDivide; default: break; } diff --git a/src/reader/spirv/function_arithmetic_test.cc b/src/reader/spirv/function_arithmetic_test.cc index 888bdbb6e5..1643aa2f83 100644 --- a/src/reader/spirv/function_arithmetic_test.cc +++ b/src/reader/spirv/function_arithmetic_test.cc @@ -226,6 +226,19 @@ INSTANTIATE_TEST_SUITE_P( "__vec_2__f32", AstFor("v2float_50_60"), "multiply", AstFor("v2float_60_50")})); +INSTANTIATE_TEST_SUITE_P( + SpvParserTest_FDiv, + SpvBinaryTest, + ::testing::Values( + // Scalar float + BinaryData{"float", "float_50", "OpFDiv", "float_60", "__f32", + "ScalarConstructor{50.000000}", "divide", + "ScalarConstructor{60.000000}"}, + // Vector float + BinaryData{"v2float", "v2float_50_60", "OpFDiv", "v2float_60_50", + "__vec_2__f32", AstFor("v2float_50_60"), "divide", + AstFor("v2float_60_50")})); + } // namespace } // namespace spirv } // namespace reader