1 //===-- AMDGPUISelLowering.h - AMDGPU 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 //===----------------------------------------------------------------------===//
11 /// \brief Interface definition of the TargetLowering class that is common
14 //===----------------------------------------------------------------------===//
16 #ifndef AMDGPUISELLOWERING_H
17 #define AMDGPUISELLOWERING_H
19 #include "llvm/Target/TargetLowering.h"
23 class AMDGPUMachineFunction;
24 class MachineRegisterInfo;
26 class AMDGPUTargetLowering : public TargetLowering {
28 void ExtractVectorElements(SDValue Op, SelectionDAG &DAG,
29 SmallVectorImpl<SDValue> &Args,
30 unsigned Start, unsigned Count) const;
31 SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
32 SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
33 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
34 /// \brief Lower vector stores by merging the vector elements into an integer
35 /// of the same bitwidth.
36 SDValue MergeVectorStore(const SDValue &Op, SelectionDAG &DAG) const;
37 /// \brief Split a vector store into multiple scalar stores.
38 /// \returns The resulting chain.
39 SDValue SplitVectorStore(SDValue Op, SelectionDAG &DAG) const;
40 SDValue LowerUDIVREM(SDValue Op, SelectionDAG &DAG) const;
44 /// \brief Helper function that adds Reg to the LiveIn list of the DAG's
47 /// \returns a RegisterSDNode representing Reg.
48 virtual SDValue CreateLiveInRegister(SelectionDAG &DAG,
49 const TargetRegisterClass *RC,
50 unsigned Reg, EVT VT) const;
51 SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op,
52 SelectionDAG &DAG) const;
53 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
54 bool isHWTrueValue(SDValue Op) const;
55 bool isHWFalseValue(SDValue Op) const;
57 void AnalyzeFormalArguments(CCState &State,
58 const SmallVectorImpl<ISD::InputArg> &Ins) const;
61 AMDGPUTargetLowering(TargetMachine &TM);
63 virtual bool isFAbsFree(EVT VT) const;
64 virtual bool isFNegFree(EVT VT) const;
65 virtual MVT getVectorIdxTy() const;
66 virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv,
68 const SmallVectorImpl<ISD::OutputArg> &Outs,
69 const SmallVectorImpl<SDValue> &OutVals,
70 SDLoc DL, SelectionDAG &DAG) const;
71 virtual SDValue LowerCall(CallLoweringInfo &CLI,
72 SmallVectorImpl<SDValue> &InVals) const {
74 llvm_unreachable("Undefined function");
77 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
78 SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const;
79 SDValue LowerIntrinsicLRP(SDValue Op, SelectionDAG &DAG) const;
80 SDValue LowerMinMax(SDValue Op, SelectionDAG &DAG) const;
81 virtual const char* getTargetNodeName(unsigned Opcode) const;
83 virtual SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const {
87 // Functions defined in AMDILISelLowering.cpp
90 /// \brief Determine which of the bits specified in \p Mask are known to be
91 /// either zero or one and return them in the \p KnownZero and \p KnownOne
93 virtual void computeMaskedBitsForTargetNode(const SDValue Op,
96 const SelectionDAG &DAG,
97 unsigned Depth = 0) const;
99 virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info,
100 const CallInst &I, unsigned Intrinsic) const;
102 /// We want to mark f32/f64 floating point values as legal.
103 bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
105 /// We don't want to shrink f64/f32 constants.
106 bool ShouldShrinkFPConstant(EVT VT) const;
109 void InitAMDILLowering();
110 SDValue LowerSREM(SDValue Op, SelectionDAG &DAG) const;
111 SDValue LowerSREM8(SDValue Op, SelectionDAG &DAG) const;
112 SDValue LowerSREM16(SDValue Op, SelectionDAG &DAG) const;
113 SDValue LowerSREM32(SDValue Op, SelectionDAG &DAG) const;
114 SDValue LowerSREM64(SDValue Op, SelectionDAG &DAG) const;
115 SDValue LowerSDIV(SDValue Op, SelectionDAG &DAG) const;
116 SDValue LowerSDIV24(SDValue Op, SelectionDAG &DAG) const;
117 SDValue LowerSDIV32(SDValue Op, SelectionDAG &DAG) const;
118 SDValue LowerSDIV64(SDValue Op, SelectionDAG &DAG) const;
119 SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
120 EVT genIntType(uint32_t size = 32, uint32_t numEle = 1) const;
121 SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
122 SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
125 namespace AMDGPUISD {
129 FIRST_NUMBER = ISD::BUILTIN_OP_END,
130 CALL, // Function call based on a single integer
131 UMUL, // 32bit unsigned multiplication
132 DIV_INF, // Divide with infinity returned on zero divisor
135 // End AMDIL ISD Opcodes
158 FIRST_MEM_OPCODE_NUMBER = ISD::FIRST_TARGET_MEMORY_OPCODE,
161 LAST_AMDGPU_ISD_NUMBER
165 } // End namespace AMDGPUISD
167 } // End namespace llvm
169 #endif // AMDGPUISELLOWERING_H