Skip to content

Commit 94add2e

Browse files
authored
Implement EmitJMP case in RiscV64Emitter (#111273)
1 parent 5abf582 commit 94add2e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/coreclr/tools/Common/Compiler/DependencyAnalysis/ObjectDataBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ public void EmitReloc(ISymbolNode symbol, RelocType relocType, int delta = 0)
301301
case RelocType.IMAGE_REL_BASED_LOONGARCH64_JIR:
302302

303303
case RelocType.IMAGE_REL_BASED_RISCV64_PC:
304+
case RelocType.IMAGE_REL_BASED_RISCV64_JALR:
304305
Debug.Assert(delta == 0);
305306
// Do not vacate space for this kind of relocation, because
306307
// the space is embedded in the instruction.

src/coreclr/tools/Common/Compiler/DependencyAnalysis/Target_RiscV64/RiscV64Emitter.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,22 @@ public void EmitJMP(ISymbolNode symbol)
9898
{
9999
if (symbol.RepresentsIndirectionCell)
100100
{
101-
//auipc x29, 0
101+
// auipc x29, 0
102102
EmitPC(Register.X29);
103-
//ld x29,16(x29)
103+
// ld x29,16(x29)
104104
EmitLD(Register.X29, Register.X29, 16);
105-
//ld x29,0(x29)
105+
// ld x29,0(x29)
106106
EmitLD(Register.X29, Register.X29, 0);
107-
//jalr x0,0(x29)
107+
// jalr x0,0(x29)
108108
EmitJALR(Register.X0, Register.X29, 0);
109109

110110
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_DIR64);
111111
}
112112
else
113113
{
114-
Builder.EmitUInt(0x00000000); // bad code.
115-
throw new NotImplementedException();
114+
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_RISCV64_JALR);
115+
EmitPC(Register.X29); // auipc x29, 0
116+
EmitJALR(Register.X0, Register.X29, 0); // jalr x0, 0(x29)
116117
}
117118
}
118119

0 commit comments

Comments
 (0)