R600: Use LDS and vectors for private memory
[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   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   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
70   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
71
72   bool is64bit() const;
73   bool hasVertexCache() const;
74   short getTexVTXClauseSize() const;
75   enum Generation getGeneration() const;
76   bool hasHWFP64() const;
77   bool hasCaymanISA() const;
78
79   bool hasBFE() const {
80     return (getGeneration() >= EVERGREEN);
81   }
82
83   bool hasBFI() const {
84     return (getGeneration() >= EVERGREEN);
85   }
86
87   bool hasBFM() const {
88     return hasBFE();
89   }
90
91   bool hasBCNT(unsigned Size) const {
92     if (Size == 32)
93       return (getGeneration() >= EVERGREEN);
94
95     assert(Size == 64);
96     return (getGeneration() >= SOUTHERN_ISLANDS);
97   }
98
99   bool hasMulU24() const {
100     return (getGeneration() >= EVERGREEN);
101   }
102
103   bool hasMulI24() const {
104     return (getGeneration() >= SOUTHERN_ISLANDS ||
105             hasCaymanISA());
106   }
107
108   bool IsIRStructurizerEnabled() const;
109   bool isIfCvtEnabled() const;
110   unsigned getWavefrontSize() const;
111   unsigned getStackEntrySize() const;
112   bool hasCFAluBug() const;
113   int getLocalMemorySize() const;
114
115   bool enableMachineScheduler() const override {
116     return getGeneration() <= NORTHERN_ISLANDS;
117   }
118
119   // Helper functions to simplify if statements
120   bool isTargetELF() const;
121   std::string getDeviceName() const;
122   bool dumpCode() const { return DumpCode; }
123   bool r600ALUEncoding() const { return R600ALUInst; }
124
125 };
126
127 } // End namespace llvm
128
129 #endif // AMDGPUSUBTARGET_H