Skip to content

Commit d230343

Browse files
houjenkosys_zuul
authored andcommitted
[IGC Feature][CodePatch] Maintain mapping VISA->LLVM
Change-Id: Ic742d837343dc8c0c126145e596f7ca3b262b787
1 parent deda116 commit d230343

File tree

12 files changed

+39
-7
lines changed

12 files changed

+39
-7
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,7 @@ namespace IGC
37293729
{
37303730
params.push_back(param_uptr("-debug", literal_deleter));
37313731
}
3732+
37323733
if (context->getModuleMetaData()->compOpt.FastVISACompile)
37333734
{
37343735
params.push_back(param_uptr("-fasterRA", literal_deleter));
@@ -6087,6 +6088,11 @@ namespace IGC
60876088
V(vKernel->AppendVISADebugLinePlaceholder());
60886089
}
60896090

6091+
void CEncoder::SetCurrentInst(llvm::Instruction *inst)
6092+
{
6093+
V(vKernel->AppendVISALLVMInst(inst));
6094+
}
6095+
60906096

60916097
std::string CEncoder::GetVariableName(CVariable* var)
60926098
{

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ namespace IGC
233233
void File(std::string& s);
234234
void PredAdd(CVariable* flag, CVariable* dst, CVariable* src0, CVariable* src1);
235235
void DebugLinePlaceholder();
236+
void SetCurrentInst(llvm::Instruction *inst);
236237

237238
inline void Jump(uint label);
238239
inline void Cast(CVariable* dst, CVariable* src);

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ bool EmitPass::runOnFunction(llvm::Function& F)
628628
IF_DEBUG_INFO_IF(m_pDebugEmitter, m_pDebugEmitter->EndInstruction(llvmInst);)
629629
}
630630
}
631+
632+
m_encoder->SetCurrentInst(nullptr);
633+
631634
if (llvmtoVISADump)
632635
{
633636
if (block.bb->hasName())
@@ -9016,6 +9019,8 @@ void EmitPass::EmitNoModifier(llvm::Instruction* inst)
90169019
return;
90179020
}
90189021

