21
21
using namespace llvm ;
22
22
using namespace llvm ::AMDGPU;
23
23
24
- AMDGPUVariadicMCExpr::AMDGPUVariadicMCExpr (VariadicKind Kind,
25
- ArrayRef<const MCExpr *> Args,
26
- MCContext &Ctx)
24
+ AMDGPUMCExpr::AMDGPUMCExpr (VariantKind Kind, ArrayRef<const MCExpr *> Args,
25
+ MCContext &Ctx)
27
26
: Kind(Kind), Ctx(Ctx) {
28
27
assert (Args.size () >= 1 && " Needs a minimum of one expression." );
29
- assert (Kind != AGVK_None &&
30
- " Cannot construct AMDGPUVariadicMCExpr of kind none." );
28
+ assert (Kind != AGVK_None && " Cannot construct AMDGPUMCExpr of kind none." );
31
29
32
30
// Allocating the variadic arguments through the same allocation mechanism
33
31
// that the object itself is allocated with so they end up in the same memory.
@@ -40,25 +38,23 @@ AMDGPUVariadicMCExpr::AMDGPUVariadicMCExpr(VariadicKind Kind,
40
38
this ->Args = ArrayRef<const MCExpr *>(RawArgs, Args.size ());
41
39
}
42
40
43
- AMDGPUVariadicMCExpr ::~AMDGPUVariadicMCExpr () { Ctx.deallocate (RawArgs); }
41
+ AMDGPUMCExpr ::~AMDGPUMCExpr () { Ctx.deallocate (RawArgs); }
44
42
45
- const AMDGPUVariadicMCExpr *
46
- AMDGPUVariadicMCExpr::create (VariadicKind Kind, ArrayRef<const MCExpr *> Args,
47
- MCContext &Ctx) {
48
- return new (Ctx) AMDGPUVariadicMCExpr (Kind, Args, Ctx);
43
+ const AMDGPUMCExpr * AMDGPUMCExpr::create (VariantKind Kind,
44
+ ArrayRef<const MCExpr *> Args,
45
+ MCContext &Ctx) {
46
+ return new (Ctx) AMDGPUMCExpr (Kind, Args, Ctx);
49
47
}
50
48
51
- const MCExpr *AMDGPUVariadicMCExpr::getSubExpr (size_t Index) const {
52
- assert (Index < Args.size () &&
53
- " Indexing out of bounds AMDGPUVariadicMCExpr sub-expr" );
49
+ const MCExpr *AMDGPUMCExpr::getSubExpr (size_t Index) const {
50
+ assert (Index < Args.size () && " Indexing out of bounds AMDGPUMCExpr sub-expr" );
54
51
return Args[Index];
55
52
}
56
53
57
- void AMDGPUVariadicMCExpr::printImpl (raw_ostream &OS,
58
- const MCAsmInfo *MAI) const {
54
+ void AMDGPUMCExpr::printImpl (raw_ostream &OS, const MCAsmInfo *MAI) const {
59
55
switch (Kind) {
60
56
default :
61
- llvm_unreachable (" Unknown AMDGPUVariadicMCExpr kind." );
57
+ llvm_unreachable (" Unknown AMDGPUMCExpr kind." );
62
58
case AGVK_Or:
63
59
OS << " or(" ;
64
60
break ;
@@ -86,21 +82,19 @@ void AMDGPUVariadicMCExpr::printImpl(raw_ostream &OS,
86
82
OS << ' )' ;
87
83
}
88
84
89
- static int64_t op (AMDGPUVariadicMCExpr::VariadicKind Kind, int64_t Arg1,
90
- int64_t Arg2) {
85
+ static int64_t op (AMDGPUMCExpr::VariantKind Kind, int64_t Arg1, int64_t Arg2) {
91
86
switch (Kind) {
92
87
default :
93
- llvm_unreachable (" Unknown AMDGPUVariadicMCExpr kind." );
94
- case AMDGPUVariadicMCExpr ::AGVK_Max:
88
+ llvm_unreachable (" Unknown AMDGPUMCExpr kind." );
89
+ case AMDGPUMCExpr ::AGVK_Max:
95
90
return std::max (Arg1, Arg2);
96
- case AMDGPUVariadicMCExpr ::AGVK_Or:
91
+ case AMDGPUMCExpr ::AGVK_Or:
97
92
return Arg1 | Arg2;
98
93
}
99
94
}
100
95
101
- bool AMDGPUVariadicMCExpr::evaluateExtraSGPRs (MCValue &Res,
102
- const MCAsmLayout *Layout,
103
- const MCFixup *Fixup) const {
96
+ bool AMDGPUMCExpr::evaluateExtraSGPRs (MCValue &Res, const MCAsmLayout *Layout,
97
+ const MCFixup *Fixup) const {
104
98
auto TryGetMCExprValue = [&](const MCExpr *Arg, uint64_t &ConstantValue) {
105
99
MCValue MCVal;
106
100
if (!Arg->evaluateAsRelocatable (MCVal, Layout, Fixup) ||
@@ -112,7 +106,7 @@ bool AMDGPUVariadicMCExpr::evaluateExtraSGPRs(MCValue &Res,
112
106
};
113
107
114
108
assert (Args.size () == 3 &&
115
- " AMDGPUVariadic Argument count incorrect for ExtraSGPRs" );
109
+ " AMDGPUMCExpr Argument count incorrect for ExtraSGPRs" );
116
110
const MCSubtargetInfo *STI = Ctx.getSubtargetInfo ();
117
111
uint64_t VCCUsed = 0 , FlatScrUsed = 0 , XNACKUsed = 0 ;
118
112
@@ -129,9 +123,8 @@ bool AMDGPUVariadicMCExpr::evaluateExtraSGPRs(MCValue &Res,
129
123
return true ;
130
124
}
131
125
132
- bool AMDGPUVariadicMCExpr::evaluateTotalNumVGPR (MCValue &Res,
133
- const MCAsmLayout *Layout,
134
- const MCFixup *Fixup) const {
126
+ bool AMDGPUMCExpr::evaluateTotalNumVGPR (MCValue &Res, const MCAsmLayout *Layout,
127
+ const MCFixup *Fixup) const {
135
128
auto TryGetMCExprValue = [&](const MCExpr *Arg, uint64_t &ConstantValue) {
136
129
MCValue MCVal;
137
130
if (!Arg->evaluateAsRelocatable (MCVal, Layout, Fixup) ||
@@ -142,7 +135,7 @@ bool AMDGPUVariadicMCExpr::evaluateTotalNumVGPR(MCValue &Res,
142
135
return true ;
143
136
};
144
137
assert (Args.size () == 2 &&
145
- " AMDGPUVariadic Argument count incorrect for TotalNumVGPRs" );
138
+ " AMDGPUMCExpr Argument count incorrect for TotalNumVGPRs" );
146
139
const MCSubtargetInfo *STI = Ctx.getSubtargetInfo ();
147
140
uint64_t NumAGPR = 0 , NumVGPR = 0 ;
148
141
@@ -158,9 +151,8 @@ bool AMDGPUVariadicMCExpr::evaluateTotalNumVGPR(MCValue &Res,
158
151
return true ;
159
152
}
160
153
161
- bool AMDGPUVariadicMCExpr::evaluateAlignTo (MCValue &Res,
162
- const MCAsmLayout *Layout,
163
- const MCFixup *Fixup) const {
154
+ bool AMDGPUMCExpr::evaluateAlignTo (MCValue &Res, const MCAsmLayout *Layout,
155
+ const MCFixup *Fixup) const {
164
156
auto TryGetMCExprValue = [&](const MCExpr *Arg, uint64_t &ConstantValue) {
165
157
MCValue MCVal;
166
158
if (!Arg->evaluateAsRelocatable (MCVal, Layout, Fixup) ||
@@ -172,7 +164,7 @@ bool AMDGPUVariadicMCExpr::evaluateAlignTo(MCValue &Res,
172
164
};
173
165
174
166
assert (Args.size () == 2 &&
175
- " AMDGPUVariadic Argument count incorrect for AlignTo" );
167
+ " AMDGPUMCExpr Argument count incorrect for AlignTo" );
176
168
uint64_t Value = 0 , Align = 0 ;
177
169
if (!TryGetMCExprValue (Args[0 ], Value) || !TryGetMCExprValue (Args[1 ], Align))
178
170
return false ;
@@ -181,9 +173,8 @@ bool AMDGPUVariadicMCExpr::evaluateAlignTo(MCValue &Res,
181
173
return true ;
182
174
}
183
175
184
- bool AMDGPUVariadicMCExpr::evaluateOccupancy (MCValue &Res,
185
- const MCAsmLayout *Layout,
186
- const MCFixup *Fixup) const {
176
+ bool AMDGPUMCExpr::evaluateOccupancy (MCValue &Res, const MCAsmLayout *Layout,
177
+ const MCFixup *Fixup) const {
187
178
auto TryGetMCExprValue = [&](const MCExpr *Arg, uint64_t &ConstantValue) {
188
179
MCValue MCVal;
189
180
if (!Arg->evaluateAsRelocatable (MCVal, Layout, Fixup) ||
@@ -194,7 +185,7 @@ bool AMDGPUVariadicMCExpr::evaluateOccupancy(MCValue &Res,
194
185
return true ;
195
186
};
196
187
assert (Args.size () == 7 &&
197
- " AMDGPUVariadic Argument count incorrect for Occupancy" );
188
+ " AMDGPUMCExpr Argument count incorrect for Occupancy" );
198
189
uint64_t InitOccupancy, MaxWaves, Granule, TargetTotalNumVGPRs, Generation,
199
190
NumSGPRs, NumVGPRs;
200
191
@@ -226,8 +217,9 @@ bool AMDGPUVariadicMCExpr::evaluateOccupancy(MCValue &Res,
226
217
return true ;
227
218
}
228
219
229
- bool AMDGPUVariadicMCExpr::evaluateAsRelocatableImpl (
230
- MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const {
220
+ bool AMDGPUMCExpr::evaluateAsRelocatableImpl (MCValue &Res,
221
+ const MCAsmLayout *Layout,
222
+ const MCFixup *Fixup) const {
231
223
std::optional<int64_t > Total;
232
224
233
225
switch (Kind) {
@@ -258,12 +250,12 @@ bool AMDGPUVariadicMCExpr::evaluateAsRelocatableImpl(
258
250
return true ;
259
251
}
260
252
261
- void AMDGPUVariadicMCExpr ::visitUsedExpr (MCStreamer &Streamer) const {
253
+ void AMDGPUMCExpr ::visitUsedExpr (MCStreamer &Streamer) const {
262
254
for (const MCExpr *Arg : Args)
263
255
Streamer.visitUsedExpr (*Arg);
264
256
}
265
257
266
- MCFragment *AMDGPUVariadicMCExpr ::findAssociatedFragment () const {
258
+ MCFragment *AMDGPUMCExpr ::findAssociatedFragment () const {
267
259
for (const MCExpr *Arg : Args) {
268
260
if (Arg->findAssociatedFragment ())
269
261
return Arg->findAssociatedFragment ();
@@ -275,18 +267,19 @@ MCFragment *AMDGPUVariadicMCExpr::findAssociatedFragment() const {
275
267
// / are unresolvable but needed for further MCExprs). Derived from
276
268
// / implementation of IsaInfo::getNumExtraSGPRs in AMDGPUBaseInfo.cpp.
277
269
// /
278
- const AMDGPUVariadicMCExpr *
279
- AMDGPUVariadicMCExpr::createExtraSGPRs ( const MCExpr *VCCUsed ,
280
- const MCExpr *FlatScrUsed ,
281
- bool XNACKUsed, MCContext &Ctx) {
270
+ const AMDGPUMCExpr * AMDGPUMCExpr::createExtraSGPRs ( const MCExpr *VCCUsed,
271
+ const MCExpr *FlatScrUsed ,
272
+ bool XNACKUsed ,
273
+ MCContext &Ctx) {
282
274
283
275
return create (AGVK_ExtraSGPRs,
284
276
{VCCUsed, FlatScrUsed, MCConstantExpr::create (XNACKUsed, Ctx)},
285
277
Ctx);
286
278
}
287
279
288
- const AMDGPUVariadicMCExpr *AMDGPUVariadicMCExpr::createTotalNumVGPR (
289
- const MCExpr *NumAGPR, const MCExpr *NumVGPR, MCContext &Ctx) {
280
+ const AMDGPUMCExpr *AMDGPUMCExpr::createTotalNumVGPR (const MCExpr *NumAGPR,
281
+ const MCExpr *NumVGPR,
282
+ MCContext &Ctx) {
290
283
return create (AGVK_TotalNumVGPRs, {NumAGPR, NumVGPR}, Ctx);
291
284
}
292
285
@@ -295,10 +288,11 @@ const AMDGPUVariadicMCExpr *AMDGPUVariadicMCExpr::createTotalNumVGPR(
295
288
// / Remove dependency on GCNSubtarget and depend only only the necessary values
296
289
// / for said occupancy computation. Should match computeOccupancy implementation
297
290
// / without passing \p STM on.
298
- const AMDGPUVariadicMCExpr *
299
- AMDGPUVariadicMCExpr::createOccupancy (unsigned InitOcc, const MCExpr *NumSGPRs,
300
- const MCExpr *NumVGPRs,
301
- const GCNSubtarget &STM, MCContext &Ctx) {
291
+ const AMDGPUMCExpr *AMDGPUMCExpr::createOccupancy (unsigned InitOcc,
292
+ const MCExpr *NumSGPRs,
293
+ const MCExpr *NumVGPRs,
294
+ const GCNSubtarget &STM,
295
+ MCContext &Ctx) {
302
296
unsigned MaxWaves = IsaInfo::getMaxWavesPerEU (&STM);
303
297
unsigned Granule = IsaInfo::getVGPRAllocGranule (&STM);
304
298
unsigned TargetTotalNumVGPRs = IsaInfo::getTotalNumVGPRs (&STM);
0 commit comments