From da0a4e9c91e3a42ba65a7d7a3a53af62dc0356a4 Mon Sep 17 00:00:00 2001 From: David Neto Date: Wed, 15 Apr 2020 13:58:17 +0000 Subject: [PATCH] [spirv-reader] Add logical and, logical or Bug: tint:3 Change-Id: Ia2bde9644a8e3cdd5871570354a380f968760711 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19562 Reviewed-by: dan sinclair --- src/reader/spirv/function.cc | 4 ++++ src/reader/spirv/function_logical_test.cc | 24 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 0412c67582..ae9b9ad78c 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -64,6 +64,10 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) { return ast::BinaryOp::kOr; case SpvOpBitwiseXor: return ast::BinaryOp::kXor; + case SpvOpLogicalAnd: + return ast::BinaryOp::kLogicalAnd; + case SpvOpLogicalOr: + return ast::BinaryOp::kLogicalOr; default: break; } diff --git a/src/reader/spirv/function_logical_test.cc b/src/reader/spirv/function_logical_test.cc index f33e58f274..4973ae93ad 100644 --- a/src/reader/spirv/function_logical_test.cc +++ b/src/reader/spirv/function_logical_test.cc @@ -57,6 +57,8 @@ std::string CommonTypes() { %v2int = OpTypeVector %int 2 %v2float = OpTypeVector %float 2 + %v2bool_t_f = OpConstantComposite %v2bool %true %false + %v2bool_f_t = OpConstantComposite %v2bool %false %true %v2uint_10_20 = OpConstantComposite %v2uint %uint_10 %uint_20 %v2uint_20_10 = OpConstantComposite %v2uint %uint_20 %uint_10 %v2int_30_40 = OpConstantComposite %v2int %int_30 %int_40 @@ -214,6 +216,28 @@ INSTANTIATE_TEST_SUITE_P( "__vec_2__bool", AstFor("v2int_30_40"), "not_equal", AstFor("v2int_40_30")})); +INSTANTIATE_TEST_SUITE_P( + SpvParserTest_LogicalAnd, + SpvBinaryLogicalTest, + ::testing::Values(BinaryData{"bool", "true", "OpLogicalAnd", "false", + "__bool", "ScalarConstructor{true}", + "logical_and", "ScalarConstructor{false}"}, + BinaryData{"v2bool", "v2bool_t_f", "OpLogicalAnd", + "v2bool_f_t", "__vec_2__bool", + AstFor("v2bool_t_f"), "logical_and", + AstFor("v2bool_f_t")})); + +INSTANTIATE_TEST_SUITE_P( + SpvParserTest_LogicalOr, + SpvBinaryLogicalTest, + ::testing::Values(BinaryData{"bool", "true", "OpLogicalOr", "false", + "__bool", "ScalarConstructor{true}", + "logical_or", "ScalarConstructor{false}"}, + BinaryData{"v2bool", "v2bool_t_f", "OpLogicalOr", + "v2bool_f_t", "__vec_2__bool", + AstFor("v2bool_t_f"), "logical_or", + AstFor("v2bool_f_t")})); + } // namespace } // namespace spirv } // namespace reader