mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 08:26:29 +00:00
[lanai] Add getIntImmCost in LanaiTargetTransformInfo.
Add simple int immediate cost function. llvm-svn: 309721
This commit is contained in:
parent
ce20a18119
commit
c6cb382a99
@ -22,6 +22,7 @@
|
||||
#include "LanaiTargetMachine.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/CodeGen/BasicTTIImpl.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
|
||||
namespace llvm {
|
||||
@ -49,6 +50,32 @@ public:
|
||||
return TTI::PSK_Software;
|
||||
}
|
||||
|
||||
int getIntImmCost(const APInt &Imm, Type *Ty) {
|
||||
assert(Ty->isIntegerTy());
|
||||
if (Imm == 0)
|
||||
return TTI::TCC_Free;
|
||||
if (isInt<16>(Imm.getSExtValue()))
|
||||
return TTI::TCC_Basic;
|
||||
if (isInt<21>(Imm.getZExtValue()))
|
||||
return TTI::TCC_Basic;
|
||||
if (isInt<32>(Imm.getSExtValue())) {
|
||||
if ((Imm.getSExtValue() & 0xFFFF) == 0)
|
||||
return TTI::TCC_Basic;
|
||||
return 2 * TTI::TCC_Basic;
|
||||
}
|
||||
|
||||
return 4 * TTI::TCC_Basic;
|
||||
}
|
||||
|
||||
int getIntImmCost(unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) {
|
||||
return getIntImmCost(Imm, Ty);
|
||||
}
|
||||
|
||||
int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
|
||||
Type *Ty) {
|
||||
return getIntImmCost(Imm, Ty);
|
||||
}
|
||||
|
||||
unsigned getArithmeticInstrCost(
|
||||
unsigned Opcode, Type *Ty,
|
||||
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
||||
|
Loading…
Reference in New Issue
Block a user