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

Method BuildInstructionAndAddToModule

source/opt/constants.cpp:205–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205Instruction* ConstantManager::BuildInstructionAndAddToModule(
206 const Constant* new_const, Module::inst_iterator* pos, uint32_t type_id) {
207 // TODO(1841): Handle id overflow.
208 uint32_t new_id = context()->TakeNextId();
209 if (new_id == 0) {
210 return nullptr;
211 }
212
213 auto new_inst = CreateInstruction(new_id, new_const, type_id);
214 if (!new_inst) {
215 return nullptr;
216 }
217 auto* new_inst_ptr = new_inst.get();
218 *pos = pos->InsertBefore(std::move(new_inst));
219 ++(*pos);
220 if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
221 context()->get_def_use_mgr()->AnalyzeInstDefUse(new_inst_ptr);
222 MapConstantToInst(new_const, new_inst_ptr);
223 return new_inst_ptr;
224}
225
226Instruction* ConstantManager::GetDefiningInstruction(
227 const Constant* c, uint32_t type_id, Module::inst_iterator* pos) {

Callers 2

FoldInsertWithConstantsFunction · 0.80

Calls 6

getMethod · 0.80
AreAnalysesValidMethod · 0.80
AnalyzeInstDefUseMethod · 0.80
TakeNextIdMethod · 0.45
InsertBeforeMethod · 0.45
get_def_use_mgrMethod · 0.45

Tested by 1