LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NVPTXISelLowering.h
Go to the documentation of this file.
1 //===-- NVPTXISelLowering.h - NVPTX DAG Lowering Interface ------*- 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 defines the interfaces that NVPTX uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef NVPTXISELLOWERING_H
16 #define NVPTXISELLOWERING_H
17 
18 #include "NVPTX.h"
19 #include "NVPTXSubtarget.h"
22 
23 namespace llvm {
24 namespace NVPTXISD {
25 enum NodeType {
26  // Start the numbering from where ISD NodeType finishes.
54 
57  LDGV2, // LDG.v2
58  LDGV4, // LDG.v4
59  LDUV2, // LDU.v2
60  LDUV4, // LDU.v4
69  StoreParamS32, // to sext and store a <32bit value, not used currently
70  StoreParamU32, // to zext and store a <32bit value, not used currently
74 };
75 }
76 
77 //===--------------------------------------------------------------------===//
78 // TargetLowering Implementation
79 //===--------------------------------------------------------------------===//
81 public:
83  virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
84 
86  SDValue LowerGlobalAddress(const GlobalValue *GV, int64_t Offset,
87  SelectionDAG &DAG) const;
88 
89  virtual const char *getTargetNodeName(unsigned Opcode) const;
90 
91  bool isTypeSupportedInIntrinsic(MVT VT) const;
92 
93  bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
94  unsigned Intrinsic) const;
95 
96  /// isLegalAddressingMode - Return true if the addressing mode represented
97  /// by AM is legal for this target, for a load/store of the specified type
98  /// Used to guide target specific optimizations, like loop strength
99  /// reduction (LoopStrengthReduce.cpp) and memory optimization for
100  /// address mode (CodeGenPrepare.cpp)
101  virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
102 
103  /// getFunctionAlignment - Return the Log2 alignment of this function.
104  virtual unsigned getFunctionAlignment(const Function *F) const;
105 
106  virtual EVT getSetCCResultType(LLVMContext &, EVT VT) const {
107  if (VT.isVector())
109  return MVT::i1;
110  }
111 
112  ConstraintType getConstraintType(const std::string &Constraint) const;
113  std::pair<unsigned, const TargetRegisterClass *>
114  getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const;
115 
117  SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
119  SmallVectorImpl<SDValue> &InVals) const;
120 
121  virtual SDValue
122  LowerCall(CallLoweringInfo &CLI, SmallVectorImpl<SDValue> &InVals) const;
123 
124  std::string getPrototype(Type *, const ArgListTy &,
126  unsigned retAlignment,
127  const ImmutableCallSite *CS) const;
128 
129  virtual SDValue
130  LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
132  const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
133  SelectionDAG &DAG) const;
134 
135  virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
136  std::vector<SDValue> &Ops,
137  SelectionDAG &DAG) const;
138 
140 
141  // PTX always uses 32-bit shift amounts
142  virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
143 
144  virtual bool shouldSplitVectorElementType(EVT VT) const;
145 
146 private:
147  const NVPTXSubtarget &nvptxSubtarget; // cache the subtarget here
148 
149  SDValue getExtSymb(SelectionDAG &DAG, const char *name, int idx,
150  EVT = MVT::i32) const;
151  SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
152  SDValue getParamHelpSymbol(SelectionDAG &DAG, int idx);
153 
154  SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
155 
156  SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
157  SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
158 
159  SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
160  SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
161  SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
162 
163  virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
164  SelectionDAG &DAG) const;
165 
166  unsigned getArgumentAlignment(SDValue Callee, const ImmutableCallSite *CS,
167  Type *Ty, unsigned Idx) const;
168 };
169 } // namespace llvm
170 
171 #endif // NVPTXISELLOWERING_H
static MVT getVectorVT(MVT VT, unsigned NumElements)
Definition: ValueTypes.h:500
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, unsigned Intrinsic) const
virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const
F(f)
bool isVector() const
isVector - Return true if this is a vector value type.
Definition: ValueTypes.h:661
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
virtual unsigned getFunctionAlignment(const Function *F) const
getFunctionAlignment - Return the Log2 alignment of this function.
ID
LLVM Calling Convention Representation.
Definition: CallingConv.h:26
bool isTypeSupportedInIntrinsic(MVT VT) const
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
ConstraintType getConstraintType(const std::string &Constraint) const
virtual SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const
virtual EVT getSetCCResultType(LLVMContext &, EVT VT) const
std::vector< ArgListEntry > ArgListTy
std::string getPrototype(Type *, const ArgListTy &, const SmallVectorImpl< ISD::OutputArg > &, unsigned retAlignment, const ImmutableCallSite *CS) const
virtual SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const
static const int FIRST_TARGET_MEMORY_OPCODE
Definition: ISDOpcodes.h:648
virtual bool shouldSplitVectorElementType(EVT VT) const
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:318
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, SDLoc dl, SelectionDAG &DAG) const
NVPTXTargetLowering(NVPTXTargetMachine &TM)
virtual MVT getScalarShiftAmountTy(EVT LHSTy) const
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
NVPTXTargetMachine * nvTM
virtual const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const
unsigned getVectorNumElements() const
Definition: ValueTypes.h:771