Skip to content

Commit bd4f7d0

Browse files
weiyu-chengfxbot
authored andcommitted
refactor G4_INST to get rid of two fields
Change-Id: I6d5daf4f78aff76f73b6df76f6c3f62c10962dba
1 parent 57f5832 commit bd4f7d0

File tree

5 files changed

+39
-66
lines changed

5 files changed

+39
-66
lines changed

visa/BinaryEncodingIGA.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ void BinaryEncodingIGA::DoAll()
452452
IGAKernel->appendBlock(currBB);
453453
continue;
454454
}
455-
++IGAInstId;
456455
Instruction *igaInst = nullptr;
457456
auto igaOpcode = getIGAOp(inst->opcode(), inst);
458457
// common fields: op, predicate, flag reg, exec size, exec mask offset, mask ctrl, conditional modifier
@@ -535,7 +534,7 @@ void BinaryEncodingIGA::DoAll()
535534
condModifier);
536535
}
537536

538-
igaInst->setID(inst->getId());
537+
igaInst->setID(IGAInstId++);
539538
if (opSpec->supportsDestination())
540539
{
541540
assert(inst->getDst() && "dst must not be null");

visa/BuildIRImpl.cpp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ G4_INST* IR_Builder::createInst(G4_Predicate* prd,
231231
G4_INST* i = NULL;
232232
if (G4_Inst_Table[op].instType == InstTypeFlow)
233233
{
234-
i = new (mem)G4_InstCF(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, option);
234+
i = new (mem)G4_InstCF(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, option);
235235
}
236236
else
237237
{
238-
i = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, option);
238+
i = new (mem)G4_INST(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, option);
239239
}
240240

241241
i->setCISAOff(curCISAOffset);
@@ -245,6 +245,7 @@ G4_INST* IR_Builder::createInst(G4_Predicate* prd,
245245
i->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
246246
}
247247

248+
instAllocList.push_back(i);
248249
instList.push_back(i);
249250

250251
return i;
@@ -282,11 +283,11 @@ G4_INST* IR_Builder::createInternalInst(G4_Predicate* prd,
282283

283284
if (G4_Inst_Table[op].instType == InstTypeFlow)
284285
{
285-
i = new (mem)G4_InstCF(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, option);
286+
i = new (mem)G4_InstCF(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, option);
286287
}
287288
else
288289
{
289-
i = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, option);
290+
i = new (mem)G4_INST(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, option);
290291
}
291292

292293
i->setCISAOff(CISAoff);
@@ -296,6 +297,7 @@ G4_INST* IR_Builder::createInternalInst(G4_Predicate* prd,
296297
i->setLocation(new (mem) MDLocation(lineno, curFile));
297298
}
298299

300+
instAllocList.push_back(i);
299301
return i;
300302
}
301303

@@ -314,7 +316,7 @@ G4_INST* IR_Builder::createInternalCFInst(
314316
MUST_BE_TRUE(G4_Inst_Table[op].instType == InstTypeFlow,
315317
"IR_Builder::createInternalCFInst must be used with InstTypeFlow instruction class");
316318

317-
G4_InstCF* i = new (mem)G4_InstCF(useDefAllocator, instAllocList, prd, op, NULL, false, size, NULL, NULL, NULL, option);
319+
G4_InstCF* i = new (mem)G4_InstCF(useDefAllocator, prd, op, NULL, false, size, NULL, NULL, NULL, option);
318320

319321
i->setJip( jip );
320322
i->setUip( uip );
@@ -326,6 +328,7 @@ G4_INST* IR_Builder::createInternalCFInst(
326328
i->setLocation(new (mem) MDLocation(lineno, curFile));
327329
}
328330

331+
instAllocList.push_back(i);
329332
return i;
330333
}
331334

@@ -361,11 +364,11 @@ G4_INST* IR_Builder::createInst(G4_Predicate* prd,
361364

362365
if (G4_Inst_Table[op].instType == InstTypeFlow)
363366
{
364-
i = new (mem)G4_InstCF(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, src2, option);
367+
i = new (mem)G4_InstCF(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, src2, option);
365368
}
366369
else
367370
{
368-
i = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, src2, option);
371+
i = new (mem)G4_INST(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, src2, option);
369372
}
370373

