@@ -212,34 +212,34 @@ enum Indirectability {
212
212
};
213
213
214
214
// A call site and the action that we want to take when indirecting the arg.
215
- // This is then subclassed by the *CallSite classes below.
216
- class CallSite {
215
+ // This is then subclassed by the *ArgCallSite classes below.
216
+ class ArgIndCallSite {
217
217
public:
218
218
CallInst *CI;
219
219
protected:
220
220
Indirectability State;
221
221
Value *Index;
222
222
public:
223
- CallSite (CallInst *CI, Indirectability State, Value *Index)
223
+ ArgIndCallSite (CallInst *CI, Indirectability State, Value *Index)
224
224
: CI(CI), State(State), Index(Index) {}
225
- virtual ~CallSite () {}
225
+ virtual ~ArgIndCallSite () {}
226
226
Indirectability getState () const { return State; }
227
227
Value *getIndex () const { return Index; }
228
228
virtual Value *process (GenXArgIndirection *Pass, SubroutineArg *SubrArg) = 0;
229
229
virtual void printImpl (raw_ostream &OS) const = 0;
230
230
void print (raw_ostream &OS) const { printImpl (OS); }
231
231
};
232
232
233
- raw_ostream &operator <<(raw_ostream &OS, const CallSite &CS) {
233
+ raw_ostream &operator <<(raw_ostream &OS, const ArgIndCallSite &CS) {
234
234
CS.print (OS); return OS;
235
235
}
236
236
237
237
// A call site in a subroutine that is itself indirecting the arg.
238
- class CallerIndirectingCallSite : public CallSite {
238
+ class CallerIndirectingCallSite : public ArgIndCallSite {
239
239
SubroutineArg *CallerSubrArg;
240
240
public:
241
241
CallerIndirectingCallSite (CallInst *CI, SubroutineArg *CallerSubrArg)
242
- : CallSite (CI, Indirectability::CALLER_INDIRECTING, nullptr ),
242
+ : ArgIndCallSite (CI, Indirectability::CALLER_INDIRECTING, nullptr ),
243
243
CallerSubrArg (CallerSubrArg) {}
244
244
virtual Value *process (GenXArgIndirection *Pass, SubroutineArg *SubrArg);
245
245
virtual void printImpl (raw_ostream &OS) const {
@@ -250,10 +250,10 @@ class CallerIndirectingCallSite : public CallSite {
250
250
// A call site where indirecting the arg does not give any optimization because
251
251
// we did not find copies or rd/wr regions that we can get rid of. We can still
252
252
// indirect it though if other call sites do get an optimization.
253
- class NoOptCallSite : public CallSite {
253
+ class NoOptCallSite : public ArgIndCallSite {
254
254
public:
255
255
NoOptCallSite (CallInst *CI)
256
- : CallSite (CI, Indirectability::NO_OPTIMIZATION, nullptr ) {}
256
+ : ArgIndCallSite (CI, Indirectability::NO_OPTIMIZATION, nullptr ) {}
257
257
virtual Value *process (GenXArgIndirection *Pass, SubroutineArg *SubrArg);
258
258
virtual void printImpl (raw_ostream &OS) const {
259
259
OS << " NoOptCallSite " << *CI;
@@ -263,13 +263,13 @@ class NoOptCallSite : public CallSite {
263
263
// A call site where the arg is constant (including undef) and the arg is
264
264
// coalesced with a retval that is used only in a legalized wrregion
265
265
// whose "old value" input is constant.
266
- class ConstArgRetCallSite : public CallSite {
266
+ class ConstArgRetCallSite : public ArgIndCallSite {
267
267
Constant *LdConst; // the constant that needs to be loaded
268
268
AssertingVH<Instruction> RetEndWr; // the last wrregion in the sequence for the retval
269
269
public:
270
270
ConstArgRetCallSite (CallInst *CI, Constant *LdConst, Instruction *RetEndWr,
271
271
Value *Index)
272
- : CallSite (CI, Indirectability::WANT_INDIRECTION, Index),
272
+ : ArgIndCallSite (CI, Indirectability::WANT_INDIRECTION, Index),
273
273
LdConst (LdConst), RetEndWr(RetEndWr) {}
274
274
virtual Value *process (GenXArgIndirection *Pass, SubroutineArg *SubrArg);
275
275
virtual void printImpl (raw_ostream &OS) const {
@@ -280,7 +280,7 @@ class ConstArgRetCallSite : public CallSite {
280
280
281
281
// A call site where the arg is a legalized rdregion or copy, and there is no
282
282
// retval coalesced with it.
283
- class IndirectArgCallSite : public CallSite {
283
+ class IndirectArgCallSite : public ArgIndCallSite {
284
284
protected:
285
285
// Some use of input (arg or inst) in legalized rdregion or copy. This is
286
286
// kept as a Use * rather than the value it actually uses to allow for the
@@ -289,7 +289,7 @@ class IndirectArgCallSite : public CallSite {
289
289
Use *InputUse;
290
290
public:
291
291
IndirectArgCallSite (CallInst *CI, Use *InputUse, Value *Index)
292
- : CallSite (CI, Indirectability::WANT_INDIRECTION, Index),
292
+ : ArgIndCallSite (CI, Indirectability::WANT_INDIRECTION, Index),
293
293
InputUse (InputUse) {}
294
294
virtual Value *process (GenXArgIndirection *Pass, SubroutineArg *SubrArg);
295
295
virtual void printImpl (raw_ostream &OS) const {
@@ -325,7 +325,7 @@ class SubroutineArg {
325
325
private:
326
326
int CoalescedRetIdx = -1 ;
327
327
bool CanCoalesceWithoutKill = false ;
328
- SmallVector<CallSite *, 4 > CallSites;
328
+ SmallVector<ArgIndCallSite *, 4 > CallSites;
329
329
Alignment Align;
330
330
Function *F = nullptr ;
331
331
Function *NewFunc = nullptr ;
@@ -338,7 +338,7 @@ class SubroutineArg {
338
338
delete *i;
339
339
}
340
340
Indirectability checkIndirectability ();
341
- CallSite *createCallSite (CallInst *CI);
341
+ ArgIndCallSite *createCallSite (CallInst *CI);
342
342
Alignment getIndirectAlignment (unsigned GRFWidth) const ;
343
343
void gatherBalesToModify (Alignment Align);
344
344
std::pair<Value *, Value *> addAddressArg ();
@@ -352,7 +352,7 @@ class SubroutineArg {
352
352
// GenX arg indirection pass
353
353
class GenXArgIndirection : public FGPassImplInterface ,
354
354
public IDMixin<GenXArgIndirection> {
355
- friend CallSite ;
355
+ friend ArgIndCallSite ;
356
356
friend SubroutineArg;
357
357
friend NoOptCallSite;
358
358
friend ConstArgRetCallSite;
@@ -779,22 +779,22 @@ Indirectability SubroutineArg::checkIndirectability()
779
779
}
780
780
}
781
781
782
- // Create an object of some subclass of CallSite for each call site.
782
+ // Create an object of some subclass of ArgIndCallSite for each call site.
783
783
for (auto &U: F->uses ()) {
784
784
if (auto *CI = checkFunctionCall (U.getUser (), F)) {
785
785
IGC_ASSERT (U.getOperandNo () == CI->getNumArgOperands ());
786
- auto CallSite = createCallSite (CI);
787
- if (!CallSite )
786
+ auto CS = createCallSite (CI);
787
+ if (!CS )
788
788
return Indirectability::CANNOT_INDIRECT;
789
- CallSites.push_back (CallSite );
790
- LLVM_DEBUG (dbgs () << " " << *CallSite << " \n " );
789
+ CallSites.push_back (CS );
790
+ LLVM_DEBUG (dbgs () << " " << *CS << " \n " );
791
791
}
792
792
}
793
793
// Check indirection state for each call site.
794
794
unsigned States = 0 ;
795
795
for (auto csi = CallSites.begin (), cse = CallSites.end (); csi != cse; ++csi) {
796
- auto CallSite = *csi;
797
- States |= CallSite ->getState ();
796
+ auto CS = *csi;
797
+ States |= CS ->getState ();
798
798
}
799
799
switch (States & (Indirectability::NO_OPTIMIZATION | Indirectability::WANT_INDIRECTION)) {
800
800
case Indirectability::NO_OPTIMIZATION | Indirectability::WANT_INDIRECTION:
@@ -806,18 +806,18 @@ Indirectability SubroutineArg::checkIndirectability()
806
806
}
807
807
808
808
/* **********************************************************************
809
- * createCallSite : create a CallSite object for this call
809
+ * createCallSite : create a ArgIndCallSite object for this call
810
810
*
811
811
* Enter: CI = CallInst
812
812
* this->Arg = the Argument to look at
813
813
* this->ArgLR = its LiveRange
814
- * this->CoalescedRetIdx = -1 else struct index of coalesced return value
814
+ * this->CoalescedRetIdx = -1 else struct index of coalesced return
815
+ * value
815
816
*
816
817
* Return: 0 if this call stops arg indirection happening for this arg
817
818
* otherwise object of some subclass of CallSite
818
819
*/
819
- CallSite *SubroutineArg::createCallSite (CallInst *CI)
820
- {
820
+ ArgIndCallSite *SubroutineArg::createCallSite (CallInst *CI) {
821
821
// Check if this call site is in a function that is itself indirecting the
822
822
// arg.
823
823
if (auto SubrArg = Pass->FuncMap [CI->getParent ()->getParent ()])
@@ -885,7 +885,7 @@ CallSite *SubroutineArg::createCallSite(CallInst *CI)
885
885
}
886
886
887
887
// Now check the various cases. This results in the creation of an object of
888
- // some subclass of CallSite .
888
+ // some subclass of ArgIndCallSite .
889
889
890
890
// Check that the regions are contiguous, and report if they are not.
891
891
if (ArgRWS.isNull () && !ArgRWS.RdR .isContiguous ()) {
@@ -1007,8 +1007,8 @@ Alignment SubroutineArg::getIndirectAlignment(unsigned GRFWidth) const {
1007
1007
Alignment Align (genx::log2 (GRFWidth), 0 ); // best case is GRF aligned
1008
1008
for (auto csi = CallSites.begin (), cse = CallSites.end ();
1009
1009
csi != cse; ++csi) {
1010
- auto CallSite = *csi;
1011
- Value *Index = CallSite ->getIndex ();
1010
+ auto CS = *csi;
1011
+ Value *Index = CS ->getIndex ();
1012
1012
if (!Index)
1013
1013
continue ;
1014
1014
Align = Align.merge (Pass->AI ->get (Index));
@@ -1300,36 +1300,36 @@ std::pair<Value *, Value *> SubroutineArg::addAddressArg() {
1300
1300
* function instead and passes the extra address arg
1301
1301
*
1302
1302
* For each call site, this calls the process() method on the object of a
1303
- * subclass of CallSite set up by createCallSite(). That returns the extra
1303
+ * subclass of ArgIndCallSite set up by createCallSite(). That returns the extra
1304
1304
* address arg, which this function then uses to create a replacement call
1305
1305
* instruction.
1306
1306
*/
1307
1307
void SubroutineArg::fixCallSites ()
1308
1308
{
1309
1309
for (auto csi = CallSites.begin (), cse = CallSites.end (); csi != cse; ++csi) {
1310
- auto CallSite = *csi;
1311
- LLVM_DEBUG (dbgs () << " fixCallSites: [" << Pass->Numbering ->getNumber (CallSite->CI )
1312
- << " ] " << *CallSite << " \n " );
1310
+ auto CS = *csi;
1311
+ LLVM_DEBUG (dbgs () << " fixCallSites: ["
1312
+ << Pass->Numbering ->getNumber (CS->CI ) << " ] " << *CS
1313
+ << " \n " );
1313
1314
// Process the call site.
1314
1315
// Create the replacement call instruction, with an added address arg that
1315
1316
// for now we set to undef. We do this first so that process() called below
1316
1317
// can modify the arg being indirected such that the eraseUnusedTree erases
1317
1318
// the rd-wr sequence that sets up the arg in the old call.
1318
1319
SmallVector<Value *, 4 > Args;
1319
- for (unsigned oi = 0 , oe = CallSite->CI ->getNumArgOperands ();
1320
- oi != oe; ++oi)
1321
- Args.push_back (CallSite->CI ->getArgOperand (oi));
1322
- Args.push_back (UndefValue::get (Type::getInt16Ty (CallSite->CI ->getContext ())));
1323
- CallInst *OldCI = CallSite->CI ;
1324
- CallSite->CI = CallInst::Create (NewFunc, Args, " " , OldCI);
1325
- CallSite->CI ->takeName (OldCI);
1326
- CallSite->CI ->setDebugLoc (OldCI->getDebugLoc ());
1327
- Pass->Numbering ->setNumber (CallSite->CI , Pass->Numbering ->getNumber (OldCI));
1328
- Pass->Numbering ->setStartNumber (CallSite->CI ,
1329
- Pass->Numbering ->getStartNumber (OldCI));
1330
- // Get the subclass of CallSite to do its processing, returning the extra
1331
- // address arg for the call.
1332
- Value *AddressArg = CallSite->process (Pass, this );
1320
+ for (unsigned oi = 0 , oe = CS->CI ->getNumArgOperands (); oi != oe; ++oi)
1321
+ Args.push_back (CS->CI ->getArgOperand (oi));
1322
+ Args.push_back (UndefValue::get (Type::getInt16Ty (CS->CI ->getContext ())));
1323
+ CallInst *OldCI = CS->CI ;
1324
+ CS->CI = CallInst::Create (NewFunc, Args, " " , OldCI);
1325
+ CS->CI ->takeName (OldCI);
1326
+ CS->CI ->setDebugLoc (OldCI->getDebugLoc ());
1327
+ Pass->Numbering ->setNumber (CS->CI , Pass->Numbering ->getNumber (OldCI));
1328
+ Pass->Numbering ->setStartNumber (CS->CI ,
1329
+ Pass->Numbering ->getStartNumber (OldCI));
1330
+ // Get the subclass of ArgIndCallSite to do its processing, returning the
1331
+ // extra address arg for the call.
1332
+ Value *AddressArg = CS->process (Pass, this );
1333
1333
LLVM_DEBUG (dbgs () << " AddressArg is " << AddressArg->getName () << " \n " );
1334
1334
if (!isa<UndefValue>(AddressArg)) {
1335
1335
// Create a live range for the address arg, and ensure it is recalculated.
@@ -1338,12 +1338,12 @@ void SubroutineArg::fixCallSites()
1338
1338
Pass->LRsToCalculate .push_back (AddressArgLR);
1339
1339
}
1340
1340
// Use the address arg in the new call.
1341
- CallSite ->CI ->setOperand (Args.size () - 1 , AddressArg);
1341
+ CS ->CI ->setOperand (Args.size () - 1 , AddressArg);
1342
1342
// Replace the old call with the new one, and erase the old one. We use
1343
1343
// eraseUnusedTree so that any rd-wr sequence for the indirected arg is also
1344
1344
// erased.
1345
- OldCI->replaceAllUsesWith (CallSite ->CI );
1346
- Pass->Liveness ->replaceValue (OldCI, CallSite ->CI );
1345
+ OldCI->replaceAllUsesWith (CS ->CI );
1346
+ Pass->Liveness ->replaceValue (OldCI, CS ->CI );
1347
1347
Pass->Liveness ->eraseUnusedTree (OldCI);
1348
1348
}
1349
1349
}
@@ -1623,8 +1623,8 @@ void SubroutineArg::coalesceAddressArgs()
1623
1623
LiveRange *AddressLR = Pass->Liveness ->getLiveRange (AddressArgument);
1624
1624
unsigned ArgNum = AddressArgument->getArgNo ();
1625
1625
for (unsigned csi = 0 , cse = CallSites.size (); csi != cse; ++csi) {
1626
- auto CallSite = CallSites[csi];
1627
- Value *CallArg = CallSite ->CI ->getArgOperand (ArgNum);
1626
+ auto CS = CallSites[csi];
1627
+ Value *CallArg = CS ->CI ->getArgOperand (ArgNum);
1628
1628
if (isa<UndefValue>(CallArg))
1629
1629
continue ;
1630
1630
LiveRange *CallArgLR = Pass->Liveness ->getLiveRange (CallArg);
@@ -1640,19 +1640,19 @@ void SubroutineArg::coalesceAddressArgs()
1640
1640
// subroutine where we are indirecting the arg -- the new address args
1641
1641
// for each subroutine should coalesce together.
1642
1642
LLVM_DEBUG (dbgs () << " Failed to coalesce:\n " << *AddressLR << " \n " << *CallArgLR << " \n " );
1643
- IGC_ASSERT_MESSAGE (!Pass->FuncMap [CallSite ->CI ->getParent ()->getParent ()],
1644
- " new address args should coalesce together" );
1643
+ IGC_ASSERT_MESSAGE (!Pass->FuncMap [CS ->CI ->getParent ()->getParent ()],
1644
+ " new address args should coalesce together" );
1645
1645
// We need to insert a copy, in the address arg's pre-copy slot. An address
1646
1646
// copy is done with a genx.convert, even though it is not actually doing a
1647
1647
// conversion.
1648
- auto Copy = createConvert (CallArg, CallArg-> getName () + " .coalescefail " ,
1649
- CallSite ->CI );
1650
- Copy->setDebugLoc (CallSite ->CI ->getDebugLoc ());
1651
- Pass->Numbering ->setNumber (Copy, Pass-> Numbering -> getArgPreCopyNumber (
1652
- CallSite ->CI , ArgNum, 0 ));
1648
+ auto Copy =
1649
+ createConvert (CallArg, CallArg-> getName () + " .coalescefail " , CS ->CI );
1650
+ Copy->setDebugLoc (CS ->CI ->getDebugLoc ());
1651
+ Pass->Numbering ->setNumber (
1652
+ Copy, Pass-> Numbering -> getArgPreCopyNumber (CS ->CI , ArgNum, 0 ));
1653
1653
// Add the new value in to AddressLR.
1654
1654
Pass->Liveness ->setLiveRange (Copy, AddressLR);
1655
- CallSite ->CI ->setOperand (ArgNum, Copy);
1655
+ CS ->CI ->setOperand (ArgNum, Copy);
1656
1656
}
1657
1657
}
1658
1658
0 commit comments