Skip to content

Commit 6f80c8a

Browse files
bcheng0127igcbot
authored andcommitted
new varaible type support
new varaible type support
1 parent e954fa8 commit 6f80c8a

File tree

8 files changed

+269
-32
lines changed

8 files changed

+269
-32
lines changed

visa/BuildIR.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ class IR_Builder
800800
// which are all allocated as a UW. name is allocated by caller
801801
G4_Declare* createFlag(uint16_t numFlagElements, const char* name);
802802

803+
G4_Declare* createTempScalar(uint16_t numFlagElements, const char* prefix);
804+
805+
G4_Declare* createScalar(uint16_t numFlagElements, const char* name);
806+
803807
G4_Declare* createPreVar(
804808
PreDefinedVarsInternal preDefVar_index, unsigned short numElements, G4_Type type);
805809

@@ -1259,6 +1263,8 @@ class IR_Builder
12591263
G4_DstRegRegion* dst, G4_Operand* src0, G4_Operand* src1, G4_Operand* src2,
12601264
G4_InstOpts options);
12611265

1266+
G4_INST* createIntrinsicAddrMovInst(Intrinsic intrinId, G4_DstRegRegion* dst, G4_Operand* src0, G4_Operand* src1, G4_Operand* src2, G4_Operand* src3, G4_Operand* src4, G4_Operand* src5, G4_Operand* src6, G4_Operand* src7, bool addToInstList);
1267+
12621268
G4_INST* createNop(G4_InstOpts options);
12631269
G4_INST* createSync(G4_opcode syncOp, G4_Operand* src);
12641270

visa/BuildIRImpl.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ G4_Declare* DeclarePool::createDeclare(
6363
}
6464
dcl->setRegVar(regVar);
6565

66-
if (regFile == G4_ADDRESS)
66+
if (regFile == G4_ADDRESS || regFile == G4_SCALAR)
6767
{
6868
dcl->setSubRegAlign(Any);
6969
}
@@ -679,6 +679,7 @@ void IR_Builder::createBuiltinDecls()
679679
1,
680680
Type_UD);
681681
builtinA0->getRegVar()->setPhyReg(phyregpool.getAddrReg(), 0);
682+
682683
builtinA0Dot2 = createDeclareNoLookup(
683684
"BuiltinA0Dot2", //a0.2
684685
G4_ADDRESS,
@@ -1072,6 +1073,19 @@ G4_Declare* IR_Builder::createFlag(uint16_t numFlagElements, const char* name)
10721073
return dcl;
10731074
}
10741075

