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