@@ -29,34 +29,26 @@ class raw_ostream;
29
29
class SlotIndex ;
30
30
31
31
struct 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 };
41
33
42
34
GCNRegPressure () {
43
35
clear ();
44
36
}
45
37
46
- bool empty () const { return getSGPRNum () == 0 && getVGPRNum ( false ) == 0 ; }
38
+ bool empty () const { return !Value[SGPR] && !Value[VGPR] && !Value[AGPR] ; }
47
39
48
- void clear () { std::fill (&Value[0 ], &Value[TOTAL_KINDS ], 0 ); }
40
+ void clear () { std::fill (&Value[0 ], &Value[ValueArraySize ], 0 ); }
49
41
50
42
// / \returns the SGPR32 pressure
51
- unsigned getSGPRNum () const { return Value[SGPR32 ]; }
43
+ unsigned getSGPRNum () const { return Value[SGPR ]; }
52
44
// / \returns the aggregated ArchVGPR32, AccVGPR32 pressure dependent upon \p
53
45
// / UnifiedVGPRFile
54
46
unsigned getVGPRNum (bool UnifiedVGPRFile) const {
55
47
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 ];
58
50
}
59
- return std::max (Value[VGPR32 ], Value[AGPR32 ]);
51
+ return std::max (Value[VGPR ], Value[AGPR ]);
60
52
}
61
53
62
54
// / Returns the aggregated VGPR pressure, assuming \p NumArchVGPRs ArchVGPRs
@@ -68,13 +60,14 @@ struct GCNRegPressure {
68
60
}
69
61
70
62
// / \returns the ArchVGPR32 pressure
71
- unsigned getArchVGPRNum () const { return Value[VGPR32 ]; }
63
+ unsigned getArchVGPRNum () const { return Value[VGPR ]; }
72
64
// / \returns the AccVGPR32 pressure
73
- unsigned getAGPRNum () const { return Value[AGPR32 ]; }
65
+ unsigned getAGPRNum () const { return Value[AGPR ]; }
74
66
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]; }
78
71
79
72
unsigned getOccupancy (const GCNSubtarget &ST) const {
80
73
return std::min (ST.getOccupancyWithNumSGPRs (getSGPRNum ()),
@@ -106,31 +99,36 @@ struct GCNRegPressure {
106
99
unsigned MaxOccupancy = std::numeric_limits<unsigned >::max()) const ;
107
100
108
101
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 );
110
103
}
111
104
112
105
bool operator !=(const GCNRegPressure &O) const {
113
106
return !(*this == O);
114
107
}
115
108
116
109
GCNRegPressure &operator +=(const GCNRegPressure &RHS) {
117
- for (unsigned I = 0 ; I < TOTAL_KINDS ; ++I)
110
+ for (unsigned I = 0 ; I < ValueArraySize ; ++I)
118
111
Value[I] += RHS.Value [I];
119
112
return *this ;
120
113
}
121
114
122
115
GCNRegPressure &operator -=(const GCNRegPressure &RHS) {
123
- for (unsigned I = 0 ; I < TOTAL_KINDS ; ++I)
116
+ for (unsigned I = 0 ; I < ValueArraySize ; ++I)
124
117
Value[I] -= RHS.Value [I];
125
118
return *this ;
126
119
}
127
120
128
121
void dump () const ;
129
122
130
123
private:
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];
132
129
133
- static unsigned getRegKind (Register Reg, const MachineRegisterInfo &MRI);
130
+ static unsigned getRegKind (const TargetRegisterClass *RC,
131
+ const SIRegisterInfo *STI);
134
132
135
133
friend GCNRegPressure max (const GCNRegPressure &P1,
136
134
const GCNRegPressure &P2);
@@ -140,7 +138,7 @@ struct GCNRegPressure {
140
138
141
139
inline GCNRegPressure max (const GCNRegPressure &P1, const GCNRegPressure &P2) {
142
140
GCNRegPressure Res;
143
- for (unsigned I = 0 ; I < GCNRegPressure::TOTAL_KINDS ; ++I)
141
+ for (unsigned I = 0 ; I < GCNRegPressure::ValueArraySize ; ++I)
144
142
Res.Value [I] = std::max (P1.Value [I], P2.Value [I]);
145
143
return Res;
146
144
}
0 commit comments