R600: Implement zero undef variants of ctlz/cttz
[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 "AMDGPUInstrInfo.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Target/TargetSubtargetInfo.h"
22
23 #define GET_SUBTARGETINFO_HEADER
24 #include "AMDGPUGenSubtargetInfo.inc"
25
26 #define MAX_CB_SIZE (1 << 16)
27
28 namespace llvm {
29
30 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
31
32   std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
33
34 public:
35   enum Generation {
36     R600 = 0,
37     R700,
38     EVERGREEN,
39     NORTHERN_ISLANDS,
40     SOUTHERN_ISLANDS,
41     SEA_ISLANDS
42   };
43
44 private:
45   std::string DevName;
46   bool Is64bit;
47   bool DumpCode;
48   bool R600ALUInst;
49   bool HasVertexCache;
50   short TexVTXClauseSize;
51   Generation Gen;
52   bool FP64;
53   bool FP64Denormals;
54   bool FP32Denormals;
55   bool CaymanISA;
56   bool EnableIRStructurizer;
57   bool EnablePromoteAlloca;
58   bool EnableIfCvt;
59   unsigned WavefrontSize;
60   bool CFALUBug;
61   int LocalMemorySize;
62
63   InstrItineraryData InstrItins;
64
65 public:
66   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
67
68   const AMDGPUInstrInfo *getInstrInfo() const {
69     return InstrInfo.get();
70   }
71
72   const InstrItineraryData &getInstrItineraryData() const {
73     return InstrItins;
74   }
75
76   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
77
78   bool is64bit() const {
79     return Is64bit;
80   }
81
82   bool hasVertexCache() const {
83     return HasVertexCache;
84   }
85
86   short getTexVTXClauseSize() const {
87     return TexVTXClauseSize;
88   }
89
90   Generation getGeneration() const {
91     return Gen;
92   }
93
94   bool hasHWFP64() const {
95     return FP64;
96   }
97
98   bool hasCaymanISA() const {
99     return CaymanISA;
100   }
101
102   bool hasFP32Denormals() const {
103     return FP32Denormals;
104   }
105
106   bool hasFP64Denormals() const {
107     return FP64Denormals;
108   }
109
110   bool hasBFE() const {
111     return (getGeneration() >= EVERGREEN);
112   }
113
114   bool hasBFI() const {
115     return (getGeneration() >= EVERGREEN);
116   }
117
118   bool hasBFM() const {
119     return hasBFE();
120   }
121
122   bool hasBCNT(unsigned Size) const {
123     if (Size == 32)
124       return (getGeneration() >= EVERGREEN);
125
126     assert(Size == 64);
127     return (getGeneration() >= SOUTHERN_ISLANDS);
128   }
129
130   bool hasMulU24() const {
131     return (getGeneration() >= EVERGREEN);
132   }
133
134   bool hasMulI24() const {
135     return (getGeneration() >= SOUTHERN_ISLANDS ||
136             hasCaymanISA());
137   }
138
139   bool hasFFBL() const {
140     return (getGeneration() >= EVERGREEN);
141   }
142
143   bool hasFFBH() const {
144     return (getGeneration() >= EVERGREEN);
145   }
146
147   bool IsIRStructurizerEnabled() const {
148     return EnableIRStructurizer;
149   }
150
151   bool isPromoteAllocaEnabled() const {
152     return EnablePromoteAlloca;
153   }
154
155   bool isIfCvtEnabled() const {
156     return EnableIfCvt;
157   }
158
159   unsigned getWavefrontSize() const {
160     return WavefrontSize;
161   }
162
163   unsigned getStackEntrySize() const;
164
165   bool hasCFAluBug() const {
166     assert(getGeneration() <= NORTHERN_ISLANDS);
167     return CFALUBug;
168   }
169
170   int getLocalMemorySize() const {
171     return LocalMemorySize;
172   }
173
174   bool enableMachineScheduler() const override {
175     return getGeneration() <= NORTHERN_ISLANDS;
176   }
177
178   // Helper functions to simplify if statements
179   bool isTargetELF() const {
180     return false;
181   }
182
183   StringRef getDeviceName() const {
184     return DevName;
185   }
186
187   bool dumpCode() const {
188     return DumpCode;
189   }
190   bool r600ALUEncoding() const {
191     return R600ALUInst;
192   }
193 };
194
195 } // End namespace llvm
196
197 #endif // AMDGPUSUBTARGET_H