1 //===-- NVPTXISelLowering.h - NVPTX DAG Lowering Interface ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interfaces that NVPTX uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef NVPTXISELLOWERING_H
16 #define NVPTXISELLOWERING_H
19 #include "NVPTXSubtarget.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/Target/TargetLowering.h"
26 // Start the numbering from where ISD NodeType finishes.
27 FIRST_NUMBER = ISD::BUILTIN_OP_END,
55 LoadV2 = ISD::FIRST_TARGET_MEMORY_OPCODE,
69 StoreParamS32, // to sext and store a <32bit value, not used currently
70 StoreParamU32, // to zext and store a <32bit value, not used currently
86 Tex1DArrayFloatFloatLevel,
87 Tex1DArrayFloatFloatGrad,
90 Tex1DArrayI32FloatLevel,
91 Tex1DArrayI32FloatGrad,
101 Tex2DArrayFloatFloat,
102 Tex2DArrayFloatFloatLevel,
103 Tex2DArrayFloatFloatGrad,
106 Tex2DArrayI32FloatLevel,
107 Tex2DArrayI32FloatGrad,
110 Tex3DFloatFloatLevel,
117 // Surface intrinsics
132 Suld1DArrayV2I16Trap,
133 Suld1DArrayV2I32Trap,
135 Suld1DArrayV4I16Trap,
136 Suld1DArrayV4I32Trap,
152 Suld2DArrayV2I16Trap,
153 Suld2DArrayV2I32Trap,
155 Suld2DArrayV4I16Trap,
156 Suld2DArrayV4I32Trap,
170 //===--------------------------------------------------------------------===//
171 // TargetLowering Implementation
172 //===--------------------------------------------------------------------===//
173 class NVPTXTargetLowering : public TargetLowering {
175 explicit NVPTXTargetLowering(NVPTXTargetMachine &TM);
176 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
178 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
179 SDValue LowerGlobalAddress(const GlobalValue *GV, int64_t Offset,
180 SelectionDAG &DAG) const;
182 const char *getTargetNodeName(unsigned Opcode) const override;
184 bool isTypeSupportedInIntrinsic(MVT VT) const;
186 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
187 unsigned Intrinsic) const override;
189 /// isLegalAddressingMode - Return true if the addressing mode represented
190 /// by AM is legal for this target, for a load/store of the specified type
191 /// Used to guide target specific optimizations, like loop strength
192 /// reduction (LoopStrengthReduce.cpp) and memory optimization for
193 /// address mode (CodeGenPrepare.cpp)
194 bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const override;
196 /// getFunctionAlignment - Return the Log2 alignment of this function.
197 unsigned getFunctionAlignment(const Function *F) const;
199 EVT getSetCCResultType(LLVMContext &, EVT VT) const override {
201 return MVT::getVectorVT(MVT::i1, VT.getVectorNumElements());
206 getConstraintType(const std::string &Constraint) const override;
207 std::pair<unsigned, const TargetRegisterClass *>
208 getRegForInlineAsmConstraint(const std::string &Constraint,
209 MVT VT) const override;
211 SDValue LowerFormalArguments(
212 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
213 const SmallVectorImpl<ISD::InputArg> &Ins, SDLoc dl, SelectionDAG &DAG,
214 SmallVectorImpl<SDValue> &InVals) const override;
216 SDValue LowerCall(CallLoweringInfo &CLI,
217 SmallVectorImpl<SDValue> &InVals) const override;
219 std::string getPrototype(Type *, const ArgListTy &,
220 const SmallVectorImpl<ISD::OutputArg> &,
221 unsigned retAlignment,
222 const ImmutableCallSite *CS) const;
225 LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
226 const SmallVectorImpl<ISD::OutputArg> &Outs,
227 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
228 SelectionDAG &DAG) const override;
230 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
231 std::vector<SDValue> &Ops,
232 SelectionDAG &DAG) const override;
234 NVPTXTargetMachine *nvTM;
236 // PTX always uses 32-bit shift amounts
237 MVT getScalarShiftAmountTy(EVT LHSTy) const override { return MVT::i32; }
239 bool shouldSplitVectorType(EVT VT) const override;
242 const NVPTXSubtarget &nvptxSubtarget; // cache the subtarget here
244 SDValue getExtSymb(SelectionDAG &DAG, const char *name, int idx,
245 EVT = MVT::i32) const;
246 SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
247 SDValue getParamHelpSymbol(SelectionDAG &DAG, int idx);
249 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
251 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
252 SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
254 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
255 SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
256 SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
258 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
259 SelectionDAG &DAG) const override;
261 unsigned getArgumentAlignment(SDValue Callee, const ImmutableCallSite *CS,
262 Type *Ty, unsigned Idx) const;
266 #endif // NVPTXISELLOWERING_H