Skip to content

Commit f247f07

Browse files
bcheng0127igcbot
authored andcommitted
LSC spill/fill support in linear scan RA
LSC spill/fill support in linear scan RA
1 parent 93091d0 commit f247f07

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

visa/LinearScanRA.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ int LinearScanRA::linearScanRA()
944944
eotLiveIntervals.clear();
945945
unsigned latestLexID = 0;
946946

947+
//Some live through intervals are implicit
948+
calculateLiveThroughIntervals();
947949
for (auto bb : kernel.fg)
948950
{
949951
calculateLiveIntervalsGlobal(bb, globalLiveIntervals, eotLiveIntervals);
@@ -975,11 +977,15 @@ int LinearScanRA::linearScanRA()
975977
COUT_ERROR << "===== preAssignedLiveIntervals============" << std::endl;
976978
printLiveIntervals(preAssignedLiveIntervals);
977979
#endif
980+
// Copy over alignment for vars inserted by RA
981+
gra.copyMissingAlignment();
982+
978983
PhyRegsManager pregManager(builder, initPregs, doBCR);
979984
globalLinearScan ra(gra, &l, globalLiveIntervals, &preAssignedLiveIntervals, inputIntervals, pregManager,
980985
mem, numRegLRA, numRowsEOT, latestLexID,
981986
doBCR, highInternalConflict);
982987

988+
//Run linear scan RA
983989
bool success = ra.runLinearScan(builder, globalLiveIntervals, spillLRs);
984990

985991
auto underSpillThreshold = [this](int numSpill, int asmCount)
@@ -1055,6 +1061,29 @@ int LinearScanRA::linearScanRA()
10551061
COUT_ERROR << "===== printSpillLiveIntervals============" << std::endl;
10561062
printSpillLiveIntervals(spillLRs);
10571063
#endif
1064+
if (builder.hasScratchSurface() && !hasStackCall &&
1065+
(nextSpillOffset + globalScratchOffset) > SCRATCH_MSG_LIMIT)
1066+
{
1067+
// create temp variable to store old a0.2 - this is marked as live-in and live-out.
1068+
// because the variable is emitted only post RA to preserve old value of a0.2.
1069+
G4_Declare * a0Dcl = kernel.fg.builder->getOldA0Dot2Temp();
1070+
LSLiveRange* lr = gra.getLSLR(a0Dcl);
1071+
if (!lr)
1072+
{
1073+
lr = CreateLocalLiveRange(a0Dcl);
1074+
globalDeclares.push_back(a0Dcl);
1075+
}
1076+
}
1077+
else if (gra.useLscForNonStackCallSpillFill) {
1078+
G4_Declare* a0Dcl = kernel.fg.builder->getOldA0Dot2Temp();
1079+
LSLiveRange* lr = gra.getLSLR(a0Dcl);
1080+
if (!lr)
1081+
{
1082+
lr = CreateLocalLiveRange(a0Dcl);
1083+
globalDeclares.push_back(a0Dcl);
1084+
}
1085+
}
1086+
10581087

10591088
// update jit metadata information for spill
10601089
if (auto jitInfo = builder.getJitInfo())
@@ -1794,6 +1823,33 @@ void LinearScanRA::calculateLiveOutIntervals(G4_BB* bb, std::vector<LSLiveRange*
17941823
return;
17951824
}
17961825

1826+
void LinearScanRA::calculateLiveThroughIntervals()
1827+
{
1828+
for (auto dcl : globalDeclares)
1829+
{
1830+
if (dcl->getAliasDeclare() != NULL ||
1831+
dcl->getRegFile() == G4_INPUT ||
1832+
dcl->isSpilled())
1833+
continue;
1834+
1835+
LSLiveRange* lr = gra.getLSLR(dcl);
1836+
if (lr &&
1837+
dcl->isInput() && dcl->isOutput() && !lr->isGRFRegAssigned())
1838+
{
1839+
lr->setFirstRef(nullptr, 0);
1840+
lr->setLastRef(nullptr, lastInstLexID * 2 + 1);
1841+
if (!lr->isPushedToIntervalList())
1842+
{
1843+
liveThroughIntervals.push_back(lr);
1844+
lr->setPushed(true);
1845+
}
1846+
}
1847+
}
1848+
1849+
return;
1850+
}
1851+
1852+
17971853
//
17981854
// Live intervals:
17991855
// 1. not input variables

visa/LinearScanRA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ namespace vISA
127127
void calculateLiveInIntervals(G4_BB* bb, std::vector<LSLiveRange*>& liveIntervals);
128128
void calculateCurrentBBLiveIntervals(G4_BB* bb, std::vector<LSLiveRange*>& liveIntervals, std::vector<LSLiveRange*>& eotLiveIntervals);
129129
void calculateLiveOutIntervals(G4_BB* bb, std::vector<LSLiveRange*>& liveIntervals);
130+
void calculateLiveThroughIntervals();
130131
void calculateLiveIntervalsGlobal(G4_BB* bb, std::vector<LSLiveRange*>& liveIntervals, std::vector<LSLiveRange*>& eotLiveIntervals);
131132
void printLiveIntervals(std::vector<LSLiveRange*>& liveIntervals);
132133
void printSpillLiveIntervals(std::list<LSLiveRange*>& liveIntervals);

0 commit comments

Comments
 (0)