bool CommonUniformElimPass::HasOnlyNamesAndDecorates(uint32_t id) const { analysis::UseList* uses = def_use_mgr_->GetUses(id); if (uses == nullptr) return true; for (auto u : *uses) { const SpvOp op = u.inst->opcode(); if (op != SpvOpName && !IsNonTypeDecorate(op)) return false; } return true; }
void CommonUniformElimPass::KillNamesAndDecorates(uint32_t id) { // TODO(greg-lunarg): Remove id from any OpGroupDecorate and // kill if no other operands. analysis::UseList* uses = def_use_mgr_->GetUses(id); if (uses == nullptr) return; std::list<ir::Instruction*> killList; for (auto u : *uses) { const SpvOp op = u.inst->opcode(); if (op != SpvOpName && !IsNonTypeDecorate(op)) continue; killList.push_back(u.inst); } for (auto kip : killList) def_use_mgr_->KillInst(kip); }
bool LocalAccessChainConvertPass::HasOnlySupportedRefs(uint32_t ptrId) { if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end()) return true; analysis::UseList* uses = def_use_mgr_->GetUses(ptrId); assert(uses != nullptr); for (auto u : *uses) { SpvOp op = u.inst->opcode(); if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) { if (!HasOnlySupportedRefs(u.inst->result_id())) return false; } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName && !IsNonTypeDecorate(op)) return false; } supported_ref_ptrs_.insert(ptrId); return true; }
bool LocalSingleBlockLoadStoreElimPass::HasOnlySupportedRefs(uint32_t ptrId) { if (supported_ref_ptrs_.find(ptrId) != supported_ref_ptrs_.end()) return true; if (get_def_use_mgr()->WhileEachUser(ptrId, [this](Instruction* user) { SpvOp op = user->opcode(); if (IsNonPtrAccessChain(op) || op == SpvOpCopyObject) { if (!HasOnlySupportedRefs(user->result_id())) { return false; } } else if (op != SpvOpStore && op != SpvOpLoad && op != SpvOpName && !IsNonTypeDecorate(op)) { return false; } return true; })) { supported_ref_ptrs_.insert(ptrId); return true; } return false; }