Skip to content

Specialize JALR Instruction #358

@jserv

Description

@jserv

The JALR (Jump and Link Register) instruction updates the program counter to a target address by adding a sign-extended 12-bit immediate to the value of the rs1 register and saves the address of the next instruction (PC+4) in the destination register. This instruction is versatile, supporting call and return operations, as well as register-indirect branching (which may require additional decoding for branch prediction).

Function calls are typically made using a JAL instruction to a label or a JALR instruction to a register rd. Specifically, these instructions should be JAL ra, label or JALR ra, rd, imm, though we may sometimes use the shorthand JAL label or JALR rd when imm is 0. The JAL instruction stores PC + 4 in ra, setting up the return address for after the function call, and increments the PC to the label's offset. JALR operates similarly but sets the PC to rd + imm.

To enhance JALR instruction simulation, we can consider specializing its usage scenarios. This could involve converting it into a push/pop pair or using it in specialized prologue/epilogue sequences for more efficient simulation.

Reference:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions