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

[RISCV] Support .option (no)autocompress #122483

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lenary
Copy link
Member

@lenary lenary commented Jan 10, 2025

This is the implementation of a new assembler-only option to allow the automatic compression of RISC-V instructions to be switched off without changing the currently enabled architectural features.

This allows users better control over the autocompression feature of the assembler, so they can get the exact instructions they want.

This will become more useful as the following things happen:

  • .option norvc is deprecated/removed (which is sometimes used for this purpose).
  • Extensions are added where the destination instruction cannot be disabled separately to the source instruction, either because the destination is in the base architecture, or because it is in the same extension as the source.
  • Extensions wider than 32-bits are added, which make CompressPats more complex to use intuitively, especially if the destination is a 32-bit instruction.

This is the implementation of a new assembler-only option to allow the
automatic compression of RISC-V instructions to be switched off without
changing the currently enabled architectural features.

This allows users better control over the autocompression feature of the
assembler, so they can get the exact instructions they want.

This will become more useful as the following things happen:
- `.option norvc` is deprecated/removed (which is sometimes used for
  this purpose).
- Extensions are added where the destination instruction cannot be
  disabled separately to the source instruction, either because the
  destination is in the base architecture, or because it is in the same
  extension as the source.
- Extensions wider than 32-bits are added, which make CompressPats more
  complex to use intuitively, especially if the destination is a 32-bit
  instruction.
@lenary
Copy link
Member Author

lenary commented Jan 10, 2025

The assembly manual proposal is here: riscv-non-isa/riscv-asm-manual#122

@topperc
Copy link
Collaborator

topperc commented Jan 10, 2025

Thanks for doing this. Kito and I have talked about something similar in the past. .option rvc has been broken since Zca/Zcf/Zcd was introduced.

@lenary
Copy link
Member Author

lenary commented Jan 10, 2025

Thanks for doing this. Kito and I have talked about something similar in the past. .option rvc has been broken since Zca/Zcf/Zcd was introduced.

Yeah. Just like EF_RVC conflates two things (C extension being present and IALIGN=16), .option norvc (effectively) conflates two things (C extension being present, and compression patterns being enabled). This is part of the missing work I mentioned that prevented us adding CompressPats to the Xqci work - the other is the tied operand issue that Sudharsan mentioned.

@@ -0,0 +1,70 @@
# RUN: llvm-mc -triple riscv32 -show-encoding -mattr=+c < %s \
Copy link
Member

Choose a reason for hiding this comment

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

llvm-mc doesn't need <

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants