• Home
  • Raw
  • Download

Lines Matching refs:Ice

33 	void run(Ice::Cfg *function);
36 void analyzeUses(Ice::Cfg *function);
44 void replace(Ice::Inst *instruction, Ice::Operand *newValue);
45 void deleteInstruction(Ice::Inst *instruction);
46 bool isDead(Ice::Inst *instruction);
47 bool isStaticallyIndexedArray(Ice::Operand *allocaAddress);
48 Ice::InstAlloca *allocaOf(Ice::Operand *address);
50 static const Ice::InstIntrinsic *asLoadSubVector(const Ice::Inst *instruction);
51 static const Ice::InstIntrinsic *asStoreSubVector(const Ice::Inst *instruction);
52 static bool isLoad(const Ice::Inst &instruction);
53 static bool isStore(const Ice::Inst &instruction);
54 static bool loadTypeMatchesStore(const Ice::Inst *load, const Ice::Inst *store);
55 static bool storeTypeMatchesStore(const Ice::Inst *store1, const Ice::Inst *store2);
59 Ice::Cfg *function;
60 Ice::GlobalContext *context;
62 struct Uses : std::vector<Ice::Inst *>
65 void insert(Ice::Operand *value, Ice::Inst *instruction);
66 void erase(Ice::Inst *instruction);
68 std::vector<Ice::Inst *> loads;
69 std::vector<Ice::Inst *> stores;
74 LoadStoreInst(Ice::Inst *inst, bool isStore) in LoadStoreInst()
81 Ice::Inst *inst;
82 Ice::Operand *address;
86 Optimizer::Uses *getUses(Ice::Operand *);
87 void setUses(Ice::Operand *, Optimizer::Uses *);
88 bool hasUses(Ice::Operand *) const;
90 Ice::Inst *getDefinition(Ice::Variable *);
91 void setDefinition(Ice::Variable *, Ice::Inst *);
93 std::vector<Ice::Operand *> operandsWithUses;
98 void Optimizer::run(Ice::Cfg *function) in run()
132 Ice::CfgNode *entryBlock = function->getEntryNode(); in propagateAlloca()
133 Ice::InstList &instList = entryBlock->getInsts(); in propagateAlloca()
135 for(Ice::Inst &inst : instList) in propagateAlloca()
142 auto *alloca = llvm::dyn_cast<Ice::InstAlloca>(&inst); in propagateAlloca()
150 Ice::Operand *address = alloca->getDest(); in propagateAlloca()
157 Ice::Operand *dest = store->getStoreAddress(); in propagateAlloca()
158 Ice::Variable *destVar = llvm::dyn_cast<Ice::Variable>(dest); in propagateAlloca()
159 Ice::Inst *def = destVar ? getDefinition(destVar) : nullptr; in propagateAlloca()
162 if(def && def->getKind() == Ice::Inst::Alloca) in propagateAlloca()
186 Ice::Type pointerType() in pointerType()
190 return Ice::IceType_i64; in pointerType()
194 return Ice::IceType_i32; in pointerType()
201 std::vector<Ice::InstAlloca *> newAllocas; in performScalarReplacementOfAggregates()
203 Ice::CfgNode *entryBlock = function->getEntryNode(); in performScalarReplacementOfAggregates()
204 Ice::InstList &instList = entryBlock->getInsts(); in performScalarReplacementOfAggregates()
206 for(Ice::Inst &inst : instList) in performScalarReplacementOfAggregates()
213 auto *alloca = llvm::dyn_cast<Ice::InstAlloca>(&inst); in performScalarReplacementOfAggregates()
220 uint32_t sizeInBytes = llvm::cast<Ice::ConstantInteger32>(alloca->getSizeInBytes())->getValue(); in performScalarReplacementOfAggregates()
228 Ice::Operand *address = alloca->getDest(); in performScalarReplacementOfAggregates()
236 std::vector<Ice::Variable *> newAddress(elementCount); in performScalarReplacementOfAggregates()
237 auto *bytes = Ice::ConstantInteger32::create(context, Ice::IceType_i32, alignInBytes); in performScalarReplacementOfAggregates()
242 auto *alloca = Ice::InstAlloca::create(function, newAddress[i], bytes, alignInBytes); in performScalarReplacementOfAggregates()
266 auto *arithmetic = llvm::cast<Ice::InstArithmetic>(use); in performScalarReplacementOfAggregates()
268 if(arithmetic->getOp() == Ice::InstArithmetic::Add) in performScalarReplacementOfAggregates()
271 int32_t offset = llvm::cast<Ice::ConstantInteger32>(rhs)->getValue(); in performScalarReplacementOfAggregates()
303 for(Ice::CfgNode *basicBlock : function->getNodes()) in eliminateDeadCode()
305 for(Ice::Inst &inst : Ice::reverse_range(basicBlock->getInsts())) in eliminateDeadCode()
324 Ice::CfgNode *entryBlock = function->getEntryNode(); in eliminateUnitializedLoads()
326 for(Ice::Inst &alloca : entryBlock->getInsts()) in eliminateUnitializedLoads()
333 if(!llvm::isa<Ice::InstAlloca>(alloca)) in eliminateUnitializedLoads()
338 Ice::Operand *address = alloca.getDest(); in eliminateUnitializedLoads()
354 for(Ice::Inst *load : addressUses.loads) in eliminateUnitializedLoads()
356 Ice::Variable *loadData = load->getDest(); in eliminateUnitializedLoads()
360 for(Ice::Inst *use : *getUses(loadData)) in eliminateUnitializedLoads()
362 for(Ice::SizeT i = 0; i < use->getSrcSize(); i++) in eliminateUnitializedLoads()
388 for(Ice::CfgNode *block : function->getNodes()) in optimizeSingleBasicBlockLoadsStores()
395 Ice::Inst *store; in optimizeSingleBasicBlockLoadsStores()
399 std::unordered_map<const Ice::InstAlloca *, LastStore> lastStoreTo; in optimizeSingleBasicBlockLoadsStores()
401 for(Ice::Inst &inst : block->getInsts()) in optimizeSingleBasicBlockLoadsStores()
410 Ice::Operand *address = inst.getStoreAddress(); in optimizeSingleBasicBlockLoadsStores()
412 if(Ice::InstAlloca *alloca = allocaOf(address)) in optimizeSingleBasicBlockLoadsStores()
422 Ice::Inst *previousStore = entry->second.store; in optimizeSingleBasicBlockLoadsStores()
437 if(Ice::InstAlloca *alloca = allocaOf(inst.getLoadAddress())) in optimizeSingleBasicBlockLoadsStores()
442 const Ice::Inst *store = entry->second.store; in optimizeSingleBasicBlockLoadsStores()
463 void Optimizer::analyzeUses(Ice::Cfg *function) in analyzeUses()
465 for(Ice::CfgNode *basicBlock : function->getNodes()) in analyzeUses()
467 for(Ice::Inst &instruction : basicBlock->getInsts()) in analyzeUses()
479 for(Ice::SizeT i = 0; i < instruction.getSrcSize(); i++) in analyzeUses()
481 Ice::SizeT unique = 0; in analyzeUses()
492 Ice::Operand *src = instruction.getSrc(i); in analyzeUses()
500 void Optimizer::replace(Ice::Inst *instruction, Ice::Operand *newValue) in replace()
502 Ice::Variable *oldValue = instruction->getDest(); in replace()
511 for(Ice::Inst *use : *getUses(oldValue)) in replace()
515 for(Ice::SizeT i = 0; i < use->getSrcSize(); i++) in replace()
532 void Optimizer::deleteInstruction(Ice::Inst *instruction) in deleteInstruction()
542 for(Ice::SizeT i = 0; i < instruction->getSrcSize(); i++) in deleteInstruction()
544 Ice::Operand *src = instruction->getSrc(i); in deleteInstruction()
556 if(Ice::Variable *var = llvm::dyn_cast<Ice::Variable>(src)) in deleteInstruction()
565 bool Optimizer::isDead(Ice::Inst *instruction) in isDead()
567 Ice::Variable *dest = instruction->getDest(); in isDead()
575 if(Ice::Variable *address = llvm::dyn_cast<Ice::Variable>(instruction->getStoreAddress())) in isDead()
577 Ice::Inst *def = getDefinition(address); in isDead()
579 if(def && llvm::isa<Ice::InstAlloca>(def)) in isDead()
597 bool Optimizer::isStaticallyIndexedArray(Ice::Operand *allocaAddress) in isStaticallyIndexedArray()
625 auto *arithmetic = llvm::dyn_cast<Ice::InstArithmetic>(use); in isStaticallyIndexedArray()
626 if(arithmetic && arithmetic->getOp() == Ice::InstArithmetic::Add) in isStaticallyIndexedArray()
630 if(llvm::isa<Ice::Constant>(rhs)) in isStaticallyIndexedArray()
643 Ice::InstAlloca *Optimizer::allocaOf(Ice::Operand *address) in allocaOf()
645 Ice::Variable *addressVar = llvm::dyn_cast<Ice::Variable>(address); in allocaOf()
646 Ice::Inst *def = addressVar ? getDefinition(addressVar) : nullptr; in allocaOf()
647 Ice::InstAlloca *alloca = def ? llvm::dyn_cast<Ice::InstAlloca>(def) : nullptr; in allocaOf()
652 const Ice::InstIntrinsic *Optimizer::asLoadSubVector(const Ice::Inst *instruction) in asLoadSubVector()
654 if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsic>(instruction)) in asLoadSubVector()
656 if(instrinsic->getIntrinsicID() == Ice::Intrinsics::LoadSubVector) in asLoadSubVector()
665 const Ice::InstIntrinsic *Optimizer::asStoreSubVector(const Ice::Inst *instruction) in asStoreSubVector()
667 if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsic>(instruction)) in asStoreSubVector()
669 if(instrinsic->getIntrinsicID() == Ice::Intrinsics::StoreSubVector) in asStoreSubVector()
678 bool Optimizer::isLoad(const Ice::Inst &instruction) in isLoad()
680 if(llvm::isa<Ice::InstLoad>(&instruction)) in isLoad()
688 bool Optimizer::isStore(const Ice::Inst &instruction) in isStore()
690 if(llvm::isa<Ice::InstStore>(&instruction)) in isStore()
698 bool Optimizer::loadTypeMatchesStore(const Ice::Inst *load, const Ice::Inst *store) in loadTypeMatchesStore()
718 return llvm::cast<Ice::ConstantInteger32>(storeSubVector->getSrc(2))->getValue() == in loadTypeMatchesStore()
719 llvm::cast<Ice::ConstantInteger32>(loadSubVector->getSrc(1))->getValue(); in loadTypeMatchesStore()
726 bool Optimizer::storeTypeMatchesStore(const Ice::Inst *store1, const Ice::Inst *store2) in storeTypeMatchesStore()
741 return llvm::cast<Ice::ConstantInteger32>(storeSubVector1->getSrc(2))->getValue() == in storeTypeMatchesStore()
742 llvm::cast<Ice::ConstantInteger32>(storeSubVector2->getSrc(2))->getValue(); in storeTypeMatchesStore()
764 if(llvm::isa<Ice::InstAlloca>(inst)) in collectDiagnostics()
781 Optimizer::Uses *Optimizer::getUses(Ice::Operand *operand) in getUses()
783 Optimizer::Uses *uses = (Optimizer::Uses *)operand->Ice::Operand::getExternalData(); in getUses()
793 void Optimizer::setUses(Ice::Operand *operand, Optimizer::Uses *uses) in setUses()
795 if(auto *oldUses = reinterpret_cast<Optimizer::Uses *>(operand->Ice::Operand::getExternalData())) in setUses()
800 operand->Ice::Operand::setExternalData(uses); in setUses()
803 bool Optimizer::hasUses(Ice::Operand *operand) const in hasUses()
805 return operand->Ice::Operand::getExternalData() != nullptr; in hasUses()
808 Ice::Inst *Optimizer::getDefinition(Ice::Variable *var) in getDefinition()
810 return (Ice::Inst *)var->Ice::Variable::getExternalData(); in getDefinition()
813 void Optimizer::setDefinition(Ice::Variable *var, Ice::Inst *inst) in setDefinition()
815 var->Ice::Variable::setExternalData(inst); in setDefinition()
823 void Optimizer::Uses::insert(Ice::Operand *value, Ice::Inst *instruction) in insert()
843 void Optimizer::Uses::erase(Ice::Inst *instruction) in erase()
883 void optimize(Ice::Cfg *function, Nucleus::OptimizerReport *report) in optimize()