| 217 | } |
| 218 | |
| 219 | bool 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 | |
| 247 | Instruction* Instruction::GetBaseAddress() const { |
| 248 | uint32_t base = GetSingleWordInOperand(kLoadBaseIndex); |
no test coverage detected