LLVM  4.0.0
LanaiTargetTransformInfo.h
Go to the documentation of this file.
1 //===-- LanaiTargetTransformInfo.h - Lanai specific TTI ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file a TargetTransformInfo::Concept conforming object specific to the
11 // Lanai target machine. It uses the target's detailed information to
12 // provide more precise answers to certain TTI queries, while letting the
13 // target independent and default TTI implementations handle the rest.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
19 
20 #include "Lanai.h"
21 #include "LanaiSubtarget.h"
22 #include "LanaiTargetMachine.h"
26 
27 namespace llvm {
28 class LanaiTTIImpl : public BasicTTIImplBase<LanaiTTIImpl> {
30  typedef TargetTransformInfo TTI;
31  friend BaseT;
32 
33  const LanaiSubtarget *ST;
34  const LanaiTargetLowering *TLI;
35 
36  const LanaiSubtarget *getST() const { return ST; }
37  const LanaiTargetLowering *getTLI() const { return TLI; }
38 
39 public:
40  explicit LanaiTTIImpl(const LanaiTargetMachine *TM, const Function &F)
41  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42  TLI(ST->getTargetLowering()) {}
43 
44  bool shouldBuildLookupTables() const { return false; }
45 
47  if (TyWidth == 32)
48  return TTI::PSK_FastHardware;
49  return TTI::PSK_Software;
50  }
51 
53  unsigned Opcode, Type *Ty,
59  int ISD = TLI->InstructionOpcodeToISD(Opcode);
60 
61  switch (ISD) {
62  default:
63  return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
64  Opd1PropInfo, Opd2PropInfo);
65  case ISD::MUL:
66  case ISD::SDIV:
67  case ISD::UDIV:
68  case ISD::UREM:
69  // This increases the cost associated with multiplication and division
70  // to 64 times what the baseline arithmetic cost is. The arithmetic
71  // instruction cost was arbitrarily chosen to reduce the desirability
72  // of emitting arithmetic instructions that are emulated in software.
73  // TODO: Investigate the performance impact given specialized lowerings.
74  return 64 * BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
75  Opd1PropInfo, Opd2PropInfo);
76  }
77  }
78 };
79 
80 } // end namespace llvm
81 
82 #endif // LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:40
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
#define F(x, y, z)
Definition: MD5.cpp:51
PopcntSupportKind
Flags indicating the kind of support for population count.
bool shouldBuildLookupTables() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >())
OperandValueProperties
Additional properties of an operand's values.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >())
Definition: BasicTTIImpl.h:306
const DataLayout & getDataLayout() const
LanaiTTIImpl(const LanaiTargetMachine *TM, const Function &F)
static const Function * getParent(const Value *V)
OperandValueKind
Additional information about an operand's possible values.
This pass exposes codegen information to IR-level passes.
TargetTransformInfo::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
This file describes how to lower LLVM code to machine code.