Make helper functions/classes/globals static. NFC.
[oota-llvm.git] / lib / Target / R600 / SIRegisterInfo.h
1 //===-- SIRegisterInfo.h - SI Register Info Interface ----------*- 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 Interface definition for SIRegisterInfo
12 //
13 //===----------------------------------------------------------------------===//
14
15
16 #ifndef LLVM_LIB_TARGET_R600_SIREGISTERINFO_H
17 #define LLVM_LIB_TARGET_R600_SIREGISTERINFO_H
18
19 #include "AMDGPURegisterInfo.h"
20 #include "llvm/Support/Debug.h"
21
22 namespace llvm {
23
24 struct SIRegisterInfo : public AMDGPURegisterInfo {
25
26   SIRegisterInfo(const AMDGPUSubtarget &st);
27
28   BitVector getReservedRegs(const MachineFunction &MF) const override;
29
30   unsigned getRegPressureSetLimit(unsigned Idx) const override;
31
32   bool requiresRegisterScavenging(const MachineFunction &Fn) const override;
33
34   void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj,
35                            unsigned FIOperandNum,
36                            RegScavenger *RS) const override;
37
38   /// \brief get the register class of the specified type to use in the
39   /// CFGStructurizer
40   const TargetRegisterClass * getCFGStructurizerRegClass(MVT VT) const override;
41
42   unsigned getHWRegIndex(unsigned Reg) const override;
43
44   /// \brief Return the 'base' register class for this register.
45   /// e.g. SGPR0 => SReg_32, VGPR => VGPR_32 SGPR0_SGPR1 -> SReg_32, etc.
46   const TargetRegisterClass *getPhysRegClass(unsigned Reg) const;
47
48   /// \returns true if this class contains only SGPR registers
49   bool isSGPRClass(const TargetRegisterClass *RC) const {
50     if (!RC)
51       return false;
52
53     return !hasVGPRs(RC);
54   }
55
56   /// \returns true if this class ID contains only SGPR registers
57   bool isSGPRClassID(unsigned RCID) const {
58     if (static_cast<int>(RCID) == -1)
59       return false;
60
61     return isSGPRClass(getRegClass(RCID));
62   }
63
64   /// \returns true if this class contains VGPR registers.
65   bool hasVGPRs(const TargetRegisterClass *RC) const;
66
67   /// \returns A VGPR reg class with the same width as \p SRC
68   const TargetRegisterClass *getEquivalentVGPRClass(
69                                           const TargetRegisterClass *SRC) const;
70
71   /// \returns The register class that is used for a sub-register of \p RC for
72   /// the given \p SubIdx.  If \p SubIdx equals NoSubRegister, \p RC will
73   /// be returned.
74   const TargetRegisterClass *getSubRegClass(const TargetRegisterClass *RC,
75                                             unsigned SubIdx) const;
76
77   /// \p Channel This is the register channel (e.g. a value from 0-16), not the
78   ///            SubReg index.
79   /// \returns The sub-register of Reg that is in Channel.
80   unsigned getPhysRegSubReg(unsigned Reg, const TargetRegisterClass *SubRC,
81                             unsigned Channel) const;
82
83   /// \returns True if operands defined with this operand type can accept
84   /// a literal constant (i.e. any 32-bit immediate).
85   bool opCanUseLiteralConstant(unsigned OpType) const;
86
87   /// \returns True if operands defined with this operand type can accept
88   /// an inline constant. i.e. An integer value in the range (-16, 64) or
89   /// -4.0f, -2.0f, -1.0f, -0.5f, 0.0f, 0.5f, 1.0f, 2.0f, 4.0f. 
90   bool opCanUseInlineConstant(unsigned OpType) const;
91
92   enum PreloadedValue {
93     TGID_X,
94     TGID_Y,
95     TGID_Z,
96     SCRATCH_WAVE_OFFSET,
97     SCRATCH_PTR,
98     INPUT_PTR,
99     TIDIG_X,
100     TIDIG_Y,
101     TIDIG_Z
102   };
103
104   /// \brief Returns the physical register that \p Value is stored in.
105   unsigned getPreloadedValue(const MachineFunction &MF,
106                              enum PreloadedValue Value) const;
107
108   /// \brief Give the maximum number of VGPRs that can be used by \p WaveCount
109   ///        concurrent waves.
110   unsigned getNumVGPRsAllowed(unsigned WaveCount) const;
111
112   /// \brief Give the maximum number of SGPRs that can be used by \p WaveCount
113   ///        concurrent waves.
114   unsigned getNumSGPRsAllowed(unsigned WaveCount) const;
115
116   unsigned findUnusedRegister(const MachineRegisterInfo &MRI,
117                               const TargetRegisterClass *RC) const;
118
119 private:
120   void buildScratchLoadStore(MachineBasicBlock::iterator MI,
121                              unsigned LoadStoreOp, unsigned Value,
122                              unsigned ScratchRsrcReg, unsigned ScratchOffset,
123                              int64_t Offset, RegScavenger *RS) const;
124 };
125
126 } // End namespace llvm
127
128 #endif