Canonicalize header guards into a common format.
[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 #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 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 hasBFE() const {
128     return (getGeneration() >= EVERGREEN);
129   }
130
131   bool hasBFI() const {
132     return (getGeneration() >= EVERGREEN);
133   }
134
135   bool hasBFM() const {
136     return hasBFE();
137   }
138
139   bool hasBCNT(unsigned Size) const {
140     if (Size == 32)
141       return (getGeneration() >= EVERGREEN);
142
143     if (Size == 64)
144       return (getGeneration() >= SOUTHERN_ISLANDS);
145
146     return false;
147   }
148
149   bool hasMulU24() const {
150     return (getGeneration() >= EVERGREEN);
151   }
152
153   bool hasMulI24() const {
154     return (getGeneration() >= SOUTHERN_ISLANDS ||
155             hasCaymanISA());
156   }
157
158   bool hasFFBL() const {
159     return (getGeneration() >= EVERGREEN);
160   }
161
162   bool hasFFBH() const {
163     return (getGeneration() >= EVERGREEN);
164   }
165
166   bool IsIRStructurizerEnabled() const {
167     return EnableIRStructurizer;
168   }
169
170   bool isPromoteAllocaEnabled() const {
171     return EnablePromoteAlloca;
172   }
173
174   bool isIfCvtEnabled() const {
175     return EnableIfCvt;
176   }
177
178   unsigned getWavefrontSize() const {
179     return WavefrontSize;
180   }
181
182   unsigned getStackEntrySize() const;
183
184   bool hasCFAluBug() const {
185     assert(getGeneration() <= NORTHERN_ISLANDS);
186     return CFALUBug;
187   }
188
189   int getLocalMemorySize() const {
190     return LocalMemorySize;
191   }
192
193   bool enableMachineScheduler() const override {
194     return getGeneration() <= NORTHERN_ISLANDS;
195   }
196
197   // Helper functions to simplify if statements
198   bool isTargetELF() const {
199     return false;
200   }
201
202   StringRef getDeviceName() const {
203     return DevName;
204   }
205
206   bool dumpCode() const {
207     return DumpCode;
208   }
209   bool r600ALUEncoding() const {
210     return R600ALUInst;
211   }
212 };
213
214 } // End namespace llvm
215
216 #endif