Skip to content

Commit a006dda

Browse files
pratikasharZuul
authored andcommitted
First checkin for spill/fill intrinsics. This change doesnt modify generated code. Future change will take advantage of this patch.
Change-Id: I0994c9167a7f17f9ccac895abf4e050e886ad03e
1 parent 970143f commit a006dda

File tree

6 files changed

+429
-1
lines changed

6 files changed

+429
-1
lines changed

visa/BuildIR.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,34 @@ class IR_Builder {
10981098
return inst;
10991099
}
11001100

1101+
G4_INST* createSpill(G4_SrcRegRegion* payload, uint16_t numRows, uint32_t offset, G4_Declare* fp, G4_InstOption option,
1102+
unsigned int lineno = 0, int CISAoff = -1, const char* srcFilename = nullptr)
1103+
{
1104+
auto builtInR0 = getBuiltinR0();
1105+
auto rd = getRegionStride1();
1106+
auto srcRgnr0 = createSrcRegRegion(Mod_src_undef, Direct, builtInR0->getRegVar(), 0, 0, rd, Type_UD);
1107+
G4_INST* spill = createInternalIntrinsicInst(nullptr, Intrinsic::Spill, 1, createNullDst(G4_Type::Type_UD),
1108+
srcRgnr0, payload, nullptr, option, lineno, CISAoff, srcFilename);
1109+
spill->asSpillIntrinsic()->setFP(fp);
1110+
spill->asSpillIntrinsic()->setOffset(offset);
1111+
spill->asSpillIntrinsic()->setNumRows(numRows);
1112+
return spill;
1113+
}
1114+
1115+
G4_INST* createFill(G4_DstRegRegion* dstData, uint16_t numRows, uint32_t offset, G4_Declare* fp , G4_InstOption option,
1116+
unsigned int lineno = 0, int CISAoff = -1, const char* srcFilename = nullptr)
1117+
{
1118+
auto builtInR0 = getBuiltinR0();
1119+
auto rd = getRegionStride1();
1120+
auto srcRgnr0 = createSrcRegRegion(Mod_src_undef, Direct, builtInR0->getRegVar(), 0, 0, rd, Type_UD);
1121+
G4_INST* fill = createInternalIntrinsicInst(nullptr, Intrinsic::Fill, 1, dstData,
1122+
srcRgnr0, nullptr, nullptr, option, lineno, CISAoff, srcFilename);
1123+
fill->asFillIntrinsic()->setFP(fp);
1124+
fill->asFillIntrinsic()->setOffset(offset);
1125+
fill->asFillIntrinsic()->setNumRows(numRows);
1126+
return fill;
1127+
}
1128+
11011129
/* numberOfFlags MEANS NUMBER OF WORDS (e.g., 1 means 16-bit), not number of bits or number of data elements in operands. */
11021130
G4_Declare* createTempFlag(unsigned short numberOfFlags, const char* prefix = "TEMP_FLAG_" )
11031131
{

visa/BuildIRImpl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,14 @@ G4_INST* IR_Builder::createIntrinsicInst(G4_Predicate* prd, Intrinsic intrinId,
673673
G4_Operand* src0, G4_Operand* src1, G4_Operand* src2,
674674
unsigned int option, int lineno, bool addToInstList)
675675
{
676-
G4_INST* i = new (mem) G4_InstIntrinsic(*this, prd, intrinId, size, dst, src0, src1, src2, option);
676+
G4_INST* i = nullptr;
677+
678+
if(intrinId == Intrinsic::Spill)
679+
i = new (mem) G4_SpillIntrinsic(*this, prd, intrinId, size, dst, src0, src1, src2, option);
680+
else if(intrinId == Intrinsic::Fill)
681+
i = new (mem) G4_FillIntrinsic(*this, prd, intrinId, size, dst, src0, src1, src2, option);
682+
else
683+
i = new (mem) G4_InstIntrinsic(*this, prd, intrinId, size, dst, src0, src1, src2, option);
677684

678685
if (addToInstList)
679686
{

visa/Gen4_IR.hpp

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ class IR_Builder;
173173
class LocalLiveRange;
174174
class G4_Kernel;
175175
class G4_VarBase;
176+
177+
class G4_SpillIntrinsic;
178+
class G4_FillIntrinsic;
176179
}
177180
void associateOpndWithInst(vISA::G4_Operand*, vISA::G4_INST*);
178181

@@ -607,6 +610,10 @@ class G4_INST
607610
bool supportsNullDst() const;
608611

609612
bool isPseudoKill() const;
613+
bool isSpillIntrinsic() const;
614+
G4_SpillIntrinsic* asSpillIntrinsic() const;
615+
bool isFillIntrinsic() const;
616+
G4_FillIntrinsic* asFillIntrinsic() const;
610617
bool isLifeTimeEnd() const { return op == G4_pseudo_lifetime_end; }
611618
bool isMov() const { return G4_Inst_Table[op].instType == InstTypeMov; }
612619
bool isLogic() const { return G4_Inst_Table[op].instType == InstTypeLogic; }
@@ -1374,6 +1381,8 @@ enum class Intrinsic
13741381
Use,
13751382
MemFence,
13761383
PseudoKill,
1384+
Spill,
1385+
Fill,
13771386
NumIntrinsics
13781387
};
13791388

@@ -3753,6 +3762,28 @@ inline bool G4_INST::isPseudoKill() const
37533762
return isIntrinsic() && asIntrinsicInst()->getIntrinsicId() == Intrinsic::PseudoKill;
37543763
}
37553764

