Skip to content

Commit

Permalink
Implement EmitJMP case in RiscV64Emitter (dotnet#111273)
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 authored Jan 10, 2025
1 parent 5abf582 commit 94add2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public void EmitReloc(ISymbolNode symbol, RelocType relocType, int delta = 0)
case RelocType.IMAGE_REL_BASED_LOONGARCH64_JIR:

case RelocType.IMAGE_REL_BASED_RISCV64_PC:
case RelocType.IMAGE_REL_BASED_RISCV64_JALR:
Debug.Assert(delta == 0);
// Do not vacate space for this kind of relocation, because
// the space is embedded in the instruction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,22 @@ public void EmitJMP(ISymbolNode symbol)
{
if (symbol.RepresentsIndirectionCell)
{
//auipc x29, 0
// auipc x29, 0
EmitPC(Register.X29);
//ld x29,16(x29)
// ld x29,16(x29)
EmitLD(Register.X29, Register.X29, 16);
//ld x29,0(x29)
// ld x29,0(x29)
EmitLD(Register.X29, Register.X29, 0);
//jalr x0,0(x29)
// jalr x0,0(x29)
EmitJALR(Register.X0, Register.X29, 0);

Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_DIR64);
}
else
{
Builder.EmitUInt(0x00000000); // bad code.
throw new NotImplementedException();
Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_RISCV64_JALR);
EmitPC(Register.X29); // auipc x29, 0
EmitJALR(Register.X0, Register.X29, 0); // jalr x0, 0(x29)
}
}

Expand Down

0 comments on commit 94add2e

Please sign in to comment.