R600: Move AMDGPUInstrInfo from AMDGPUTargetMachine into AMDGPUSubtarget
[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 Is32on64bit;
48   bool DumpCode;
49   bool R600ALUInst;
50   bool HasVertexCache;
51   short TexVTXClauseSize;
52   enum Generation Gen;
53   bool FP64;
54   bool CaymanISA;
55   bool EnableIRStructurizer;
56   bool EnableIfCvt;
57   unsigned WavefrontSize;
58   bool CFALUBug;
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
113   bool enableMachineScheduler() const override {
114     return getGeneration() <= NORTHERN_ISLANDS;
115   }
116
117   // Helper functions to simplify if statements
118   bool isTargetELF() const;
119   std::string getDeviceName() const;
120   bool dumpCode() const { return DumpCode; }
121   bool r600ALUEncoding() const { return R600ALUInst; }
122
123 };
124
125 } // End namespace llvm
126
127 #endif // AMDGPUSUBTARGET_H