[X86][SSE] Vector integer/float conversion memory folding
[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   bool EnableLoadStoreOpt;
64   unsigned WavefrontSize;
65   bool CFALUBug;
66   int LocalMemorySize;
67
68   const DataLayout DL;
69   AMDGPUFrameLowering FrameLowering;
70   std::unique_ptr<AMDGPUTargetLowering> TLInfo;
71   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
72   InstrItineraryData InstrItins;
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   bool enableMachineScheduler() const override {
204     return getGeneration() <= NORTHERN_ISLANDS;
205   }
206
207   // Helper functions to simplify if statements
208   bool isTargetELF() const {
209     return false;
210   }
211
212   StringRef getDeviceName() const {
213     return DevName;
214   }
215
216   bool dumpCode() const {
217     return DumpCode;
218   }
219   bool r600ALUEncoding() const {
220     return R600ALUInst;
221   }
222 };
223
224 } // End namespace llvm
225
226 #endif