9022+
m_encoder->SetCurrentInst(inst);
9023+
90199024
switch (inst->getOpcode())
90209025
{
90219026
case Instruction::Ret:

visa/BuildIR.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ class IR_Builder {
557557
input_info_t * getInputArg(unsigned int index);
558558
unsigned int getInputCount();
559559
input_info_t *getRetIPArg();
560+
const void* GetCurrentInst() const { return m_inst; };
561+
void SetCurrentInst(const void* inst) { m_inst = inst; };
560562

561563
const CISA_IR_Builder* getParent() const { return parentBuilder; }
562564
std::stringstream& criticalMsgStream();
@@ -898,6 +900,7 @@ class IR_Builder {
898900
use64BitFEStackVars(false), mem(m), phyregpool(m, k.getNumRegTotal()), hashtable(m), rgnpool(m), dclpool(m),
899901
instList(alloc), kernel(k)
900902
{
903+
m_inst = nullptr;
901904
num_general_dcl = 0;
902905
num_temp_dcl = 0;
903906
kernel.setBuilder(this); // kernel needs pointer to the builder
@@ -2756,6 +2759,7 @@ class IR_Builder {
27562759
#include "HWCaps.inc"
27572760

27582761
private:
2762+
const void* m_inst;
27592763
G4_SrcRegRegion* createBindlessExDesc(uint32_t exdesc);
27602764

27612765
int translateVISASLMByteScaledInst(

visa/FlowGraph.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5820,6 +5820,7 @@ void G4_BB::emitBasicInstructionIga(char* instSyntax, std::ostream& output, INST
58205820
}
58215821
void G4_BB::emitBasicInstruction(std::ostream& output, INST_LIST_ITER &it)
58225822
{
5823+
const void *llvmInst = (*it)->GetLLVMInst();
58235824
if ((*it)->isSend())
58245825
{
58255826
//

visa/Gen4_IR.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ G4_INST::G4_INST(const IR_Builder& irb,
755755
evenlySplitInst(false),
756756
execSize(size),
757757
bin(nullptr),
758-
builder(irb)
758+
builder(irb),
759+
llvmInst(irb.GetCurrentInst())
759760
{
760761
srcs[0] = s0;
761762
srcs[1] = s1;
@@ -798,7 +799,8 @@ G4_INST::G4_INST(const IR_Builder& irb,
798799
evenlySplitInst(false),
799800
execSize(size),
800801
bin(nullptr),
801-
builder(irb)
802+
builder(irb),
803+
llvmInst(irb.GetCurrentInst())
802804
{
803805
srcs[0] = s0;
804806
srcs[1] = s1;

visa/Gen4_IR.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ class G4_INST
547547
uint32_t global_id = (uint32_t) -1;
548548

549549
const IR_Builder& builder; // link to builder to access the various compilation options
550+
const void *llvmInst;
550551

551552
public:
553+
const void* GetLLVMInst() { return llvmInst; };
554+
G4_INST* InheritLLVMInst(G4_INST* i) { llvmInst = i->GetLLVMInst(); return this; };
552555
enum SWSBTokenType {
553556
TOKEN_NONE,
554557
AFTER_READ,

visa/HWConformity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7145,7 +7145,7 @@ static void expandPlaneMacro(IR_Builder& builder, INST_LIST_ITER it, G4_BB* bb,
71457145
builder.createDst(builder.phyregpool.getAcc0Reg(), 0, 0, 1, Type_NF) :
71467146
builder.Create_Dst_Opnd_From_Dcl(tmpVal, 1);
71477147
G4_INST* madInst = builder.createInternalInst(nullptr, G4_mad, nullptr, false, 8, accDst,
7148-
srcR, u, srcP, options | InstOpt_WriteEnable);
7148+
srcR, u, srcP, options | InstOpt_WriteEnable)->InheritLLVMInst(inst);
71497149
bb->insert(it, madInst);
71507150

71517151
G4_Predicate* pred = inst->getPredicate() ? builder.duplicateOperand(inst->getPredicate()) : nullptr;
@@ -7156,7 +7156,7 @@ static void expandPlaneMacro(IR_Builder& builder, INST_LIST_ITER it, G4_BB* bb,
71567156
G4_DstRegRegion* newDst = builder.createDst(dst->getBase(),
71577157
dst->getRegOff() + (secondHalf ? 1 : 0), dst->getSubRegOff(), dst->getHorzStride(), dst->getType());
71587158
G4_INST* secondMadInst = builder.createInternalInst(pred, G4_mad, condMod, inst->getSaturate(), 8, newDst,
7159-
accSrc, v, srcQ, options);
7159+
accSrc, v, srcQ, options)->InheritLLVMInst(inst);
71607160
bb->insert(it, secondMadInst);
71617161
}
71627162

visa/Optimizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,13 @@ void Optimizer::insertHashMovs()
442442
16,
443443
kernel.fg.builder->createNullDst(Type_UD),
444444
kernel.fg.builder->createImm((unsigned int)(hashVal & 0xffffffff), Type_UD),
445-
InstOpt_WriteEnable, false);
445+
InstOpt_WriteEnable, false)->InheritLLVMInst(inst);
446446

447447
hi = kernel.fg.builder->createMov(
448448
16,
449449
kernel.fg.builder->createNullDst(Type_UD),
450450
kernel.fg.builder->createImm((unsigned int)((hashVal >> 32) & 0xffffffff), Type_UD),
451-
InstOpt_WriteEnable, false);
451+
InstOpt_WriteEnable, false)->InheritLLVMInst(inst);
452452

453453
bb->push_back(lo);
454454
bb->push_back(hi);
@@ -6874,7 +6874,7 @@ bool Optimizer::foldPseudoAndOr(G4_BB* bb, INST_LIST_ITER& ii)
68746874
// insert "(W) mov(16) acc0.0:f 0x0:f" before EOT
68756875
G4_INST* movInst = builder.createMov(16,
68766876
builder.createDst(builder.phyregpool.getAcc0Reg(),0, 0, 1, Type_F),
6877-
builder.createImm(0, Type_F), InstOpt_WriteEnable, false);
6877+
builder.createImm(0, Type_F), InstOpt_WriteEnable, false)->InheritLLVMInst(inst);
68786878
// insert mov before contiguous send, in case that there are instruction combined set on continuous
68796879
// two send
68806880
INST_LIST_ITER insert_point = ii;

visa/VISAKernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ class VISAKernelImpl : public VISAFunction
476476

477477
VISA_BUILDER_API int AppendVISADebugLinePlaceholder();
478478

479+
VISA_BUILDER_API int AppendVISALLVMInst(void *inst);
480+
479481
VISA_BUILDER_API int AppendVISAMiscRawSend(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, unsigned char modifiers,
480482
unsigned int exMsgDesc, unsigned char srcSize, unsigned char dstSize, VISA_VectorOpnd *desc,
481483
VISA_RawOpnd *src, VISA_RawOpnd *dst);

0 commit comments

Comments
 (0)