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 "llvm/CodeGen/SelectionDAG.h"
20 #include "llvm/Target/TargetLowering.h"
25 // Start the numbering from where ISD NodeType finishes.
26 FIRST_NUMBER = ISD::BUILTIN_OP_END,
54 LoadV2 = ISD::FIRST_TARGET_MEMORY_OPCODE,
68 StoreParamS32, // to sext and store a <32bit value, not used currently
69 StoreParamU32, // to zext and store a <32bit value, not used currently
85 Tex1DArrayFloatFloatLevel,
86 Tex1DArrayFloatFloatGrad,
89 Tex1DArrayI32FloatLevel,
90 Tex1DArrayI32FloatGrad,
100 Tex2DArrayFloatFloat,
101 Tex2DArrayFloatFloatLevel,
102 Tex2DArrayFloatFloatGrad,
105 Tex2DArrayI32FloatLevel,
106 Tex2DArrayI32FloatGrad,
109 Tex3DFloatFloatLevel,
116 // Surface intrinsics
131 Suld1DArrayV2I16Trap,
132 Suld1DArrayV2I32Trap,
134 Suld1DArrayV4I16Trap,
135 Suld1DArrayV4I32Trap,
151 Suld2DArrayV2I16Trap,
152 Suld2DArrayV2I32Trap,
154 Suld2DArrayV4I16Trap,
155 Suld2DArrayV4I32Trap,
169 class NVPTXSubtarget;
171 //===--------------------------------------------------------------------===//
172 // TargetLowering Implementation
173 //===--------------------------------------------------------------------===//
174 class NVPTXTargetLowering : public TargetLowering {
176 explicit NVPTXTargetLowering(NVPTXTargetMachine &TM);
177 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
179 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
180 SDValue LowerGlobalAddress(const GlobalValue *GV, int64_t Offset,
181 SelectionDAG &DAG) const;
183 const char *getTargetNodeName(unsigned Opcode) const override;
185 bool isTypeSupportedInIntrinsic(MVT VT) const;
187 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
188 unsigned Intrinsic) const override;
190 /// isLegalAddressingMode - Return true if the addressing mode represented
191 /// by AM is legal for this target, for a load/store of the specified type
192 /// Used to guide target specific optimizations, like loop strength
193 /// reduction (LoopStrengthReduce.cpp) and memory optimization for
194 /// address mode (CodeGenPrepare.cpp)
195 bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const override;
197 /// getFunctionAlignment - Return the Log2 alignment of this function.
198 unsigned getFunctionAlignment(const Function *F) const;
200 EVT getSetCCResultType(LLVMContext &, EVT VT) const override {
202 return MVT::getVectorVT(MVT::i1, VT.getVectorNumElements());
207 getConstraintType(const std::string &Constraint) const override;
208 std::pair<unsigned, const TargetRegisterClass *>
209 getRegForInlineAsmConstraint(const std::string &Constraint,
210 MVT VT) const override;
212 SDValue LowerFormalArguments(
213 SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
214 const SmallVectorImpl<ISD::InputArg> &Ins, SDLoc dl, SelectionDAG &DAG,
215 SmallVectorImpl<SDValue> &InVals) const override;
217 SDValue LowerCall(CallLoweringInfo &CLI,
218 SmallVectorImpl<SDValue> &InVals) const override;
220 std::string getPrototype(Type *, const ArgListTy &,
221 const SmallVectorImpl<ISD::OutputArg> &,
222 unsigned retAlignment,
223 const ImmutableCallSite *CS) const;
226 LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
227 const SmallVectorImpl<ISD::OutputArg> &Outs,
228 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
229 SelectionDAG &DAG) const override;
231 void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
232 std::vector<SDValue> &Ops,
233 SelectionDAG &DAG) const override;
235 NVPTXTargetMachine *nvTM;
237 // PTX always uses 32-bit shift amounts
238 MVT getScalarShiftAmountTy(EVT LHSTy) const override { return MVT::i32; }
240 bool shouldSplitVectorType(EVT VT) const override;
243 const NVPTXSubtarget &nvptxSubtarget; // cache the subtarget here
245 SDValue getExtSymb(SelectionDAG &DAG, const char *name, int idx,
246 EVT = MVT::i32) const;
247 SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
248 SDValue getParamHelpSymbol(SelectionDAG &DAG, int idx);
250 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
252 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
253 SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
255 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
256 SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
257 SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
259 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
260 SelectionDAG &DAG) const override;
262 unsigned getArgumentAlignment(SDValue Callee, const ImmutableCallSite *CS,
263 Type *Ty, unsigned Idx) const;
267 #endif // NVPTXISELLOWERING_H