@@ -29,34 +29,26 @@ class raw_ostream;
2929class SlotIndex ;
3030
3131struct GCNRegPressure {
32- enum RegKind {
33- SGPR32,
34- SGPR_TUPLE,
35- VGPR32,
36- VGPR_TUPLE,
37- AGPR32,
38- AGPR_TUPLE,
39- TOTAL_KINDS
40- };
32+ enum RegKind { SGPR, VGPR, AGPR, TOTAL_KINDS };
4133
4234 GCNRegPressure () {
4335 clear ();
4436 }
4537
46- bool empty () const { return getSGPRNum () == 0 && getVGPRNum ( false ) == 0 ; }
38+ bool empty () const { return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] ; }
4739
48- void clear () { std::fill (&Value[0 ], &Value[TOTAL_KINDS ], 0 ); }
40+ void clear () { std::fill (&Value[0 ], &Value[ValueArraySize ], 0 ); }
4941
5042 // / \returns the SGPR32 pressure
51- unsigned getSGPRNum () const { return Value[SGPR32 ]; }
43+ unsigned getSGPRNum () const { return Value[SGPR ]; }
5244 // / \returns the aggregated ArchVGPR32, AccVGPR32 pressure dependent upon \p
5345 // / UnifiedVGPRFile
5446 unsigned getVGPRNum (bool UnifiedVGPRFile) const {
5547 if (UnifiedVGPRFile) {
56- return Value[AGPR32 ] ? getUnifiedVGPRNum (Value[VGPR32 ], Value[AGPR32 ])
57- : Value[VGPR32] + Value[AGPR32 ];
48+ return Value[AGPR ] ? getUnifiedVGPRNum (Value[VGPR ], Value[AGPR ])
49+ : Value[VGPR ];
5850 }
59- return std::max (Value[VGPR32 ], Value[AGPR32 ]);
51+ return std::max (Value[VGPR ], Value[AGPR ]);
6052 }
6153
6254 // / Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
@@ -68,13 +60,14 @@ struct GCNRegPressure {
6860 }
6961
7062 // / \returns the ArchVGPR32 pressure
71- unsigned getArchVGPRNum () const { return Value[VGPR32 ]; }
63+ unsigned getArchVGPRNum () const { return Value[VGPR ]; }
7264 // / \returns the AccVGPR32 pressure
73- unsigned getAGPRNum () const { return Value[AGPR32 ]; }
65+ unsigned getAGPRNum () const { return Value[AGPR ]; }
7466
75- unsigned getVGPRTuplesWeight () const { return std::max (Value[VGPR_TUPLE],
76- Value[AGPR_TUPLE]); }
77- unsigned getSGPRTuplesWeight () const { return Value[SGPR_TUPLE]; }
67+ unsigned getVGPRTuplesWeight () const {
68+ return std::max (Value[TOTAL_KINDS + VGPR], Value[TOTAL_KINDS + AGPR]);
69+ }
70+ unsigned getSGPRTuplesWeight () const { return Value[TOTAL_KINDS + SGPR]; }
7871
7972 unsigned getOccupancy (const GCNSubtarget &ST) const {
8073 return std::min (ST.getOccupancyWithNumSGPRs (getSGPRNum ()),
@@ -106,31 +99,36 @@ struct GCNRegPressure {
10699 unsigned MaxOccupancy = std::numeric_limits<unsigned >::max()) const ;
107100
108101 bool operator ==(const GCNRegPressure &O) const {
109- return std::equal (&Value[0 ], &Value[TOTAL_KINDS ], O.Value );
102+ return std::equal (&Value[0 ], &Value[ValueArraySize ], O.Value );
110103 }
111104
112105 bool operator !=(const GCNRegPressure &O) const {
113106 return !(*this == O);
114107 }
115108
116109 GCNRegPressure &operator +=(const GCNRegPressure &RHS) {
117- for (unsigned I = 0 ; I < TOTAL_KINDS ; ++I)
110+ for (unsigned I = 0 ; I < ValueArraySize ; ++I)
118111 Value[I] += RHS.Value [I];
119112 return *this ;
120113 }
121114
122115 GCNRegPressure &operator -=(const GCNRegPressure &RHS) {
123- for (unsigned I = 0 ; I < TOTAL_KINDS ; ++I)
116+ for (unsigned I = 0 ; I < ValueArraySize ; ++I)
124117 Value[I] -= RHS.Value [I];
125118 return *this ;
126119 }
127120
128121 void dump () const ;
129122
130123private:
131- unsigned Value[TOTAL_KINDS];
124+ static constexpr unsigned ValueArraySize = TOTAL_KINDS * 2 ;
125+
126+ // / Pressure for all register kinds (first all regular registers kinds, then
127+ // / all tuple register kinds).
128+ unsigned Value[ValueArraySize];
132129
133- static unsigned getRegKind (Register Reg, const MachineRegisterInfo &MRI);
130+ static unsigned getRegKind (const TargetRegisterClass *RC,
131+ const SIRegisterInfo *STI);
134132
135133 friend GCNRegPressure max (const GCNRegPressure &P1,
136134 const GCNRegPressure &P2);
@@ -140,7 +138,7 @@ struct GCNRegPressure {
140138
141139inline GCNRegPressure max (const GCNRegPressure &P1, const GCNRegPressure &P2) {
142140 GCNRegPressure Res;
143- for (unsigned I = 0 ; I < GCNRegPressure::TOTAL_KINDS ; ++I)
141+ for (unsigned I = 0 ; I < GCNRegPressure::ValueArraySize ; ++I)
144142 Res.Value [I] = std::max (P1.Value [I], P2.Value [I]);
145143 return Res;
146144}
0 commit comments