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