LLVM  3.7.0
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 LLVM_LIB_TARGET_NVPTX_NVPTXISELLOWERING_H
16 #define LLVM_LIB_TARGET_NVPTX_NVPTXISELLOWERING_H
17 
18 #include "NVPTX.h"
21 
22 namespace llvm {
23 namespace NVPTXISD {
24 enum NodeType : unsigned {
25  // Start the numbering from where ISD NodeType finishes.
58 
61  LDGV2, // LDG.v2
62  LDGV4, // LDG.v4
63  LDUV2, // LDU.v2
64  LDUV4, // LDU.v4
73  StoreParamS32, // to sext and store a <32bit value, not used currently
74  StoreParamU32, // to zext and store a <32bit value, not used currently
78 
79  // Texture intrinsics
248 
249  // Surface intrinsics
261 
273 
285 
297 
309 
321 
333 
345 
357 
369 
381 
393 
405 
417 
429 };
430 }
431 
432 class NVPTXSubtarget;
433 
434 //===--------------------------------------------------------------------===//
435 // TargetLowering Implementation
436 //===--------------------------------------------------------------------===//
438 public:
439  explicit NVPTXTargetLowering(const NVPTXTargetMachine &TM,
440  const NVPTXSubtarget &STI);
441  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
442 
444  SDValue LowerGlobalAddress(const GlobalValue *GV, int64_t Offset,
445  SelectionDAG &DAG) const;
446 
447  const char *getTargetNodeName(unsigned Opcode) const override;
448 
449  bool isTypeSupportedInIntrinsic(MVT VT) const;
450 
451  bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
452  unsigned Intrinsic) const override;
453 
454  /// isLegalAddressingMode - Return true if the addressing mode represented
455  /// by AM is legal for this target, for a load/store of the specified type
456  /// Used to guide target specific optimizations, like loop strength
457  /// reduction (LoopStrengthReduce.cpp) and memory optimization for
458  /// address mode (CodeGenPrepare.cpp)
459  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
460  unsigned AS) const override;
461 
462  /// getFunctionAlignment - Return the Log2 alignment of this function.
463  unsigned getFunctionAlignment(const Function *F) const;
464 
466  EVT VT) const override {
467  if (VT.isVector())
468  return EVT::getVectorVT(Ctx, MVT::i1, VT.getVectorNumElements());
469  return MVT::i1;
470  }
471 
472  ConstraintType getConstraintType(StringRef Constraint) const override;
473  std::pair<unsigned, const TargetRegisterClass *>
475  StringRef Constraint, MVT VT) const override;
476 
478  SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
480  SmallVectorImpl<SDValue> &InVals) const override;
481 
482  SDValue LowerCall(CallLoweringInfo &CLI,
483  SmallVectorImpl<SDValue> &InVals) const override;
484 
485  std::string getPrototype(const DataLayout &DL, Type *, const ArgListTy &,
487  unsigned retAlignment,
488  const ImmutableCallSite *CS) const;
489 
490  SDValue
491  LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
493  const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
494  SelectionDAG &DAG) const override;
495 
496  void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
497  std::vector<SDValue> &Ops,
498  SelectionDAG &DAG) const override;
499 
501 
502  // PTX always uses 32-bit shift amounts
503  MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
504  return MVT::i32;
505  }
506 
508  getPreferredVectorAction(EVT VT) const override;
509 
510  bool allowFMA(MachineFunction &MF, CodeGenOpt::Level OptLevel) const;
511 
512  bool isFMAFasterThanFMulAndFAdd(EVT) const override { return true; }
513 
514  bool enableAggressiveFMAFusion(EVT VT) const override { return true; }
515 
516 private:
517  const NVPTXSubtarget &STI; // cache the subtarget here
518 
519  SDValue getExtSymb(SelectionDAG &DAG, const char *name, int idx,
520  EVT = MVT::i32) const;
521  SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT) const;
522  SDValue getParamHelpSymbol(SelectionDAG &DAG, int idx);
523 
524  SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
525 
526  SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
527  SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
528 
529  SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
530  SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
531  SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
532 
533  SDValue LowerShiftRightParts(SDValue Op, SelectionDAG &DAG) const;
534  SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
535 
536  SDValue LowerSelect(SDValue Op, SelectionDAG &DAG) const;
537 
538  void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
539  SelectionDAG &DAG) const override;
540  SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
541 
542  unsigned getArgumentAlignment(SDValue Callee, const ImmutableCallSite *CS,
543  Type *Ty, unsigned Idx) const;
544 };
545 } // namespace llvm
546 
547 #endif
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:724
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:104
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
bool isFMAFasterThanFMulAndFAdd(EVT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Ctx, EVT VT) const override
Return the ValueType of the result of SETCC operations.
CallInst - This class represents a function call, abstracting a target machine's calling convention...
std::string getPrototype(const DataLayout &DL, Type *, const ArgListTy &, const SmallVectorImpl< ISD::OutputArg > &, unsigned retAlignment, const ImmutableCallSite *CS) const
bool enableAggressiveFMAFusion(EVT VT) const override
Return true if target always beneficiates from combining into FMA for a given value type...
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint letter, return the type of constraint it is for this target...
F(f)
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
bool isVector() const
isVector - Return true if this is a vector value type.
Definition: ValueTypes.h:115
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override
EVT is not used in-tree, but is used by out-of-tree target.
unsigned getFunctionAlignment(const Function *F) const
getFunctionAlignment - Return the Log2 alignment of this function.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isTypeSupportedInIntrinsic(MVT VT) const
bool allowFMA(MachineFunction &MF, CodeGenOpt::Level OptLevel) const
MVT - Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:41
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
EVT - Extended Value Type.
Definition: ValueTypes.h:31
std::vector< ArgListEntry > ArgListTy
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements)
getVectorVT - Returns the EVT that represents a vector NumElements in length, where each element is o...
Definition: ValueTypes.h:70
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT) const override
Return the preferred vector type legalization action.
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:179
NVPTXTargetLowering(const NVPTXTargetMachine &TM, const NVPTXSubtarget &STI)
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static const int FIRST_TARGET_MEMORY_OPCODE
FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations which do not reference a specific me...
Definition: ISDOpcodes.h:731
Represents one node in the SelectionDAG.
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, SDLoc dl, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array...
NVPTXTargetMachine.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:418
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
static const char * name
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
This file describes how to lower LLVM code to machine code.
unsigned getVectorNumElements() const
getVectorNumElements - Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:225
const NVPTXTargetMachine * nvTM