[llvm] r309721 - [lanai] Add getIntImmCost in LanaiTargetTransformInfo.

Jacques Pienaar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 11:40:09 PDT 2017


Author: jpienaar
Date: Tue Aug  1 11:40:08 2017
New Revision: 309721

URL: http://llvm.org/viewvc/llvm-project?rev=309721&view=rev
Log:
[lanai] Add getIntImmCost in LanaiTargetTransformInfo.

Add simple int immediate cost function.


Modified:
    llvm/trunk/lib/Target/Lanai/LanaiTargetTransformInfo.h

Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetTransformInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetTransformInfo.h?rev=309721&r1=309720&r2=309721&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Lanai/LanaiTargetTransformInfo.h (original)
+++ llvm/trunk/lib/Target/Lanai/LanaiTargetTransformInfo.h Tue Aug  1 11:40:08 2017
@@ -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,




More information about the llvm-commits mailing list