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