// are a struct and then give the raw Id number.
SaveName(result_id, std::string("_struct_") + to_string(result_id));
break;
+ case SpvOpConstantTrue:
+ SaveName(result_id, "true");
+ break;
+ case SpvOpConstantFalse:
+ SaveName(result_id, "false");
+ break;
case SpvOpConstant: {
std::ostringstream value;
EmitNumericLiteral(&value, inst, inst.operands[2]);
const char* expected_text =
"%bool = OpTypeBool\n"
- "%1 = OpConstantTrue %bool\n";
+ "%true = OpConstantTrue %bool\n";
CheckOptimization(original_text, expected_text, o);
}
"double_n0x1p_1024"}, // -Inf
}), );
+INSTANTIATE_TEST_CASE_P(
+ BooleanConstants, FriendlyNameTest,
+ ::testing::ValuesIn(std::vector<NameIdCase>{
+ {"%1 = OpTypeBool\n%2 = OpConstantTrue %1", 2, "true"},
+ {"%1 = OpTypeBool\n%2 = OpConstantFalse %1", 2, "false"},
+ }), );
+
} // anonymous namespace
"%void = OpTypeVoid",
"%4 = OpTypeFunction %void",
"%bool = OpTypeBool",
- "%6 = OpConstantTrue %bool",
- "%7 = OpConstantFalse %bool",
+ "%true = OpConstantTrue %bool",
+ "%false = OpConstantFalse %bool",
"%int = OpTypeInt 32 1",
"%9 = OpConstant %int 1",
"%uint = OpTypeInt 32 0",
"%10 = OpTypeFunction %void",
"%bool = OpTypeBool",
"%_ptr_Function_bool = OpTypePointer Function %bool",
- "%13 = OpConstantTrue %bool",
- "%14 = OpConstantFalse %bool",
+ "%true = OpConstantTrue %bool",
+ "%false = OpConstantFalse %bool",
"%int = OpTypeInt 32 1",
"%_ptr_Function_int = OpTypePointer Function %int",
"%int_1 = OpConstant %int 1",
"%uv = OpVariable %_ptr_Function_uint Function",
"%fv = OpVariable %_ptr_Function_float Function",
"%dv = OpVariable %_ptr_Function_double Function",
- "OpStore %btv %13",
- "OpStore %bfv %14",
+ "OpStore %btv %true",
+ "OpStore %bfv %false",
"OpStore %iv %int_1",
"OpStore %uv %uint_2",
"OpStore %fv %float_3_14",
},
// expected
{
- "%59 = OpConstantTrue %bool",
- "%60 = OpConstantTrue %bool",
- "%spec_bool_t_vec = OpConstantComposite %v2bool %59 %60",
- "%62 = OpConstantFalse %bool",
- "%63 = OpConstantFalse %bool",
- "%spec_bool_f_vec = OpConstantComposite %v2bool %62 %63",
- "%65 = OpConstantFalse %bool",
- "%66 = OpConstantFalse %bool",
- "%spec_bool_from_null = OpConstantComposite %v2bool %65 %66",
+ "%true = OpConstantTrue %bool",
+ "%true_0 = OpConstantTrue %bool",
+ "%spec_bool_t_vec = OpConstantComposite %v2bool %true %true_0",
+ "%false = OpConstantFalse %bool",
+ "%false_0 = OpConstantFalse %bool",
+ "%spec_bool_f_vec = OpConstantComposite %v2bool %false %false_0",
+ "%false_1 = OpConstantFalse %bool",
+ "%false_2 = OpConstantFalse %bool",
+ "%spec_bool_from_null = OpConstantComposite %v2bool %false_1 %false_2",
},
},
},
// expected
{
- "%59 = OpConstantTrue %bool",
- "%60 = OpConstantTrue %bool",
- "%spec_bool_t_vec = OpConstantComposite %v2bool %59 %60",
- "%62 = OpConstantFalse %bool",
- "%63 = OpConstantFalse %bool",
- "%spec_bool_f_vec = OpConstantComposite %v2bool %62 %63",
- "%65 = OpConstantFalse %bool",
- "%66 = OpConstantFalse %bool",
- "%spec_bool_from_null = OpConstantComposite %v2bool %65 %66",
+ "%true = OpConstantTrue %bool",
+ "%true_0 = OpConstantTrue %bool",
+ "%spec_bool_t_vec = OpConstantComposite %v2bool %true %true_0",
+ "%false = OpConstantFalse %bool",
+ "%false_0 = OpConstantFalse %bool",
+ "%spec_bool_f_vec = OpConstantComposite %v2bool %false %false_0",
+ "%false_1 = OpConstantFalse %bool",
+ "%false_2 = OpConstantFalse %bool",
+ "%spec_bool_from_null = OpConstantComposite %v2bool %false_1 %false_2",
},
},
{"%double = OpTypeFloat 64", "%2 = OpSpecConstant %double 3.1415926",
"%double_3_1415926 = OpConstant %double 3.1415926"},
{"%bool = OpTypeBool", "%2 = OpSpecConstantTrue %bool",
- "%2 = OpConstantTrue %bool"},
+ "%true = OpConstantTrue %bool"},
{"%bool = OpTypeBool", "%2 = OpSpecConstantFalse %bool",
- "%2 = OpConstantFalse %bool"},
+ "%false = OpConstantFalse %bool"},
})));
using FreezeSpecConstantValueRemoveDecorationTest = PassTest<::testing::Test>;
"%float_3_14 = OpConstant %float 3.14"},
{"%5 = OpSpecConstant %double 3.14159265358979",
"%double_3_14159265358979 = OpConstant %double 3.14159265358979"},
- {" OpSpecConstantTrue ", " OpConstantTrue "},
- {" OpSpecConstantFalse ", " OpConstantFalse "},
+ {"%6 = OpSpecConstantTrue ", "%true = OpConstantTrue "},
+ {"%13 = OpSpecConstantFalse ", "%false = OpConstantFalse "},
};
for (auto& p : replacement_pairs) {
EXPECT_TRUE(FindAndReplace(&expected_disassembly, p.first, p.second))