R600: Trivial subtarget feature cleanups.
[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   enum Generation Gen;
52   bool FP64;
53   bool CaymanISA;
54   bool EnableIRStructurizer;
55   bool EnableIfCvt;
56   unsigned WavefrontSize;
57   bool CFALUBug;
58   int LocalMemorySize;
59
60   InstrItineraryData InstrItins;
61
62 public:
63   AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
64
65   const AMDGPUInstrInfo *getInstrInfo() const {
66     return InstrInfo.get();
67   }
68   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
69   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
70
71   bool is64bit() const;
72   bool hasVertexCache() const;
73   short getTexVTXClauseSize() const;
74   enum Generation getGeneration() const;
75   bool hasHWFP64() const;
76   bool hasCaymanISA() const;
77
78   bool hasBFE() const {
79     return (getGeneration() >= EVERGREEN);
80   }
81
82   bool hasBFI() const {
83     return (getGeneration() >= EVERGREEN);
84   }
85
86   bool hasBFM() const {
87     return hasBFE();
88   }
89
90   bool hasBCNT(unsigned Size) const {
91     if (Size == 32)
92       return (getGeneration() >= EVERGREEN);
93
94     assert(Size == 64);
95     return (getGeneration() >= SOUTHERN_ISLANDS);
96   }
97
98   bool hasMulU24() const {
99     return (getGeneration() >= EVERGREEN);
100   }
101
102   bool hasMulI24() const {
103     return (getGeneration() >= SOUTHERN_ISLANDS ||
104             hasCaymanISA());
105   }
106
107   bool IsIRStructurizerEnabled() const;
108   bool isIfCvtEnabled() const;
109   unsigned getWavefrontSize() const;
110   unsigned getStackEntrySize() const;
111   bool hasCFAluBug() const;
112   int getLocalMemorySize() const;
113
114   bool enableMachineScheduler() const override {
115     return getGeneration() <= NORTHERN_ISLANDS;
116   }
117
118   // Helper functions to simplify if statements
119   bool isTargetELF() const;
120   std::string getDeviceName() const;
121   bool dumpCode() const { return DumpCode; }
122   bool r600ALUEncoding() const { return R600ALUInst; }
123
124 };
125
126 } // End namespace llvm
127
128 #endif // AMDGPUSUBTARGET_H