1076+
G4_Declare* IR_Builder::createTempScalar(uint16_t numFlagElements, const char* prefix)
1077+
{
1078+
const char* name = getNameString(mem, 20, "%s%d", prefix, num_temp_dcl++);
1079+
G4_Declare* dcl = createDeclareNoLookup(name, G4_SCALAR, numFlagElements, 1, Type_UB);
1080+
return dcl;
1081+
}
1082+
1083+
G4_Declare* IR_Builder::createScalar(uint16_t numFlagElements, const char* name)
1084+
{
1085+
G4_Declare* dcl = createDeclareNoLookup(name, G4_SCALAR, numFlagElements, 1, Type_UB);
1086+
return dcl;
1087+
}
1088+
10751089
G4_Declare* IR_Builder::createPreVar(
10761090
PreDefinedVarsInternal preDefVar_index, unsigned short numElements, G4_Type type)
10771091
{
@@ -2128,6 +2142,35 @@ G4_INST* IR_Builder::createInternalIntrinsicInst(
21282142
return ii;
21292143
}
21302144

2145+
G4_INST* IR_Builder::createIntrinsicAddrMovInst(
2146+
Intrinsic intrinId,
2147+
G4_DstRegRegion* dst,
2148+
G4_Operand* src0, G4_Operand* src1, G4_Operand* src2, G4_Operand* src3,
2149+
G4_Operand* src4, G4_Operand* src5, G4_Operand* src6, G4_Operand* src7,
2150+
bool addToInstList)
2151+
{
2152+
G4_INST* i = nullptr;
2153+
assert(intrinId == Intrinsic::PseudoAddrMov && "expect pseudo_mov op");
2154+
2155+
i = new (mem) G4_PseudoAddrMovIntrinsic(*this, intrinId, dst, src0, src1, src2, src3, src4, src5, src6, src7);
2156+
2157+
if (addToInstList)
2158+
{
2159+
i->setCISAOff(curCISAOffset);
2160+
2161+
if (m_options->getOption(vISA_EmitLocation))
2162+
{
2163+
i->setLocation(allocateMDLocation(curLine, curFile));
2164+
}
2165+
2166+
instList.push_back(i);
2167+
}
2168+
2169+
instAllocList.push_back(i);
2170+
2171+
return i;
2172+
}
2173+
21312174
G4_MathOp IR_Builder::Get_MathFuncCtrl(ISA_Opcode op, G4_Type type)
21322175
{
21332176
switch (op)

visa/G4_IR.cpp

Lines changed: 111 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,10 @@ G4_Type G4_INST::getExecType() const
381381

382382
for (unsigned i = 0; i < G4_MAX_SRCS; i++)
383383
{
384-
if (srcs[i] != NULL)
384+
G4_Operand* src = getSrc(i);
385+
if (src != NULL)
385386
{
386-
G4_Type srcType = srcs[i]->getType();
387+
G4_Type srcType = src->getType();
387388
if (TypeSize(srcType) >= TypeSize(execType))
388389
{
389390
if (IS_DTYPE(srcType))
@@ -435,7 +436,8 @@ G4_Type G4_INST::getExecType2() const
435436

436437
for (unsigned i = 0; i < G4_MAX_SRCS; i++)
437438
{
438-
if (srcs[i] == NULL)
439+
G4_Operand* src = getSrc(i);
440+
if (src == NULL)
439441
{
440442
continue;
441443
}
@@ -462,7 +464,7 @@ G4_Type G4_INST::getExecType2() const
462464
}
463465
else if (IS_DFTYPE(srcType) && !IS_DFTYPE(execType))
464466
{
465-
execType = srcs[i]->getType();
467+
execType = src->getType();
466468
break;
467469
}
468470
else if ((IS_FTYPE(srcType) || srcType == Type_VF) &&
@@ -1018,6 +1020,7 @@ bool G4_INST::isJEUPipeInstructionXe() const
10181020
return false;
10191021
}
10201022

1023+
10211024
bool G4_INST::isLongPipeInstructionXe() const
10221025
{
10231026
if (isJEUPipeInstructionXe())
@@ -1036,6 +1039,7 @@ bool G4_INST::isLongPipeInstructionXe() const
10361039
return false;
10371040
}
10381041

1042+
10391043
const G4_Operand* dst = getDst();
10401044
if (dst && isLongPipeType(dst->getType()))
10411045
{
@@ -1074,6 +1078,7 @@ bool G4_INST::isIntegerPipeInstructionXe() const
10741078
return false;
10751079
}
10761080

1081+
10771082
if (builder.hasFixedCycleMathPipeline() &&
10781083
isMath())
10791084
{
@@ -1110,6 +1115,7 @@ bool G4_INST::isFloatPipeInstructionXe() const
11101115
return false;
11111116
}
11121117

1118+
11131119
if (isLongPipeInstructionXe())
11141120
{
11151121
return false;
@@ -1186,6 +1192,7 @@ SB_INST_PIPE G4_INST::getDataTypePipeXe(G4_Type type)
11861192

11871193
SB_INST_PIPE G4_INST::getInstructionPipeXe()
11881194
{
1195+
11891196
if (isLongPipeInstructionXe())
11901197
{
11911198
return PIPE_LONG;
@@ -3291,9 +3298,10 @@ bool G4_INST::isValidSymbolOperand(bool &dst_valid, bool *srcs_valid) const
32913298

32923299
for (unsigned i = 0; i < G4_MAX_SRCS; i++)
32933300
{
3294-
if (srcs[i] && srcs[i]->isSrcRegRegion() && srcs[i]->asSrcRegRegion()->getBase()->isRegVar())
3301+
G4_Operand* src = getSrc(i);
3302+
if (src && src->isSrcRegRegion() && src->asSrcRegRegion()->getBase()->isRegVar())
32953303
{
3296-
srcs_valid[i] = srcs[i]->asSrcRegRegion()->obeySymbolRegRule();
3304+
srcs_valid[i] = src->asSrcRegRegion()->obeySymbolRegRule();
32973305
if (!srcs_valid[i])
32983306
obeyRule = false;
32993307
}
@@ -3343,15 +3351,15 @@ bool G4_INST::isOptBarrier() const
33433351

33443352
for (int i = 0; i < getNumSrc(); i++)
33453353
{
3346-
if (srcs[i])
3354+
if (getSrc(i))
33473355
{
3348-
if (srcs[i]->isAreg())
3356+
if (getSrc(i)->isAreg())
33493357
{
3350-
if (srcs[i]->isNReg() ||
3351-
srcs[i]->isSrReg() ||
3352-
srcs[i]->isCrReg() ||
3353-
srcs[i]->isTmReg() ||
3354-
srcs[i]->isTDRReg())
3358+
if (getSrc(i)->isNReg() ||
3359+
getSrc(i)->isSrReg() ||
3360+
getSrc(i)->isCrReg() ||
3361+
getSrc(i)->isTmReg() ||
3362+
getSrc(i)->isTDRReg())
33553363
{
33563364
return true;
33573365
}
@@ -3483,19 +3491,20 @@ void G4_INST::emit_inst(std::ostream& output, bool symbol_dst, bool *symbol_srcs
34833491
auto numSrcOpnds = getNumSrc();
34843492
for (int i = 0; i < numSrcOpnds; i++)
34853493
{
3486-
if (srcs[i])
3494+
if (getSrc(i))
34873495
{
34883496
output << " ";
34893497
if (symbol_srcs != NULL)
34903498
{
3491-
srcs[i]->emit(output, symbol_srcs[i]); // emit symbolic/physical register depends on the flag
3499+
getSrc(i)->emit(output, symbol_srcs[i]); // emit symbolic/physical register depends on the flag
34923500
}
34933501
else
34943502
{
3495-
srcs[i]->emit(output, false); // emit physical register
3503+
getSrc(i)->emit(output, false); // emit physical register
34963504
}
34973505
}
34983506
}
3507+
34993508
if (isFillIntrinsic())
35003509
{
35013510
output << " ";
@@ -3622,7 +3631,7 @@ void G4_INST::emit_options(std::ostream& output) const
36223631

36233632
////////////////////////////////////////////////////////////
36243633
// SWSB options
3625-
if (distanceHonourInstruction() && getDistance() != 0) {
3634+
if (getDistance() != 0) {
36263635
std::stringstream dists;
36273636
switch (getDistanceTypeXe()) {
36283637
case DistanceType::DIST: break;
@@ -4366,8 +4375,6 @@ void printRegVarOff(std::ostream& output,
43664375
}
43674376
else if (baseVar->getPhyReg()->isAreg())
43684377
{
4369-
MUST_BE_TRUE(regOff == 0, ERROR_INTERNAL_ARGUMENT);
4370-
43714378
(static_cast<G4_Areg*>(baseVar->getPhyReg()))->emit(output);
43724379
if (!baseVar->isNullReg())
43734380
{
@@ -4444,7 +4451,9 @@ void printRegVarOff(std::ostream& output,
44444451
{
44454452
(static_cast<G4_Areg*>(baseVar->getPhyReg()))->emit(output);
44464453
output << '.' << (baseVar->getPhyRegOff() + subRegOffset);
4447-
output << ", " << immAddrOff << ']';
4454+
{
4455+
output << ", " << immAddrOff << ']';
4456+
}
44484457
}
44494458
}
44504459
else //No register assigned yet
@@ -4458,7 +4467,9 @@ void printRegVarOff(std::ostream& output,
44584467
{
44594468
(static_cast<G4_Areg*>(base))->emit(output);
44604469
output << '.' << subRegOffset;
4461-
output << ", " << immAddrOff << ']';
4470+
{
4471+
output << ", " << immAddrOff << ']';
4472+
}
44624473
}
44634474
else
44644475
{
@@ -5559,6 +5570,10 @@ void G4_Declare::emit(std::ostream &output) const
55595570
{
55605571
output << 'a';
55615572
}
5573+
else if (regFile == G4_SCALAR)
5574+
{
5575+
output << 's';
5576+
}
55625577
else if (regFile == G4_FLAG)
55635578
{
55645579
output << 'f';
@@ -7049,6 +7064,12 @@ void G4_INST::setPredicate(G4_Predicate* p)
70497064

70507065
void G4_INST::setSrc(G4_Operand* opnd, unsigned i)
70517066
{
7067+
if (isPseudoAddrMovIntrinsic())
7068+
{
7069+
asIntrinsicInst()->setIntrinsicSrc(opnd, i);
7070+
return;
7071+
}
7072+
70527073
MUST_BE_TRUE(i < G4_MAX_SRCS, ERROR_INTERNAL_ARGUMENT);
70537074

70547075
if (srcs[i] != NULL)
@@ -8228,6 +8249,75 @@ G4_INST* G4_InstSend::cloneInst()
82288249
return newInst;
82298250
}
82308251

8252+
G4_InstIntrinsic::G4_InstIntrinsic(
8253+
const IR_Builder& builder,
8254+
G4_Predicate* prd,
8255+
Intrinsic intrinId,
8256+
G4_ExecSize execSize,
8257+
G4_DstRegRegion* d,
8258+
G4_Operand* s0,
8259+
G4_Operand* s1,
8260+
G4_Operand* s2,
8261+
G4_Operand* s3,
8262+
G4_Operand* s4,
8263+
G4_Operand* s5,
8264+
G4_Operand* s6,
8265+
G4_Operand* s7,
8266+
G4_InstOpts opt) :
8267+
G4_INST(builder, prd, G4_intrinsic, nullptr, g4::NOSAT, execSize, d, nullptr, nullptr, nullptr, opt),
8268+
intrinsicId(intrinId), tmpGRFStart(-1), tmpAddrStart(-1), tmpFlagStart(-1)
8269+
{
8270+
srcs[0] = s0;
8271+
srcs[1] = s1;
8272+
srcs[2] = s2;
8273+
srcs[3] = s3;
8274+
srcs[4] = s4;
8275+
srcs[5] = s5;
8276+
srcs[6] = s6;
8277+
srcs[7] = s7;
8278+
8279+
resetRightBound(s0);
8280+
resetRightBound(s1);
8281+
resetRightBound(s2);
8282+
resetRightBound(s3);
8283+
resetRightBound(s4);
8284+
resetRightBound(s5);
8285+
resetRightBound(s6);
8286+
resetRightBound(s7);
8287+
8288+
associateOpndWithInst(s0, this);
8289+
associateOpndWithInst(s1, this);
8290+
associateOpndWithInst(s2, this);
8291+
associateOpndWithInst(s3, this);
8292+
associateOpndWithInst(s4, this);
8293+
associateOpndWithInst(s5, this);
8294+
associateOpndWithInst(s6, this);
8295+
associateOpndWithInst(s7, this);
8296+
}
8297+
8298+
G4_Operand* G4_InstIntrinsic::getIntrinsicSrc(unsigned i) const
8299+
{
8300+
MUST_BE_TRUE(i < G4_MAX_INTRINSIC_SRCS, ERROR_INTERNAL_ARGUMENT);
8301+
return srcs[i];
8302+
}
8303+
8304+
void G4_InstIntrinsic::setIntrinsicSrc(G4_Operand* opnd, unsigned i)
8305+
{
8306+
MUST_BE_TRUE(i < G4_MAX_INTRINSIC_SRCS, ERROR_INTERNAL_ARGUMENT);
8307+
8308+
if (srcs[i] != NULL)
8309+
{
8310+
if (srcs[i]->getInst() == (G4_INST *)this)
8311+
{
8312+
srcs[i]->setInst(NULL);
8313+
}
8314+
}
8315+
srcs[i] = opnd;
8316+
8317+
associateOpndWithInst(opnd, (G4_INST*)this);
8318+
resetRightBound(opnd);
8319+
}
8320+
82318321
G4_INST* G4_InstIntrinsic::cloneInst()
82328322
{
82338323
auto nonConstBuilder = const_cast<IR_Builder*>(&builder);

0 commit comments

Comments
 (0)