Fwd: Question regarding stack operations in RISC-V

1,250 views
Skip to first unread message

Hesam Z.

unread,
May 3, 2017, 4:49:30 PM5/3/17
to isa...@groups.riscv.org
Hi,
I have noticed that there are no PUSH and POP instructions. Should the functionality of stack be implemented by software means?


Bruce Hoult

unread,
May 3, 2017, 6:10:34 PM5/3/17
to Hesam Z., RISC-V ISA Dev
Most commonly you need to save or restore several registers in a row. It can be just as efficient to adjust the stack pointer once and use SP+offset loads or stores instead of PUSH or POP, especially on wide implementations where you might be able to run several loads or stores in one clock cycle, but not easily update the same register multiple times in one clock cycle. Also, pop needs to write to two registers, which no other RISC-V integer instruction does.

Compilers for other ISAs often use the same technique even if they have PUSH and POP instructions.

On Wed, May 3, 2017 at 11:49 PM, Hesam Z. <hesamzol...@gmail.com> wrote:
Hi,
I have noticed that there are no PUSH and POP instructions. Should the functionality of stack be implemented by software means?


--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/CADNcivnVrXrxrs7Gj9y-nJogi%2BDh3TSeBHBQi5UkKZRJSwDD3A%40mail.gmail.com.

Rogier Brussee

unread,
May 4, 2017, 4:03:20 PM5/4/17
to RISC-V ISA Dev, hesamzol...@gmail.com, br...@hoult.org
In addition loading and storing words and doubles relative to the stack and adjusting the stack  can be done with 2 byte compressed instructions if the C extension is supported.



Op donderdag 4 mei 2017 00:10:34 UTC+2 schreef Bruce Hoult:
Most commonly you need to save or restore several registers in a row. It can be just as efficient to adjust the stack pointer once and use SP+offset loads or stores instead of PUSH or POP, especially on wide implementations where you might be able to run several loads or stores in one clock cycle, but not easily update the same register multiple times in one clock cycle. Also, pop needs to write to two registers, which no other RISC-V integer instruction does.

Compilers for other ISAs often use the same technique even if they have PUSH and POP instructions.
On Wed, May 3, 2017 at 11:49 PM, Hesam Z. <hesamzol...@gmail.com> wrote:
Hi,
I have noticed that there are no PUSH and POP instructions. Should the functionality of stack be implemented by software means?


--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+u...@groups.riscv.org.

Bruce Hoult

unread,
May 4, 2017, 4:24:02 PM5/4/17
to Rogier Brussee, RISC-V ISA Dev, Hesam Z.
I assumed that went without saying :-) But I guess not everyone has examined the code generated for their HiFive1.

To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.

To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
Reply all
Reply to author
Forward
0 new messages