Skip to content

Commit ed71be1

Browse files
azabaznoigcbot
authored andcommitted
Rename internal structure in arg indirection pass to avoid ambiguity
Rename internal structure in arg indirection pass to avoid ambiguity
1 parent 22d596c commit ed71be1

File tree

1 file changed

+61
-61
lines changed

1 file changed

+61
-61
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXArgIndirection.cpp

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -212,34 +212,34 @@ enum Indirectability {
212212
};
213213

214214
// 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 {
217217
public:
218218
CallInst *CI;
219219
protected:
220220
Indirectability State;
221221
Value *Index;
222222
public:
223-
CallSite(CallInst *CI, Indirectability State, Value *Index)
223+
ArgIndCallSite(CallInst *CI, Indirectability State, Value *Index)
224224
: CI(CI), State(State), Index(Index) {}
225-
virtual ~CallSite() {}
225+
virtual ~ArgIndCallSite() {}
226226
Indirectability getState() const { return State; }
227227
Value *getIndex() const { return Index; }
228228
virtual Value *process(GenXArgIndirection *Pass, SubroutineArg *SubrArg) = 0;
229229
virtual void printImpl(raw_ostream &OS) const = 0;
230230
void print(raw_ostream &OS) const { printImpl(OS); }
231231
};
232232

