Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,7 @@ void CodeGen::genJumpTable(GenTree* treeNode)
// Access to inline data is 'abstracted' by a special type of static member
// (produced by eeFindJitDataOffs) which the emitter recognizes as being a reference
// to constant data, not a real static field.
GetEmitter()->emitIns_R_C(INS_bl, emitActualTypeSize(TYP_I_IMPL), treeNode->GetRegNum(), REG_NA,
GetEmitter()->emitIns_R_C(INS_bl, EA_PTRSIZE, treeNode->GetRegNum(), REG_NA,
m_compiler->eeFindJitDataOffs(jmpTabBase), 0);
genProduceReg(treeNode);
}
Expand All @@ -2292,7 +2292,13 @@ void CodeGen::genJumpTable(GenTree* treeNode)
//
void CodeGen::genAsyncResumeInfo(GenTreeVal* treeNode)
{
GetEmitter()->emitIns_R_C(INS_bl, emitActualTypeSize(TYP_I_IMPL), treeNode->GetRegNum(), REG_NA,
emitAttr attr = EA_PTRSIZE;
if (m_compiler->eeDataWithCodePointersNeedsRelocs())
{
attr = EA_SET_FLG(EA_PTRSIZE, EA_CNS_RELOC_FLG);
}

GetEmitter()->emitIns_R_C(INS_bl, attr, treeNode->GetRegNum(), REG_NA,
genEmitAsyncResumeInfo((unsigned)treeNode->gtVal1), 0);
genProduceReg(treeNode);
}
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/jit/emitloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1972,8 +1972,8 @@ void emitter::emitIns_R_R_R_R(
/*****************************************************************************
*
* Add an instruction with a register + static member operands.
* Constant is stored into JIT data which is adjacent to code.
* For LOONGARCH64, maybe not the best, here just supports the func-interface.
* Usually constants are stored into JIT data adjacent to code, in which case no
* relocation is needed. PC-relative offset will be encoded directly into instruction.
*
*/
void emitter::emitIns_R_C(
Expand All @@ -2000,14 +2000,16 @@ void emitter::emitIns_R_C(
// load reg, r21 + addr_bits[11:0]

instrDesc* id = emitNewInstr(attr);
id->idSetRelocFlags(attr);

id->idIns(ins);
assert(reg != REG_R0); // for special. reg Must not be R0.
id->idReg1(reg); // destination register that will get the constant value.

id->idSmallCns(offs); // usually is 0.
id->idInsOpt(INS_OPTS_RC);
if (m_compiler->opts.compReloc)

if (m_compiler->opts.compReloc || id->idIsReloc())
{
id->idSetIsDspReloc();
id->idCodeSize(8);
Expand All @@ -2030,7 +2032,6 @@ void emitter::emitIns_R_C(
id->idOpSize(EA_PTRSIZE);
}

// TODO-LoongArch64: this maybe deleted.
id->idSetIsBound(); // We won't patch address since we will know the exact distance
// once JIT code and data are allocated together.

Expand Down
Loading