[llvm-commits] [llvm] r169172 - /llvm/trunk/lib/Analysis/CostModel.cpp
Nadav Rotem
nrotem at apple.com
Mon Dec 3 14:47:13 PST 2012
Author: nadav
Date: Mon Dec 3 16:47:12 2012
New Revision: 169172
URL: http://llvm.org/viewvc/llvm-project?rev=169172&view=rev
Log:
constify the cost API
Modified:
llvm/trunk/lib/Analysis/CostModel.cpp
Modified: llvm/trunk/lib/Analysis/CostModel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CostModel.cpp?rev=169172&r1=169171&r2=169172&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CostModel.cpp (original)
+++ llvm/trunk/lib/Analysis/CostModel.cpp Mon Dec 3 16:47:12 2012
@@ -40,7 +40,7 @@
/// Returns -1 if the cost is unknown.
/// Note, this method does not cache the cost calculation and it
/// can be expensive in some cases.
- unsigned getInstructionCost(Instruction *I) const;
+ unsigned getInstructionCost(const Instruction *I) const;
private:
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -82,7 +82,7 @@
return false;
}
-unsigned CostModelAnalysis::getInstructionCost(Instruction *I) const {
+unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
if (!VTTI)
return -1;
@@ -113,7 +113,7 @@
return VTTI->getArithmeticInstrCost(I->getOpcode(), I->getType());
}
case Instruction::Select: {
- SelectInst *SI = cast<SelectInst>(I);
+ const SelectInst *SI = cast<SelectInst>(I);
Type *CondTy = SI->getCondition()->getType();
return VTTI->getCmpSelInstrCost(I->getOpcode(), I->getType(), CondTy);
}
@@ -123,14 +123,14 @@
return VTTI->getCmpSelInstrCost(I->getOpcode(), ValTy);
}
case Instruction::Store: {
- StoreInst *SI = cast<StoreInst>(I);
+ const StoreInst *SI = cast<StoreInst>(I);
Type *ValTy = SI->getValueOperand()->getType();
return VTTI->getMemoryOpCost(I->getOpcode(), ValTy,
SI->getAlignment(),
SI->getPointerAddressSpace());
}
case Instruction::Load: {
- LoadInst *LI = cast<LoadInst>(I);
+ const LoadInst *LI = cast<LoadInst>(I);
return VTTI->getMemoryOpCost(I->getOpcode(), I->getType(),
LI->getAlignment(),
LI->getPointerAddressSpace());
@@ -151,7 +151,7 @@
return VTTI->getCastInstrCost(I->getOpcode(), I->getType(), SrcTy);
}
case Instruction::ExtractElement: {
- ExtractElementInst * EEI = cast<ExtractElementInst>(I);
+ const ExtractElementInst * EEI = cast<ExtractElementInst>(I);
ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1));
unsigned Idx = -1;
if (CI)
@@ -160,7 +160,7 @@
EEI->getOperand(0)->getType(), Idx);
}
case Instruction::InsertElement: {
- InsertElementInst * IE = cast<InsertElementInst>(I);
+ const InsertElementInst * IE = cast<InsertElementInst>(I);
ConstantInt *CI = dyn_cast<ConstantInt>(IE->getOperand(2));
unsigned Idx = -1;
if (CI)
More information about the llvm-commits
mailing list