3765+
inline bool G4_INST::isSpillIntrinsic() const
3766+
{
3767+
return isIntrinsic() && asIntrinsicInst()->getIntrinsicId() == Intrinsic::Spill;
3768+
}
3769+
3770+
inline G4_SpillIntrinsic* G4_INST::asSpillIntrinsic() const
3771+
{
3772+
MUST_BE_TRUE(isSpillIntrinsic(), "not a spill intrinsic");
3773+
return const_cast<G4_SpillIntrinsic*>(reinterpret_cast<const G4_SpillIntrinsic*>(this));
3774+
}
3775+
3776+
inline bool G4_INST::isFillIntrinsic() const
3777+
{
3778+
return isIntrinsic() && asIntrinsicInst()->getIntrinsicId() == Intrinsic::Fill;
3779+
}
3780+
3781+
inline G4_FillIntrinsic* G4_INST::asFillIntrinsic() const
3782+
{
3783+
MUST_BE_TRUE(isFillIntrinsic(), "not a fill intrinsic");
3784+
return const_cast<G4_FillIntrinsic*>(reinterpret_cast<const G4_FillIntrinsic*>(this));
3785+
}
3786+
37563787
inline const char* G4_INST::getLabelStr() const
37573788
{
37583789
MUST_BE_TRUE(srcs[0] != NULL && srcs[0]->isLabel(), ERROR_UNKNOWN);
@@ -3787,6 +3818,74 @@ inline const char* G4_InstCF::getUipLabelStr() const
37873818
return uip->asLabel()->getLabel();
37883819
}
37893820

3821+
class G4_SpillIntrinsic : public G4_InstIntrinsic
3822+
{
3823+
public:
3824+
G4_SpillIntrinsic(
3825+
const IR_Builder& builder,
3826+
G4_Predicate* prd,
3827+
Intrinsic intrinId,
3828+
uint8_t size,
3829+
G4_DstRegRegion* d,
3830+
G4_Operand* s0,
3831+
G4_Operand* s1,
3832+
G4_Operand* s2,
3833+
unsigned int opt) :
3834+
G4_InstIntrinsic(builder, prd, intrinId, size, d, s0, s1, s2, opt)
3835+
{
3836+
3837+
}
3838+
3839+
bool isOffBP() const { return getFP() != nullptr; }
3840+
3841+
uint32_t getNumRows() const { return numRows; }
3842+
uint32_t getOffset() const { return offset; }
3843+
G4_Declare* getFP() const { return fp; }
3844+
3845+
void setNumRows(uint32_t r) { numRows = r; }
3846+
void setOffset(uint32_t o) { offset = o; }
3847+
void setFP(G4_Declare* f) { fp = f; }
3848+
3849+
private:
3850+
G4_Declare* fp = nullptr;
3851+
uint32_t numRows = 0;
3852+
uint32_t offset = 0;
3853+
};
3854+
3855+
class G4_FillIntrinsic : public G4_InstIntrinsic
3856+
{
3857+
public:
3858+
G4_FillIntrinsic(
3859+
const IR_Builder& builder,
3860+
G4_Predicate* prd,
3861+
Intrinsic intrinId,
3862+
uint8_t size,
3863+
G4_DstRegRegion* d,
3864+
G4_Operand* s0,
3865+
G4_Operand* s1,
3866+
G4_Operand* s2,
3867+
unsigned int opt) :
3868+
G4_InstIntrinsic(builder, prd, intrinId, size, d, s0, s1, s2, opt)
3869+
{
3870+
3871+
}
3872+
3873+
bool isOffBP() const { return getFP() != nullptr; }
3874+
3875+
uint32_t getNumRows() const { return numRows; }
3876+
uint32_t getOffset() const { return offset; }
3877+
G4_Declare* getFP() const { return fp; }
3878+
3879+
void setNumRows(uint32_t r) { numRows = r; }
3880+
void setOffset(uint32_t o) { offset = o; }
3881+
void setFP(G4_Declare* f) { fp = f; }
3882+
3883+
private:
3884+
G4_Declare* fp = nullptr;
3885+
uint32_t numRows = 0;
3886+
uint32_t offset = 0;
3887+
};
3888+
37903889
} // namespace vISA
37913890

37923891
#endif

visa/GraphColor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9048,6 +9048,8 @@ int GlobalRA::coloringRegAlloc()
90489048
coloring.addSaveRestoreCode(localSpillAreaOwordSize);
90499049
}
90509050

9051+
//expandSpillFillIntrinsics();
9052+
90519053
if (builder.getOption(vISA_OptReport))
90529054
{
90539055
detectUndefinedUses(liveAnalysis, kernel);

visa/GraphColor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ namespace vISA
706706
void markBlockLocalVars();
707707
void computePhyReg();
708708
void fixAlignment();
709+
void expandSpillIntrinsic(G4_BB*);
710+
void expandFillIntrinsic(G4_BB*);
711+
void expandSpillFillIntrinsics();
709712

710713
RAVarInfo defaultValues;
711714
std::vector<RAVarInfo> vars;

0 commit comments

Comments
 (0)