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

Method IsApplicable

source/fuzz/transformation_add_function.cpp:58–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58bool TransformationAddFunction::IsApplicable(
59 opt::IRContext* ir_context,
60 const TransformationContext& transformation_context) const {
61 // This transformation may use a lot of ids, all of which need to be fresh
62 // and distinct. This set tracks them.
63 std::set<uint32_t> ids_used_by_this_transformation;
64
65 // Ensure that all result ids in the new function are fresh and distinct.
66 for (auto& instruction : message_.instruction()) {
67 if (instruction.result_id()) {
68 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
69 instruction.result_id(), ir_context,
70 &ids_used_by_this_transformation)) {
71 return false;
72 }
73 }
74 }
75
76 if (message_.is_livesafe()) {
77 // Ensure that all ids provided for making the function livesafe are fresh
78 // and distinct.
79 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
80 message_.loop_limiter_variable_id(), ir_context,
81 &ids_used_by_this_transformation)) {
82 return false;
83 }
84 for (auto& loop_limiter_info : message_.loop_limiter_info()) {
85 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
86 loop_limiter_info.load_id(), ir_context,
87 &ids_used_by_this_transformation)) {
88 return false;
89 }
90 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
91 loop_limiter_info.increment_id(), ir_context,
92 &ids_used_by_this_transformation)) {
93 return false;
94 }
95 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
96 loop_limiter_info.compare_id(), ir_context,
97 &ids_used_by_this_transformation)) {
98 return false;
99 }
100 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
101 loop_limiter_info.logical_op_id(), ir_context,
102 &ids_used_by_this_transformation)) {
103 return false;
104 }
105 }
106 for (auto& access_chain_clamping_info :
107 message_.access_chain_clamping_info()) {
108 for (auto& pair : access_chain_clamping_info.compare_and_select_ids()) {
109 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
110 pair.first(), ir_context, &ids_used_by_this_transformation)) {
111 return false;
112 }
113 if (!CheckIdIsFreshAndNotUsedByThisTransformation(
114 pair.second(), ir_context, &ids_used_by_this_transformation)) {
115 return false;

Callers

nothing calls this directly

Calls 7

CloneIRContextFunction · 0.85
IsValidFunction · 0.85
instructionMethod · 0.80
firstMethod · 0.80
getMethod · 0.80
GetValidatorOptionsMethod · 0.80
result_idMethod · 0.45

Tested by

no test coverage detected