#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 {
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,