MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / DoPointeesLogicallyMatch

Function DoPointeesLogicallyMatch

source/val/validate_function.cpp:30–56  ·  view source on GitHub ↗

Returns true if |a| and |b| are instructions defining pointers that point to types logically match and the decorations that apply to |b| are a subset of the decorations that apply to |a|.

Source from the content-addressed store, hash-verified

28// types logically match and the decorations that apply to |b| are a subset
29// of the decorations that apply to |a|.
30bool DoPointeesLogicallyMatch(val::Instruction* a, val::Instruction* b,
31 ValidationState_t& _) {
32 if (a->opcode() != spv::Op::OpTypePointer ||
33 b->opcode() != spv::Op::OpTypePointer) {
34 return false;
35 }
36
37 const auto& dec_a = _.id_decorations(a->id());
38 const auto& dec_b = _.id_decorations(b->id());
39 for (const auto& dec : dec_b) {
40 if (std::find(dec_a.begin(), dec_a.end(), dec) == dec_a.end()) {
41 return false;
42 }
43 }
44
45 uint32_t a_type = a->GetOperandAs<uint32_t>(2);
46 uint32_t b_type = b->GetOperandAs<uint32_t>(2);
47
48 if (a_type == b_type) {
49 return true;
50 }
51
52 Instruction* a_type_inst = _.FindDef(a_type);
53 Instruction* b_type_inst = _.FindDef(b_type);
54
55 return _.LogicallyMatch(a_type_inst, b_type_inst, true);
56}
57
58spv_result_t ValidateFunction(ValidationState_t& _, const Instruction* inst) {
59 const auto function_type_id = inst->GetOperandAs<uint32_t>(3);

Callers 1

ValidateFunctionCallFunction · 0.85

Calls 7

findFunction · 0.85
FindDefMethod · 0.80
LogicallyMatchMethod · 0.80
opcodeMethod · 0.45
idMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected