diff options
| author | Jacques Pienaar <jpienaar@google.com> | 2017-08-01 18:40:08 +0000 |
|---|---|---|
| committer | Jacques Pienaar <jpienaar@google.com> | 2017-08-01 18:40:08 +0000 |
| commit | 922928b62debdbb1682684cadfb5edd044cf1f1f (patch) | |
| tree | e6c8502c55a690235e4b6fc770881193edc5a71d | |
| parent | 6e1f3b1c90a39fd1f681ad418ec80426614c3bd0 (diff) | |
| download | bcm5719-llvm-922928b62debdbb1682684cadfb5edd044cf1f1f.tar.gz bcm5719-llvm-922928b62debdbb1682684cadfb5edd044cf1f1f.zip | |
[lanai] Add getIntImmCost in LanaiTargetTransformInfo.
Add simple int immediate cost function.
llvm-svn: 309721
| -rw-r--r-- | llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h b/llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h index d95c16fc3ca..12613ed273f 100644 --- a/llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h +++ b/llvm/lib/Target/Lanai/LanaiTargetTransformInfo.h @@ -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, |

