R600/SI: expose TBUFFER_STORE_FORMAT_* for OpenGL transform feedback
[oota-llvm.git] / lib / Target / R600 / AMDGPUISelLowering.h
1 //===-- AMDGPUISelLowering.h - AMDGPU 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 /// \file
11 /// \brief Interface definition of the TargetLowering class that is common
12 /// to all AMD GPUs.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef AMDGPUISELLOWERING_H
17 #define AMDGPUISELLOWERING_H
18
19 #include "llvm/Target/TargetLowering.h"
20
21 namespace llvm {
22
23 class AMDGPUMachineFunction;
24 class MachineRegisterInfo;
25
26 class AMDGPUTargetLowering : public TargetLowering {
27 private:
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;
41
42 protected:
43
44   /// \brief Helper function that adds Reg to the LiveIn list of the DAG's
45   /// MachineFunction.
46   ///
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   /// \brief Split a vector load into multiple scalar loads.
54   SDValue SplitVectorLoad(const SDValue &Op, SelectionDAG &DAG) const;
55   SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
56   bool isHWTrueValue(SDValue Op) const;
57   bool isHWFalseValue(SDValue Op) const;
58
59   void AnalyzeFormalArguments(CCState &State,
60                               const SmallVectorImpl<ISD::InputArg> &Ins) const;
61
62 public:
63   AMDGPUTargetLowering(TargetMachine &TM);
64
65   virtual bool isFAbsFree(EVT VT) const;
66   virtual bool isFNegFree(EVT VT) const;
67   virtual MVT getVectorIdxTy() const;
68   virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv,
69                               bool isVarArg,
70                               const SmallVectorImpl<ISD::OutputArg> &Outs,
71                               const SmallVectorImpl<SDValue> &OutVals,
72                               SDLoc DL, SelectionDAG &DAG) const;
73   virtual SDValue LowerCall(CallLoweringInfo &CLI,
74                             SmallVectorImpl<SDValue> &InVals) const {
75     CLI.Callee.dump();
76     llvm_unreachable("Undefined function");
77   }
78
79   virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
80   SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const;
81   SDValue LowerIntrinsicLRP(SDValue Op, SelectionDAG &DAG) const;
82   SDValue LowerMinMax(SDValue Op, SelectionDAG &DAG) const;
83   virtual const char* getTargetNodeName(unsigned Opcode) const;
84
85   virtual SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const {
86     return N;
87   }
88
89 // Functions defined in AMDILISelLowering.cpp
90 public:
91
92   /// \brief Determine which of the bits specified in \p Mask are known to be
93   /// either zero or one and return them in the \p KnownZero and \p KnownOne
94   /// bitsets.
95   virtual void computeMaskedBitsForTargetNode(const SDValue Op,
96                                               APInt &KnownZero,
97                                               APInt &KnownOne,
98                                               const SelectionDAG &DAG,
99                                               unsigned Depth = 0) const;
100
101   virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info,
102                                   const CallInst &I, unsigned Intrinsic) const;
103
104   /// We want to mark f32/f64 floating point values as legal.
105   bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
106
107   /// We don't want to shrink f64/f32 constants.
108   bool ShouldShrinkFPConstant(EVT VT) const;
109
110 private:
111   void InitAMDILLowering();
112   SDValue LowerSREM(SDValue Op, SelectionDAG &DAG) const;
113   SDValue LowerSREM8(SDValue Op, SelectionDAG &DAG) const;
114   SDValue LowerSREM16(SDValue Op, SelectionDAG &DAG) const;
115   SDValue LowerSREM32(SDValue Op, SelectionDAG &DAG) const;
116   SDValue LowerSREM64(SDValue Op, SelectionDAG &DAG) const;
117   SDValue LowerSDIV(SDValue Op, SelectionDAG &DAG) const;
118   SDValue LowerSDIV24(SDValue Op, SelectionDAG &DAG) const;
119   SDValue LowerSDIV32(SDValue Op, SelectionDAG &DAG) const;
120   SDValue LowerSDIV64(SDValue Op, SelectionDAG &DAG) const;
121   SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
122   EVT genIntType(uint32_t size = 32, uint32_t numEle = 1) const;
123   SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
124   SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const;
125 };
126
127 namespace AMDGPUISD {
128
129 enum {
130   // AMDIL ISD Opcodes
131   FIRST_NUMBER = ISD::BUILTIN_OP_END,
132   CALL,        // Function call based on a single integer
133   UMUL,        // 32bit unsigned multiplication
134   DIV_INF,      // Divide with infinity returned on zero divisor
135   RET_FLAG,
136   BRANCH_COND,
137   // End AMDIL ISD Opcodes
138   DWORDADDR,
139   FRACT,
140   COS_HW,
141   SIN_HW,
142   FMAX,
143   SMAX,
144   UMAX,
145   FMIN,
146   SMIN,
147   UMIN,
148   URECIP,
149   DOT4,
150   TEXTURE_FETCH,
151   EXPORT,
152   CONST_ADDRESS,
153   REGISTER_LOAD,
154   REGISTER_STORE,
155   LOAD_INPUT,
156   SAMPLE,
157   SAMPLEB,
158   SAMPLED,
159   SAMPLEL,
160   FIRST_MEM_OPCODE_NUMBER = ISD::FIRST_TARGET_MEMORY_OPCODE,
161   STORE_MSKOR,
162   LOAD_CONSTANT,
163   TBUFFER_STORE_FORMAT,
164   LAST_AMDGPU_ISD_NUMBER
165 };
166
167
168 } // End namespace AMDGPUISD
169
170 } // End namespace llvm
171
172 #endif // AMDGPUISELLOWERING_H