371374
i->setCISAOff(curCISAOffset);
@@ -375,6 +378,7 @@ G4_INST* IR_Builder::createInst(G4_Predicate* prd,
375378
i->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
376379
}
377380

381+
instAllocList.push_back(i);
378382
instList.push_back(i);
379383

380384
return i;
@@ -411,11 +415,11 @@ G4_INST* IR_Builder::createInternalInst(G4_Predicate* prd,
411415
G4_INST* i = NULL;
412416
if (G4_Inst_Table[op].instType == InstTypeFlow)
413417
{
414-
i = new (mem)G4_InstCF(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, src2, option);
418+
i = new (mem)G4_InstCF(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, src2, option);
415419
}
416420
else
417421
{
418-
i = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, mod, sat, size, dst, src0, src1, src2, option);
422+
i = new (mem)G4_INST(useDefAllocator, prd, op, mod, sat, size, dst, src0, src1, src2, option);
419423
}
420424

421425
i->setCISAOff(CISAoff);
@@ -425,6 +429,7 @@ G4_INST* IR_Builder::createInternalInst(G4_Predicate* prd,
425429
i->setLocation(new (mem) MDLocation(lineno, curFile));
426430
}
427431

432+
instAllocList.push_back(i);
428433
return i;
429434
}
430435

@@ -441,7 +446,7 @@ G4_INST* IR_Builder::createSendInst(G4_Predicate* prd,
441446
{
442447

443448
assert (msgDesc && "msgDesc must not be null");
444-
G4_INST* m = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, NULL, false, size, postDst, currSrc, msg, option);
449+
G4_INST* m = new (mem)G4_INST(useDefAllocator, prd, op, NULL, false, size, postDst, currSrc, msg, option);
445450

446451
///used in binary encoding
447452
m->setMsgDesc( msgDesc );
@@ -453,6 +458,7 @@ G4_INST* IR_Builder::createSendInst(G4_Predicate* prd,
453458
m->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
454459
}
455460

461+
instAllocList.push_back(m);
456462
instList.push_back(m);
457463
return m;
458464
}
@@ -482,7 +488,7 @@ G4_INST* IR_Builder::createSplitSendInst(G4_Predicate* prd,
482488
MUST_BE_TRUE(msgDesc->extMessageLength() == 0, "src1 length must be 0 if it is null");
483489
src1 = createNullSrc(Type_UD);
484490
}
485-
G4_INST* m = new (mem)G4_INST(useDefAllocator, instAllocList, prd, op, NULL, false, size, dst, src0, src1, msg, option);
491+
G4_INST* m = new (mem)G4_INST(useDefAllocator, prd, op, NULL, false, size, dst, src0, src1, msg, option);
486492

487493
m->setMsgDesc( msgDesc );
488494

