Move the R600 intrinsic support back to the target machine - there's
[oota-llvm.git] / lib / Target / R600 / AMDGPUSubtarget.h
1 //=====-- AMDGPUSubtarget.h - Define Subtarget for the AMDIL ---*- 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 AMDGPU specific subclass of TargetSubtarget.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef AMDGPUSUBTARGET_H
16 #define AMDGPUSUBTARGET_H
17 #include "AMDGPU.h"
18 #include "AMDGPUFrameLowering.h"
19 #include "AMDGPUInstrInfo.h"
20 #include "AMDGPUIntrinsicInfo.h"
21 #include "AMDGPUSubtarget.h"
22 #include "R600ISelLowering.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/ADT/StringRef.h"
26 #include "llvm/Target/TargetSubtargetInfo.h"
27
28 #define GET_SUBTARGETINFO_HEADER
29 #include "AMDGPUGenSubtargetInfo.inc"
30
31 #define MAX_CB_SIZE (1 << 16)
32
33 namespace llvm {
34
35 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
36
37 public:
38   enum Generation {
39     R600 = 0,
40     R700,
41     EVERGREEN,
42     NORTHERN_ISLANDS,
43     SOUTHERN_ISLANDS,
44     SEA_ISLANDS
45   };
46
47 private:
48   std::string DevName;
49   bool Is64bit;
50   bool DumpCode;
51   bool R600ALUInst;
52   bool HasVertexCache;
53   short TexVTXClauseSize;
54   Generation Gen;
55   bool FP64;
56   bool FP64Denormals;
57   bool FP32Denormals;
58   bool CaymanISA;
59   bool EnableIRStructurizer;
60   bool EnablePromoteAlloca;
61   bool EnableIfCvt;
62   unsigned WavefrontSize;
63   bool CFALUBug;
64   int LocalMemorySize;
65
66   const DataLayout DL;
67   AMDGPUFrameLowering FrameLowering;
68   std::unique_ptr<AMDGPUTargetLowering> TLInfo;
69   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
70   InstrItineraryData InstrItins;
71
72 public:
73   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
74   AMDGPUSubtarget &initializeSubtargetDependencies(StringRef GPU, StringRef FS);
75
76   const AMDGPUFrameLowering *getFrameLowering() const { return &FrameLowering; }
77   const AMDGPUInstrInfo *getInstrInfo() const { return InstrInfo.get(); }
78   const AMDGPURegisterInfo *getRegisterInfo() const {
79     return &InstrInfo->getRegisterInfo();
80   }
81   AMDGPUTargetLowering *getTargetLowering() const { return TLInfo.get(); }
82   const DataLayout *getDataLayout() const { return &DL; }
83   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
84
85   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
86
87   bool is64bit() const {
88     return Is64bit;
89   }
90
91   bool hasVertexCache() const {
92     return HasVertexCache;
93   }
94
95   short getTexVTXClauseSize() const {
96     return TexVTXClauseSize;
97   }
98
99   Generation getGeneration() const {
100     return Gen;
101   }
102
103   bool hasHWFP64() const {
104     return FP64;
105   }
106
107   bool hasCaymanISA() const {
108     return CaymanISA;
109   }
110
111   bool hasFP32Denormals() const {
112     return FP32Denormals;
113   }
114
115   bool hasFP64Denormals() const {
116     return FP64Denormals;
117   }
118
119   bool hasBFE() const {
120     return (getGeneration() >= EVERGREEN);
121   }
122
123   bool hasBFI() const {
124     return (getGeneration() >= EVERGREEN);
125   }
126
127   bool hasBFM() const {
128     return hasBFE();
129   }
130
131   bool hasBCNT(unsigned Size) const {
132     if (Size == 32)
133       return (getGeneration() >= EVERGREEN);
134
135     if (Size == 64)
136       return (getGeneration() >= SOUTHERN_ISLANDS);
137
138     return false;
139   }
140
141   bool hasMulU24() const {
142     return (getGeneration() >= EVERGREEN);
143   }
144
145   bool hasMulI24() const {
146     return (getGeneration() >= SOUTHERN_ISLANDS ||
147             hasCaymanISA());
148   }
149
150   bool hasFFBL() const {
151     return (getGeneration() >= EVERGREEN);
152   }
153
154   bool hasFFBH() const {
155     return (getGeneration() >= EVERGREEN);
156   }
157
158   bool IsIRStructurizerEnabled() const {
159     return EnableIRStructurizer;
160   }
161
162   bool isPromoteAllocaEnabled() const {
163     return EnablePromoteAlloca;
164   }
165
166   bool isIfCvtEnabled() const {
167     return EnableIfCvt;
168   }
169
170   unsigned getWavefrontSize() const {
171     return WavefrontSize;
172   }
173
174   unsigned getStackEntrySize() const;
175
176   bool hasCFAluBug() const {
177     assert(getGeneration() <= NORTHERN_ISLANDS);
178     return CFALUBug;
179   }
180
181   int getLocalMemorySize() const {
182     return LocalMemorySize;
183   }
184
185   bool enableMachineScheduler() const override {
186     return getGeneration() <= NORTHERN_ISLANDS;
187   }
188
189   // Helper functions to simplify if statements
190   bool isTargetELF() const {
191     return false;
192   }
193
194   StringRef getDeviceName() const {
195     return DevName;
196   }
197
198   bool dumpCode() const {
199     return DumpCode;
200   }
201   bool r600ALUEncoding() const {
202     return R600ALUInst;
203   }
204 };
205
206 } // End namespace llvm
207
208 #endif // AMDGPUSUBTARGET_H