233-
raw_ostream &operator<<(raw_ostream &OS, const CallSite &CS) {
233+
raw_ostream &operator<<(raw_ostream &OS, const ArgIndCallSite &CS) {
234234
CS.print(OS); return OS;
235235
}
236236

237237
// A call site in a subroutine that is itself indirecting the arg.
238-
class CallerIndirectingCallSite : public CallSite {
238+
class CallerIndirectingCallSite : public ArgIndCallSite {
239239
SubroutineArg *CallerSubrArg;
240240
public:
241241
CallerIndirectingCallSite(CallInst *CI, SubroutineArg *CallerSubrArg)
242-
: CallSite(CI, Indirectability::CALLER_INDIRECTING, nullptr),
242+
: ArgIndCallSite(CI, Indirectability::CALLER_INDIRECTING, nullptr),
243243
CallerSubrArg(CallerSubrArg) {}
244244
virtual Value *process(GenXArgIndirection *Pass, SubroutineArg *SubrArg);
245245
virtual void printImpl(raw_ostream &OS) const {
@@ -250,10 +250,10 @@ class CallerIndirectingCallSite : public CallSite {
250250
// A call site where indirecting the arg does not give any optimization because
251251
// we did not find copies or rd/wr regions that we can get rid of. We can still
252252
// indirect it though if other call sites do get an optimization.
253-
class NoOptCallSite : public CallSite {
253+
class NoOptCallSite : public ArgIndCallSite {
254254
public:
255255
NoOptCallSite(CallInst *CI)
256-
: CallSite(CI, Indirectability::NO_OPTIMIZATION, nullptr) {}
256+
: ArgIndCallSite(CI, Indirectability::NO_OPTIMIZATION, nullptr) {}
257257
virtual Value *process(GenXArgIndirection *Pass, SubroutineArg *SubrArg);
258258
virtual void printImpl(raw_ostream &OS) const {
259259
OS << "NoOptCallSite " << *CI;
@@ -263,13 +263,13 @@ class NoOptCallSite : public CallSite {
263263
// A call site where the arg is constant (including undef) and the arg is
264264
// coalesced with a retval that is used only in a legalized wrregion
265265
// whose "old value" input is constant.
266-
class ConstArgRetCallSite : public CallSite {
266+
class ConstArgRetCallSite : public ArgIndCallSite {
267267
Constant *LdConst; // the constant that needs to be loaded
268268
AssertingVH<Instruction> RetEndWr; // the last wrregion in the sequence for the retval
269269
public:
270270
ConstArgRetCallSite(CallInst *CI, Constant *LdConst, Instruction *RetEndWr,
271271
Value *Index)
272-
: CallSite(CI, Indirectability::WANT_INDIRECTION, Index),
272+
: ArgIndCallSite(CI, Indirectability::WANT_INDIRECTION, Index),
273273
LdConst(LdConst), RetEndWr(RetEndWr) {}
274274
virtual Value *process(GenXArgIndirection *Pass, SubroutineArg *SubrArg);
275275
virtual void printImpl(raw_ostream &OS) const {
@@ -280,7 +280,7 @@ class ConstArgRetCallSite : public CallSite {
280280

281281
// A call site where the arg is a legalized rdregion or copy, and there is no
282282
// retval coalesced with it.
283-
class IndirectArgCallSite : public CallSite {
283+
class IndirectArgCallSite : public ArgIndCallSite {
284284
protected:
285285
// Some use of input (arg or inst) in legalized rdregion or copy. This is
286286
// kept as a Use * rather than the value it actually uses to allow for the
@@ -289,7 +289,7 @@ class IndirectArgCallSite : public CallSite {
289289
Use *InputUse;
290290
public:
291291
IndirectArgCallSite(CallInst *CI, Use *InputUse, Value *Index)
292-
: CallSite(CI, Indirectability::WANT_INDIRECTION, Index),
292+
: ArgIndCallSite(CI, Indirectability::WANT_INDIRECTION, Index),
293293
InputUse(InputUse) {}
294294
virtual Value *process(GenXArgIndirection *Pass, SubroutineArg *SubrArg);
295295
virtual void printImpl(raw_ostream &OS) const {
@@ -325,7 +325,7 @@ class SubroutineArg {
325325
private:
326326
int CoalescedRetIdx = -1;
327327
bool CanCoalesceWithoutKill = false;
328-
SmallVector<CallSite *, 4> CallSites;
328+
SmallVector<ArgIndCallSite *, 4> CallSites;
329329
Alignment Align;
330330
Function *F = nullptr;
331331
Function *NewFunc = nullptr;
@@ -338,7 +338,7 @@ class SubroutineArg {
338338
delete *i;
339339
}
340340
Indirectability checkIndirectability();
341-
CallSite *createCallSite(CallInst *CI);
341+
ArgIndCallSite *createCallSite(CallInst *CI);
342342
Alignment getIndirectAlignment(unsigned GRFWidth) const;
343343
void gatherBalesToModify(Alignment Align);
344344
std::pair<Value *, Value *> addAddressArg();
@@ -352,7 +352,7 @@ class SubroutineArg {
352352
// GenX arg indirection pass
353353
class GenXArgIndirection : public FGPassImplInterface,
354354
public IDMixin<GenXArgIndirection> {
355-
friend CallSite;
355+
friend ArgIndCallSite;
356356
friend SubroutineArg;
357357
friend NoOptCallSite;
358358
friend ConstArgRetCallSite;
@@ -779,22 +779,22 @@ Indirectability SubroutineArg::checkIndirectability()
779779
}
780780
}
781781

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.
783783
for (auto &U: F->uses()) {
784784
if (auto *CI = checkFunctionCall(U.getUser(), F)) {
785785
IGC_ASSERT(U.getOperandNo() == CI->getNumArgOperands());
786-
auto CallSite = createCallSite(CI);
787-
if (!CallSite)
786+
auto CS = createCallSite(CI);
787+
if (!CS)
788788
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");
791791
}
792792
}
793793
// Check indirection state for each call site.
794794
unsigned States = 0;
795795
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();
798798
}
799799
switch (States & (Indirectability::NO_OPTIMIZATION | Indirectability::WANT_INDIRECTION)) {
800800
case Indirectability::NO_OPTIMIZATION | Indirectability::WANT_INDIRECTION:
@@ -806,18 +806,18 @@ Indirectability SubroutineArg::checkIndirectability()
806806
}
807807

808808
/***********************************************************************
809-
* createCallSite : create a CallSite object for this call
809+
* createCallSite : create a ArgIndCallSite object for this call
810810
*
811811
* Enter: CI = CallInst
812812
* this->Arg = the Argument to look at
813813
* 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
815816
*
816817
* Return: 0 if this call stops arg indirection happening for this arg
817818
* otherwise object of some subclass of CallSite
818819
*/
819-
CallSite *SubroutineArg::createCallSite(CallInst *CI)
820-
{
820+
ArgIndCallSite *SubroutineArg::createCallSite(CallInst *CI) {
821821
// Check if this call site is in a function that is itself indirecting the
822822
// arg.
823823
if (auto SubrArg = Pass->FuncMap[CI->getParent()->getParent()])
@@ -885,7 +885,7 @@ CallSite *SubroutineArg::createCallSite(CallInst *CI)
885885
}
886886

887887
// Now check the various cases. This results in the creation of an object of
888-
// some subclass of CallSite.
888+
// some subclass of ArgIndCallSite.
889889

890890
// Check that the regions are contiguous, and report if they are not.
891891
if (ArgRWS.isNull() && !ArgRWS.RdR.isContiguous()) {
@@ -1007,8 +1007,8 @@ Alignment SubroutineArg::getIndirectAlignment(unsigned GRFWidth) const {
10071007
Alignment Align(genx::log2(GRFWidth), 0); // best case is GRF aligned
10081008
for (auto csi = CallSites.begin(), cse = CallSites.end();
10091009
csi != cse; ++csi) {
1010-
auto CallSite = *csi;
1011-
Value *Index = CallSite->getIndex();
1010+
auto CS = *csi;
1011+
Value *Index = CS->getIndex();
10121012
if (!Index)
10131013
continue;
10141014
Align = Align.merge(Pass->AI->get(Index));
@@ -1300,36 +1300,36 @@ std::pair<Value *, Value *> SubroutineArg::addAddressArg() {
13001300
* function instead and passes the extra address arg
13011301
*
13021302
* 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
13041304
* address arg, which this function then uses to create a replacement call
13051305
* instruction.
13061306
*/
13071307
void SubroutineArg::fixCallSites()
13081308
{
13091309
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");
13131314
// Process the call site.
13141315
// Create the replacement call instruction, with an added address arg that
13151316
// for now we set to undef. We do this first so that process() called below
13161317
// can modify the arg being indirected such that the eraseUnusedTree erases
13171318
// the rd-wr sequence that sets up the arg in the old call.
13181319
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);
13331333
LLVM_DEBUG(dbgs() << " AddressArg is " << AddressArg->getName() << "\n");
13341334
if (!isa<UndefValue>(AddressArg)) {
13351335
// Create a live range for the address arg, and ensure it is recalculated.
@@ -1338,12 +1338,12 @@ void SubroutineArg::fixCallSites()
13381338
Pass->LRsToCalculate.push_back(AddressArgLR);
13391339
}
13401340
// Use the address arg in the new call.
1341-
CallSite->CI->setOperand(Args.size() - 1, AddressArg);
1341+
CS->CI->setOperand(Args.size() - 1, AddressArg);
13421342
// Replace the old call with the new one, and erase the old one. We use
13431343
// eraseUnusedTree so that any rd-wr sequence for the indirected arg is also
13441344
// 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);
13471347
Pass->Liveness->eraseUnusedTree(OldCI);
13481348
}
13491349
}
@@ -1623,8 +1623,8 @@ void SubroutineArg::coalesceAddressArgs()
16231623
LiveRange *AddressLR = Pass->Liveness->getLiveRange(AddressArgument);
16241624
unsigned ArgNum = AddressArgument->getArgNo();
16251625
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);
16281628
if (isa<UndefValue>(CallArg))
16291629
continue;
16301630
LiveRange *CallArgLR = Pass->Liveness->getLiveRange(CallArg);
@@ -1640,19 +1640,19 @@ void SubroutineArg::coalesceAddressArgs()
16401640
// subroutine where we are indirecting the arg -- the new address args
16411641
// for each subroutine should coalesce together.
16421642
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");
16451645
// We need to insert a copy, in the address arg's pre-copy slot. An address
16461646
// copy is done with a genx.convert, even though it is not actually doing a
16471647
// 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));
16531653
// Add the new value in to AddressLR.
16541654
Pass->Liveness->setLiveRange(Copy, AddressLR);
1655-
CallSite->CI->setOperand(ArgNum, Copy);
1655+
CS->CI->setOperand(ArgNum, Copy);
16561656
}
16571657
}
16581658

0 commit comments

Comments
 (0)