@@ -492,16 +498,11 @@ G4_INST* IR_Builder::createSplitSendInst(G4_Predicate* prd,
492498
{
493499
m->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
494500
}
501+
m->setSrc(src3 ? src3 : createImm(msgDesc->getExtendedDesc(), Type_UD), 3);
495502

503+
instAllocList.push_back(m);
496504
instList.push_back(m);
497-
if (src3 != NULL)
498-
{
499-
m->setSrc(src3, 3);
500-
}
501-
else
502-
{
503-
m->setSrc(createImm(msgDesc->getExtendedDesc(), Type_UD), 3);
504-
}
505+
505506
return m;
506507
}
507508
//
@@ -520,7 +521,7 @@ G4_INST* IR_Builder::createMathInst(G4_Predicate* prd,
520521
unsigned int option,
521522
int lineno)
522523
{
523-
G4_INST* i = new (mem)G4_InstMath(useDefAllocator, instAllocList, prd, G4_math, NULL, sat, size, dst, src0, src1, option, mathOp);
524+
G4_INST* i = new (mem)G4_InstMath(useDefAllocator, prd, G4_math, NULL, sat, size, dst, src0, src1, option, mathOp);
524525

525526
i->setCISAOff(curCISAOffset);
526527

@@ -529,6 +530,7 @@ G4_INST* IR_Builder::createMathInst(G4_Predicate* prd,
529530
i->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
530531
}
531532

533+
instAllocList.push_back(i);
532534
instList.push_back(i);
533535
return i;
534536
}
@@ -538,7 +540,7 @@ G4_INST* IR_Builder::createIntrinsicInst(G4_Predicate* prd, Intrinsic intrinId,
538540
G4_Operand* src0, G4_Operand* src1, G4_Operand* src2,
539541
unsigned int option, int lineno)
540542
{
541-
G4_INST* i = new (mem) G4_InstIntrinsic(useDefAllocator, instAllocList, prd, intrinId, size, dst, src0, src1, src2, option);
543+
G4_INST* i = new (mem) G4_InstIntrinsic(useDefAllocator, prd, intrinId, size, dst, src0, src1, src2, option);
542544

543545
i->setCISAOff(curCISAOffset);
544546

@@ -547,6 +549,7 @@ G4_INST* IR_Builder::createIntrinsicInst(G4_Predicate* prd, Intrinsic intrinId,
547549
i->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
548550
}
549551

552+
instAllocList.push_back(i);
550553
instList.push_back(i);
551554
return i;
552555
}
@@ -556,7 +559,7 @@ G4_INST* IR_Builder::createInternalIntrinsicInst(G4_Predicate* prd, Intrinsic in
556559
G4_Operand* src0, G4_Operand* src1, G4_Operand* src2,
557560
unsigned int option, int lineno)
558561
{
559-
G4_INST* i = new (mem) G4_InstIntrinsic(useDefAllocator, instAllocList, prd, intrinId, size, dst, src0, src1, src2, option);
562+
G4_INST* i = new (mem) G4_InstIntrinsic(useDefAllocator, prd, intrinId, size, dst, src0, src1, src2, option);
560563

561564
i->setCISAOff(curCISAOffset);
562565

@@ -565,6 +568,7 @@ G4_INST* IR_Builder::createInternalIntrinsicInst(G4_Predicate* prd, Intrinsic in
565568
i->setLocation(new (mem) MDLocation(lineno == 0 ? curLine : lineno, curFile));
566569
}
567570

571+
instAllocList.push_back(i);
568572
return i;
569573
}
570574

visa/FlowGraph.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,7 +3836,6 @@ void G4_Kernel::dumpDotFileInternal(const char* appendix)
38363836
std::replace_if(dotStr.begin(), dotStr.end(), bind2nd(equal_to<char>(), '&'), '$');
38373837
ofile << dotStr;
38383838

3839-
ofile << " %" << (*i)->getId();
38403839
ofile << "</FONT></TD></TR>" << std::endl;
38413840
//ofile << "\\l"; // left adjusted
38423841
}
@@ -4637,7 +4636,7 @@ void G4_BB::emitBankConflict(std::ostream& output, G4_INST *inst)
46374636

46384637

46394638

