R600: Add option to disable promote alloca
[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 CaymanISA;
54   bool EnableIRStructurizer;
55   bool EnablePromoteAlloca;
56   bool EnableIfCvt;
57   unsigned WavefrontSize;
58   bool CFALUBug;
59   int LocalMemorySize;
60
61   InstrItineraryData InstrItins;
62
63 public:
64   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
65
66   const AMDGPUInstrInfo *getInstrInfo() const {
67     return InstrInfo.get();
68   }
69
70   const InstrItineraryData &getInstrItineraryData() const {
71     return InstrItins;
72   }
73
74   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
75
76   bool is64bit() const {
77     return Is64bit;
78   }
79
80   bool hasVertexCache() const {
81     return HasVertexCache;
82   }
83
84   short getTexVTXClauseSize() const {
85     return TexVTXClauseSize;
86   }
87
88   Generation getGeneration() const {
89     return Gen;
90   }
91
92   bool hasHWFP64() const {
93     return FP64;
94   }
95
96   bool hasCaymanISA() const {
97     return CaymanISA;
98   }
99
100   bool hasBFE() const {
101     return (getGeneration() >= EVERGREEN);
102   }
103
104   bool hasBFI() const {
105     return (getGeneration() >= EVERGREEN);
106   }
107
108   bool hasBFM() const {
109     return hasBFE();
110   }
111
112   bool hasBCNT(unsigned Size) const {
113     if (Size == 32)
114       return (getGeneration() >= EVERGREEN);
115
116     assert(Size == 64);
117     return (getGeneration() >= SOUTHERN_ISLANDS);
118   }
119
120   bool hasMulU24() const {
121     return (getGeneration() >= EVERGREEN);
122   }
123
124   bool hasMulI24() const {
125     return (getGeneration() >= SOUTHERN_ISLANDS ||
126             hasCaymanISA());
127   }
128
129   bool IsIRStructurizerEnabled() const {
130     return EnableIRStructurizer;
131   }
132
133   bool isPromoteAllocaEnabled() const {
134     return EnablePromoteAlloca;
135   }
136
137   bool isIfCvtEnabled() const {
138     return EnableIfCvt;
139   }
140
141   unsigned getWavefrontSize() const {
142     return WavefrontSize;
143   }
144
145   unsigned getStackEntrySize() const;
146
147   bool hasCFAluBug() const {
148     assert(getGeneration() <= NORTHERN_ISLANDS);
149     return CFALUBug;
150   }
151
152   int getLocalMemorySize() const {
153     return LocalMemorySize;
154   }
155
156   bool enableMachineScheduler() const override {
157     return getGeneration() <= NORTHERN_ISLANDS;
158   }
159
160   // Helper functions to simplify if statements
161   bool isTargetELF() const {
162     return false;
163   }
164
165   StringRef getDeviceName() const {
166     return DevName;
167   }
168
169   bool dumpCode() const {
170     return DumpCode;
171   }
172   bool r600ALUEncoding() const {
173     return R600ALUInst;
174   }
175 };
176
177 } // End namespace llvm
178
179 #endif // AMDGPUSUBTARGET_H