R600: Move DataLayout to AMDGPUTargetMachine
[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 LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_R600_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/ADT/StringExtras.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Target/TargetSubtargetInfo.h"
26
27 #define GET_SUBTARGETINFO_HEADER
28 #include "AMDGPUGenSubtargetInfo.inc"
29
30 namespace llvm {
31
32 class SIMachineFunctionInfo;
33
34 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
35
36 public:
37   enum Generation {
38     R600 = 0,
39     R700,
40     EVERGREEN,
41     NORTHERN_ISLANDS,
42     SOUTHERN_ISLANDS,
43     SEA_ISLANDS,
44     VOLCANIC_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 FlatAddressSpace;
60   bool EnableIRStructurizer;
61   bool EnablePromoteAlloca;
62   bool EnableIfCvt;
63   bool EnableLoadStoreOpt;
64   unsigned WavefrontSize;
65   bool CFALUBug;
66   int LocalMemorySize;
67   bool EnableVGPRSpilling;
68
69   AMDGPUFrameLowering FrameLowering;
70   std::unique_ptr<AMDGPUTargetLowering> TLInfo;
71   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
72   InstrItineraryData InstrItins;
73   Triple TargetTriple;
74
75 public:
76   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
77   AMDGPUSubtarget &initializeSubtargetDependencies(StringRef TT, StringRef GPU,
78                                                    StringRef FS);
79
80   const AMDGPUFrameLowering *getFrameLowering() const override {
81     return &FrameLowering;
82   }
83   const AMDGPUInstrInfo *getInstrInfo() const override {
84     return InstrInfo.get();
85   }
86   const AMDGPURegisterInfo *getRegisterInfo() const override {
87     return &InstrInfo->getRegisterInfo();
88   }
89   AMDGPUTargetLowering *getTargetLowering() const override {
90     return TLInfo.get();
91   }
92   const InstrItineraryData *getInstrItineraryData() const override {
93     return &InstrItins;
94   }
95
96   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
97
98   bool is64bit() const {
99     return Is64bit;
100   }
101
102   bool hasVertexCache() const {
103     return HasVertexCache;
104   }
105
106   short getTexVTXClauseSize() const {
107     return TexVTXClauseSize;
108   }
109
110   Generation getGeneration() const {
111     return Gen;
112   }
113
114   bool hasHWFP64() const {
115     return FP64;
116   }
117
118   bool hasCaymanISA() const {
119     return CaymanISA;
120   }
121
122   bool hasFP32Denormals() const {
123     return FP32Denormals;
124   }
125
126   bool hasFP64Denormals() const {
127     return FP64Denormals;
128   }
129
130   bool hasFlatAddressSpace() const {
131     return FlatAddressSpace;
132   }
133
134   bool hasBFE() const {
135     return (getGeneration() >= EVERGREEN);
136   }
137
138   bool hasBFI() const {
139     return (getGeneration() >= EVERGREEN);
140   }
141
142   bool hasBFM() const {
143     return hasBFE();
144   }
145
146   bool hasBCNT(unsigned Size) const {
147     if (Size == 32)
148       return (getGeneration() >= EVERGREEN);
149
150     if (Size == 64)
151       return (getGeneration() >= SOUTHERN_ISLANDS);
152
153     return false;
154   }
155
156   bool hasMulU24() const {
157     return (getGeneration() >= EVERGREEN);
158   }
159
160   bool hasMulI24() const {
161     return (getGeneration() >= SOUTHERN_ISLANDS ||
162             hasCaymanISA());
163   }
164
165   bool hasFFBL() const {
166     return (getGeneration() >= EVERGREEN);
167   }
168
169   bool hasFFBH() const {
170     return (getGeneration() >= EVERGREEN);
171   }
172
173   bool IsIRStructurizerEnabled() const {
174     return EnableIRStructurizer;
175   }
176
177   bool isPromoteAllocaEnabled() const {
178     return EnablePromoteAlloca;
179   }
180
181   bool isIfCvtEnabled() const {
182     return EnableIfCvt;
183   }
184
185   bool loadStoreOptEnabled() const {
186     return EnableLoadStoreOpt;
187   }
188
189   unsigned getWavefrontSize() const {
190     return WavefrontSize;
191   }
192
193   unsigned getStackEntrySize() const;
194
195   bool hasCFAluBug() const {
196     assert(getGeneration() <= NORTHERN_ISLANDS);
197     return CFALUBug;
198   }
199
200   int getLocalMemorySize() const {
201     return LocalMemorySize;
202   }
203
204   unsigned getAmdKernelCodeChipID() const;
205
206   bool enableMachineScheduler() const override {
207     return getGeneration() <= NORTHERN_ISLANDS;
208   }
209
210   // Helper functions to simplify if statements
211   bool isTargetELF() const {
212     return false;
213   }
214
215   StringRef getDeviceName() const {
216     return DevName;
217   }
218
219   bool dumpCode() const {
220     return DumpCode;
221   }
222   bool r600ALUEncoding() const {
223     return R600ALUInst;
224   }
225   bool isAmdHsaOS() const {
226     return TargetTriple.getOS() == Triple::AMDHSA;
227   }
228   bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
229 };
230
231 } // End namespace llvm
232
233 #endif