mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-14 15:39:00 +00:00
Switch the cost model analysis over to just the TTI interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
abc227d9b3
commit
194bd71b06
@ -34,7 +34,7 @@ namespace {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Class identification, replacement for typeinfo
|
static char ID; // Class identification, replacement for typeinfo
|
||||||
CostModelAnalysis() : FunctionPass(ID), F(0), VTTI(0) {
|
CostModelAnalysis() : FunctionPass(ID), F(0), TTI(0) {
|
||||||
initializeCostModelAnalysisPass(
|
initializeCostModelAnalysisPass(
|
||||||
*PassRegistry::getPassRegistry());
|
*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
@ -52,8 +52,8 @@ namespace {
|
|||||||
|
|
||||||
/// The function that we analyze.
|
/// The function that we analyze.
|
||||||
Function *F;
|
Function *F;
|
||||||
/// Vector target information.
|
/// Target information.
|
||||||
const VectorTargetTransformInfo *VTTI;
|
const TargetTransformInfo *TTI;
|
||||||
};
|
};
|
||||||
} // End of anonymous namespace
|
} // End of anonymous namespace
|
||||||
|
|
||||||
@ -75,25 +75,20 @@ CostModelAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
bool
|
bool
|
||||||
CostModelAnalysis::runOnFunction(Function &F) {
|
CostModelAnalysis::runOnFunction(Function &F) {
|
||||||
this->F = &F;
|
this->F = &F;
|
||||||
|
|
||||||
// Target information.
|
|
||||||
TargetTransformInfo *TTI;
|
|
||||||
TTI = getAnalysisIfAvailable<TargetTransformInfo>();
|
TTI = getAnalysisIfAvailable<TargetTransformInfo>();
|
||||||
if (TTI)
|
|
||||||
VTTI = TTI->getVectorTargetTransformInfo();
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
||||||
if (!VTTI)
|
if (!TTI)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
switch (I->getOpcode()) {
|
switch (I->getOpcode()) {
|
||||||
case Instruction::Ret:
|
case Instruction::Ret:
|
||||||
case Instruction::PHI:
|
case Instruction::PHI:
|
||||||
case Instruction::Br: {
|
case Instruction::Br: {
|
||||||
return VTTI->getCFInstrCost(I->getOpcode());
|
return TTI->getCFInstrCost(I->getOpcode());
|
||||||
}
|
}
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
case Instruction::FAdd:
|
case Instruction::FAdd:
|
||||||
@ -113,28 +108,28 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
|||||||
case Instruction::And:
|
case Instruction::And:
|
||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
case Instruction::Xor: {
|
case Instruction::Xor: {
|
||||||
return VTTI->getArithmeticInstrCost(I->getOpcode(), I->getType());
|
return TTI->getArithmeticInstrCost(I->getOpcode(), I->getType());
|
||||||
}
|
}
|
||||||
case Instruction::Select: {
|
case Instruction::Select: {
|
||||||
const SelectInst *SI = cast<SelectInst>(I);
|
const SelectInst *SI = cast<SelectInst>(I);
|
||||||
Type *CondTy = SI->getCondition()->getType();
|
Type *CondTy = SI->getCondition()->getType();
|
||||||
return VTTI->getCmpSelInstrCost(I->getOpcode(), I->getType(), CondTy);
|
return TTI->getCmpSelInstrCost(I->getOpcode(), I->getType(), CondTy);
|
||||||
}
|
}
|
||||||
case Instruction::ICmp:
|
case Instruction::ICmp:
|
||||||
case Instruction::FCmp: {
|
case Instruction::FCmp: {
|
||||||
Type *ValTy = I->getOperand(0)->getType();
|
Type *ValTy = I->getOperand(0)->getType();
|
||||||
return VTTI->getCmpSelInstrCost(I->getOpcode(), ValTy);
|
return TTI->getCmpSelInstrCost(I->getOpcode(), ValTy);
|
||||||
}
|
}
|
||||||
case Instruction::Store: {
|
case Instruction::Store: {
|
||||||
const StoreInst *SI = cast<StoreInst>(I);
|
const StoreInst *SI = cast<StoreInst>(I);
|
||||||
Type *ValTy = SI->getValueOperand()->getType();
|
Type *ValTy = SI->getValueOperand()->getType();
|
||||||
return VTTI->getMemoryOpCost(I->getOpcode(), ValTy,
|
return TTI->getMemoryOpCost(I->getOpcode(), ValTy,
|
||||||
SI->getAlignment(),
|
SI->getAlignment(),
|
||||||
SI->getPointerAddressSpace());
|
SI->getPointerAddressSpace());
|
||||||
}
|
}
|
||||||
case Instruction::Load: {
|
case Instruction::Load: {
|
||||||
const LoadInst *LI = cast<LoadInst>(I);
|
const LoadInst *LI = cast<LoadInst>(I);
|
||||||
return VTTI->getMemoryOpCost(I->getOpcode(), I->getType(),
|
return TTI->getMemoryOpCost(I->getOpcode(), I->getType(),
|
||||||
LI->getAlignment(),
|
LI->getAlignment(),
|
||||||
LI->getPointerAddressSpace());
|
LI->getPointerAddressSpace());
|
||||||
}
|
}
|
||||||
@ -151,7 +146,7 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
|||||||
case Instruction::FPTrunc:
|
case Instruction::FPTrunc:
|
||||||
case Instruction::BitCast: {
|
case Instruction::BitCast: {
|
||||||
Type *SrcTy = I->getOperand(0)->getType();
|
Type *SrcTy = I->getOperand(0)->getType();
|
||||||
return VTTI->getCastInstrCost(I->getOpcode(), I->getType(), SrcTy);
|
return TTI->getCastInstrCost(I->getOpcode(), I->getType(), SrcTy);
|
||||||
}
|
}
|
||||||
case Instruction::ExtractElement: {
|
case Instruction::ExtractElement: {
|
||||||
const ExtractElementInst * EEI = cast<ExtractElementInst>(I);
|
const ExtractElementInst * EEI = cast<ExtractElementInst>(I);
|
||||||
@ -159,8 +154,8 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
|||||||
unsigned Idx = -1;
|
unsigned Idx = -1;
|
||||||
if (CI)
|
if (CI)
|
||||||
Idx = CI->getZExtValue();
|
Idx = CI->getZExtValue();
|
||||||
return VTTI->getVectorInstrCost(I->getOpcode(),
|
return TTI->getVectorInstrCost(I->getOpcode(),
|
||||||
EEI->getOperand(0)->getType(), Idx);
|
EEI->getOperand(0)->getType(), Idx);
|
||||||
}
|
}
|
||||||
case Instruction::InsertElement: {
|
case Instruction::InsertElement: {
|
||||||
const InsertElementInst * IE = cast<InsertElementInst>(I);
|
const InsertElementInst * IE = cast<InsertElementInst>(I);
|
||||||
@ -168,8 +163,8 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
|
|||||||
unsigned Idx = -1;
|
unsigned Idx = -1;
|
||||||
if (CI)
|
if (CI)
|
||||||
Idx = CI->getZExtValue();
|
Idx = CI->getZExtValue();
|
||||||
return VTTI->getVectorInstrCost(I->getOpcode(),
|
return TTI->getVectorInstrCost(I->getOpcode(),
|
||||||
IE->getType(), Idx);
|
IE->getType(), Idx);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// We don't have any information on this instruction.
|
// We don't have any information on this instruction.
|
||||||
|
Loading…
Reference in New Issue
Block a user