Fix capitalization. NFC.
[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/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 namespace llvm {
32
33 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
34
35 public:
36   enum Generation {
37     R600 = 0,
38     R700,
39     EVERGREEN,
40     NORTHERN_ISLANDS,
41     SOUTHERN_ISLANDS,
42     SEA_ISLANDS
43   };
44
45 private:
46   std::string DevName;
47   bool Is64bit;
48   bool DumpCode;
49   bool R600ALUInst;
50   bool HasVertexCache;
51   short TexVTXClauseSize;
52   Generation Gen;
53   bool FP64;
54   bool FP64Denormals;
55   bool FP32Denormals;
56   bool CaymanISA;
57   bool FlatAddressSpace;
58   bool EnableIRStructurizer;
59   bool EnablePromoteAlloca;
60   bool EnableIfCvt;
61   bool EnableLoadStoreOpt;
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 override {
77     return &FrameLowering;
78   }
79   const AMDGPUInstrInfo *getInstrInfo() const override {
80     return InstrInfo.get();
81   }
82   const AMDGPURegisterInfo *getRegisterInfo() const override {
83     return &InstrInfo->getRegisterInfo();
84   }
85   AMDGPUTargetLowering *getTargetLowering() const override {
86     return TLInfo.get();
87   }
88   const DataLayout *getDataLayout() const override { return &DL; }
89   const InstrItineraryData *getInstrItineraryData() const override {
90     return &InstrItins;
91   }
92
93   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
94
95   bool is64bit() const {
96     return Is64bit;
97   }
98
99   bool hasVertexCache() const {
100     return HasVertexCache;
101   }
102
103   short getTexVTXClauseSize() const {
104     return TexVTXClauseSize;
105   }
106
107   Generation getGeneration() const {
108     return Gen;
109   }
110
111   bool hasHWFP64() const {
112     return FP64;
113   }
114
115   bool hasCaymanISA() const {
116     return CaymanISA;
117   }
118
119   bool hasFP32Denormals() const {
120     return FP32Denormals;
121   }
122
123   bool hasFP64Denormals() const {
124     return FP64Denormals;
125   }
126
127   bool hasFlatAddressSpace() const {
128     return FlatAddressSpace;
129   }
130
131   bool hasBFE() const {
132     return (getGeneration() >= EVERGREEN);
133   }
134
135   bool hasBFI() const {
136     return (getGeneration() >= EVERGREEN);
137   }
138
139   bool hasBFM() const {
140     return hasBFE();
141   }
142
143   bool hasBCNT(unsigned Size) const {
144     if (Size == 32)
145       return (getGeneration() >= EVERGREEN);
146
147     if (Size == 64)
148       return (getGeneration() >= SOUTHERN_ISLANDS);
149
150     return false;
151   }
152
153   bool hasMulU24() const {
154     return (getGeneration() >= EVERGREEN);
155   }
156
157   bool hasMulI24() const {
158     return (getGeneration() >= SOUTHERN_ISLANDS ||
159             hasCaymanISA());
160   }
161
162   bool hasFFBL() const {
163     return (getGeneration() >= EVERGREEN);
164   }
165
166   bool hasFFBH() const {
167     return (getGeneration() >= EVERGREEN);
168   }
169
170   bool IsIRStructurizerEnabled() const {
171     return EnableIRStructurizer;
172   }
173
174   bool isPromoteAllocaEnabled() const {
175     return EnablePromoteAlloca;
176   }
177
178   bool isIfCvtEnabled() const {
179     return EnableIfCvt;
180   }
181
182   bool loadStoreOptEnabled() const {
183     return EnableLoadStoreOpt;
184   }
185
186   unsigned getWavefrontSize() const {
187     return WavefrontSize;
188   }
189
190   unsigned getStackEntrySize() const;
191
192   bool hasCFAluBug() const {
193     assert(getGeneration() <= NORTHERN_ISLANDS);
194     return CFALUBug;
195   }
196
197   int getLocalMemorySize() const {
198     return LocalMemorySize;
199   }
200
201   bool enableMachineScheduler() const override {
202     return getGeneration() <= NORTHERN_ISLANDS;
203   }
204
205   // Helper functions to simplify if statements
206   bool isTargetELF() const {
207     return false;
208   }
209
210   StringRef getDeviceName() const {
211     return DevName;
212   }
213
214   bool dumpCode() const {
215     return DumpCode;
216   }
217   bool r600ALUEncoding() const {
218     return R600ALUInst;
219   }
220 };
221
222 } // End namespace llvm
223
224 #endif