4640-
static void emitInstId(std::ostream& output, int srcLine, int vISAId, int genId, uint64_t pc)
4639+
static void emitInstId(std::ostream& output, int srcLine, int vISAId, uint32_t genId, uint64_t pc)
46414640
{
46424641
if (srcLine != 0)
46434642
{
@@ -4666,7 +4665,7 @@ void G4_BB::emitBasicInstructionIga(char* instSyntax, std::ostream& output, INST
46664665
if (!inst->isLabel() && inst->opcode() < G4_NUM_OPCODE)
46674666
{
46684667
output << " //";
4669-
emitInstId(output, inst->getLineNo(), inst->getCISAOff(), inst->getGlobalID(), inst->getGenOffset());
4668+
emitInstId(output, inst->getLineNo(), inst->getCISAOff(), inst->getLexicalId(), inst->getGenOffset());
46704669

46714670
emitBankConflict(output, inst);
46724671
}
@@ -4684,7 +4683,7 @@ void G4_BB::emitBasicInstruction(std::ostream& output, INST_LIST_ITER &it)
46844683
SendInst->emit_send(output);
46854684

46864685
output << " //";
4687-
emitInstId(output, SendInst->getLineNo(), SendInst->getCISAOff(), SendInst->getGlobalID(), SendInst->getGenOffset());
4686+
emitInstId(output, SendInst->getLineNo(), SendInst->getCISAOff(), SendInst->getLexicalId(), SendInst->getGenOffset());
46884687
(*it)->emit_send_desc(output);
46894688
}
46904689
else
@@ -4697,7 +4696,7 @@ void G4_BB::emitBasicInstruction(std::ostream& output, INST_LIST_ITER &it)
46974696
if ((*it)->isLabel() == false)
46984697
{
46994698
output << " //";
4700-
emitInstId(output, inst->getLineNo(), inst->getCISAOff(), inst->getGlobalID(), inst->getGenOffset());
4699+
emitInstId(output, inst->getLineNo(), inst->getCISAOff(), inst->getLexicalId(), inst->getGenOffset());
47014700
emitBankConflict(output, inst);
47024701
}
47034702
}

visa/Gen4_IR.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ bool G4_SendMsgDescriptor::isSLMMessage() const
458458
}
459459

460460
G4_INST::G4_INST(USE_DEF_ALLOCATOR& allocator,
461-
std::vector<G4_INST*>& instList,
462461
G4_Predicate* prd,
463462
G4_opcode o,
464463
G4_CondMod* m,
@@ -472,7 +471,7 @@ G4_INST::G4_INST(USE_DEF_ALLOCATOR& allocator,
472471
local_id(0),
473472
srcCISAoff(-1),
474473
sat(s), scratch(false), evenlySplitInst(false),
475-
execSize(size), bin(0), global_id(-1),
474+
execSize(size), bin(0),
476475
useInstList(allocator),
477476
defInstList(allocator),
478477
location(NULL)
@@ -482,7 +481,6 @@ G4_INST::G4_INST(USE_DEF_ALLOCATOR& allocator,
482481
srcs[2] = nullptr;
483482
srcs[3] = nullptr;
484483

485-
m_Transient.ra.lexicalId = 0;
486484
dead = false;
487485
implAccSrc = nullptr;
488486
implAccDst = nullptr;
@@ -496,14 +494,10 @@ G4_INST::G4_INST(USE_DEF_ALLOCATOR& allocator,
496494
associateOpndWithInst(dst, this);
497495
associateOpndWithInst(s0, this);
498496
associateOpndWithInst(s1, this);
499-
500-
id = (int)instList.size();
501-
instList.push_back(this);
502497
}
503498

504499
G4_INST::G4_INST(
505500
USE_DEF_ALLOCATOR& allocator,
506-
std::vector<G4_INST*>& instList,
507501
G4_Predicate* prd,
508502
G4_opcode o,
509503
G4_CondMod* m,
@@ -516,7 +510,6 @@ G4_INST::G4_INST(
516510
unsigned int opt) :
517511
op(o), dst(d), predicate(prd), mod(m), option(opt), msgDesc(NULL),
518512
local_id(0),
519-
global_id(-1),
520513
srcCISAoff(-1),
521514
sat(s), scratch(false), evenlySplitInst(false),
522515
execSize(size), bin(0),
@@ -529,7 +522,6 @@ G4_INST::G4_INST(
529522
srcs[2] = s2;
530523
srcs[3] = nullptr;
531524

532-
m_Transient.ra.lexicalId = 0;
533525
dead = false;
534526
implAccSrc = nullptr;
535527
implAccDst = nullptr;
@@ -547,9 +539,6 @@ G4_INST::G4_INST(
547539
associateOpndWithInst(s2, this);
548540
associateOpndWithInst((G4_Operand*)predicate, this);
549541
associateOpndWithInst((G4_Operand*)mod, this);
550-
551-
id = (int)instList.size();
552-
instList.push_back(this);
553542
}
554543

555544
void G4_INST::setOpcode(G4_opcode opcd)

0 commit comments

Comments
 (0)