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

Method IsReadOnlyLoad

source/opt/instruction.cpp:219–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219bool Instruction::IsReadOnlyLoad() const {
220 if (IsLoad()) {
221 Instruction* address_def = GetBaseAddress();
222 if (!address_def) {
223 return false;
224 }
225
226 if (address_def->opcode() == spv::Op::OpVariable) {
227 if (address_def->IsReadOnlyPointer()) {
228 return true;
229 }
230 }
231
232 if (address_def->opcode() == spv::Op::OpLoad) {
233 const analysis::Type* address_type =
234 context()->get_type_mgr()->GetType(address_def->type_id());
235 if (address_type->AsSampledImage() != nullptr) {
236 const auto* image_type =
237 address_type->AsSampledImage()->image_type()->AsImage();
238 if (image_type->sampled() == 1) {
239 return true;
240 }
241 }
242 }
243 }
244 return false;
245}
246
247Instruction* Instruction::GetBaseAddress() const {
248 uint32_t base = GetSingleWordInOperand(kLoadBaseIndex);

Callers 1

Calls 9

IsReadOnlyPointerMethod · 0.80
get_type_mgrMethod · 0.80
AsSampledImageMethod · 0.80
AsImageMethod · 0.80
image_typeMethod · 0.80
sampledMethod · 0.80
opcodeMethod · 0.45
GetTypeMethod · 0.45
type_idMethod · 0.45

Tested by

no test coverage detected