Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add Autocompress Control #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/asm-manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,48 @@ NOTE: `.option arch, +<ext>, -<ext>` is accepted and will result in enabling the
extensions that depend on `ext`, e.g. `rv32i` + `.option arch, +v, -v` will result
`rv32ifd_zve32x_zve32f_zve64x_zve64f_zve64d_zvl32b_zvl64b_zvl128b`.

=== `autocompress`/`noautocompress`

In RISC-V, it is primarily the assembler's job (not the compiler's), to choose
the shortest possible version of an instruction. This means the assembler will
change `lw a0, 16(a1)` into `c.lw a0, 16(a1)`, when either the `C` or `Zca`
extension is enabled.

While this process does save static code size, there are circumstances where it
might not be wanted, and instead when assembly writers want exactly the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "when" in "instead when assembly writers" is unnecessary.

instructions they wrote to be assembled.

Previously, this has been achievable with `.option norvc` or `.option arch` (to
disable the extension the destination is in), but this will become more
difficult to control as wider instructions are supported by assemblers.

This option does not change the currently enabled extensions, which allows
instructions of different lengths to still be used without error. For example:

[source,asm]
----
.option arch, +zca

lw a0, 0(a0) # assembled as 'c.lw a0, 0(a0)' (2 bytes)
c.lw a0, 0(a0) # not changed

.option noautocompress

lw a0, 0(a0) # not changed
c.lw a0, 0(a0) # not changed, no error

.option autocompress

lw a0, 0(a0) # assembled as 'c.lw a0, 0(a0)' (2 bytes)
c.lw a0, 0(a0) # not changed
----

The default behaviour is `.option autocompress`.

The default behaviour of some disassemblers is to reverse this process and show
`lw a0, 0(a0)` when `c.lw a0, 0(a0)` is in the binary. This can be disabled in
objdump-compatible disassemblers `-M no-aliases`.

=== `pic`/`nopic`

Set the code model to PIC (position independent code) or non-PIC. This will
Expand Down
Loading