JAL: what is "alternate reference case" x5?

The RISC-V v2.2 specification (JAL instruction, page 15) talks about a "standard calling convention":

The standard software calling convention uses x1 as the return address register and x5 as the alternate reference register.

with the following design comment:

The alternate reference register supports millicode subroutine calls (for example, to save and restore registers in compressed code) while maintaining a regular register return address.

What is an alternative link registry for?

I understand that the "link register" is the register for storing the PC to go to return, and this millicode / microcode is a lower level format below the ISA level. Is there an idea what is x5

used instead x1

for certain (microcode / millicode) instructions that surround "regular calls" to avoid shuffling or registry overflow? Do you have a typical use case?

It would be helpful to add an explanation of alternate link registers to the Wikipedia article on registration links , which I searched for for more information.

+3


source to share


1 answer


In general, millicode instructions should not interfere with normal instructions, and an alternate calling convention is required to call a millicode procedure ( from Waterman PhD Thesis, p. 66 ):

... subroutines must have an alternative calling convention because the case of references must be preserved while they are being executed. Fortunately, unlike ARM and MIPS, the RISC-Vs hop and pipe team can write the return address in any integer register, rather than glue the ABI-assigned link registry. Apart from this difference, these millicode subroutines behave like regular Procedures

The more specific reason the reference case should be preserved is because millicode is used to implement prologues and epilogues, so using a normal calling convention will compress the reference case and defeat the whole idea of ​​using millicode for prologues / afterword.

Is it an idea that x5 is used instead of x1 for certain (microcodes / millicode) instructions that surround "normal calls" to avoid shuffling or registry overflow?

Yes ... to some extent the word "surround".

Do you have a typical use case?



See prologue_2

, epilogue_2

millikoda routines from Waterman PhD, page 67

00: c919     c.beqz a0, 16
02: 016002ef jal t0, prologue_2
06: 842a     c.mv s0, a0
08: 157d     c.addi a0, -1
0a: ff7ff0ef jal ra, factorial
0e: 02850533 mul a0, a0, s0
12: 0100006f jal x0, epilogue_2
16: 4505     c.li a0, 1
18: 8082     c.jr ra

      

where prologue_2

:

00: 1141 c.addi sp, -16
02: e406 c.sdsp ra, 8(sp)
04: e022 c.sdsp s0, 0(sp)
06: 8282 c.jr t0

      

and epilogue_2

:

00: 60a2 c.ldsp ra, 8(sp)
02: 6402 c.ldsp s0, 0(sp)
04: 0141 c.addi sp, 16
06: 8082 c.jr ra

      

+5


source







All Articles