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

Method GetPtr

source/opt/mem_pass.cpp:102–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102Instruction* MemPass::GetPtr(uint32_t ptrId, uint32_t* varId) {
103 *varId = ptrId;
104 Instruction* ptrInst = get_def_use_mgr()->GetDef(*varId);
105 Instruction* varInst;
106
107 switch (ptrInst->opcode()) {
108 case spv::Op::OpVariable:
109 case spv::Op::OpUntypedVariableKHR:
110 case spv::Op::OpFunctionParameter:
111 varInst = ptrInst;
112 break;
113 case spv::Op::OpAccessChain:
114 case spv::Op::OpInBoundsAccessChain:
115 case spv::Op::OpUntypedAccessChainKHR:
116 case spv::Op::OpPtrAccessChain:
117 case spv::Op::OpInBoundsPtrAccessChain:
118 case spv::Op::OpImageTexelPointer:
119 case spv::Op::OpCopyObject:
120 varInst = ptrInst->GetBaseAddress();
121 break;
122 default:
123 *varId = 0;
124 return ptrInst;
125 break;
126 }
127
128 if (varInst->opcode() == spv::Op::OpVariable ||
129 varInst->opcode() == spv::Op::OpUntypedVariableKHR) {
130 *varId = varInst->result_id();
131 } else {
132 *varId = 0;
133 }
134
135 while (ptrInst->opcode() == spv::Op::OpCopyObject) {
136 uint32_t temp = ptrInst->GetSingleWordInOperand(0);
137 ptrInst = get_def_use_mgr()->GetDef(temp);
138 }
139
140 return ptrInst;
141}
142
143Instruction* MemPass::GetPtr(Instruction* ip, uint32_t* varId) {
144 assert(ip->opcode() == spv::Op::OpStore || ip->opcode() == spv::Op::OpLoad ||

Callers 2

ProcessStoreMethod · 0.80
ProcessLoadMethod · 0.80

Calls 6

GetBaseAddressMethod · 0.80
IsAtomicWithLoadMethod · 0.80
GetDefMethod · 0.45
opcodeMethod · 0.45
result_idMethod · 0.45

Tested by

no test coverage detected