Skip to content

[RISCV] Introduce RVI AME (standard, pre-ratification) backend support#22

Open
vismaysur wants to merge 10 commits into
RuyiAI-Stack:riscvfrom
vismaysur:feature/rvi-ame-backend
Open

[RISCV] Introduce RVI AME (standard, pre-ratification) backend support#22
vismaysur wants to merge 10 commits into
RuyiAI-Stack:riscvfrom
vismaysur:feature/rvi-ame-backend

Conversation

@vismaysur

@vismaysur vismaysur commented Jul 14, 2026

Copy link
Copy Markdown

This PR adds initial RISC-V AME backend support.

Tasks/Deliverables:

  • target feature support (subtarget features for AME_NUM_M_REGS and AME_NUM_ACC_REGS)
  • matrix register definitions
  • instruction definitions + encodings
  • intrinsics
  • tests: llc (.ll -> .s and .ll -> .o) and llvm-mc (.s -> .o).

Closes #21

@github-actions

Copy link
Copy Markdown

Hello @vismaysur 👋

Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.

  • All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
  • The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.
  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.

Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description.


Frequently asked questions

How do I add reviewers?

This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically.

You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using @ followed by their GitHub username.

What if there are no comments?

If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers.

Are any special GitHub settings required to contribute to LLVM?

We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details.


If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse.

Thank you,
The LLVM Community

@vismaysur

vismaysur commented Jul 14, 2026

Copy link
Copy Markdown
Author

A few important observations / notes:

  • mls.rm / mls.cm / mls instructions (for loading squares) have no stride operands (encoding only the destination reg index and the base mem addr). so they can only load tiles that are already contiguous in memory (rather than extracting tiles out of a larger strided row-major / column-major matrix).

Just a detail to keep note of: if a stride operand is later added to the spec, we will not need to repack data in memory into tiles.

@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch 7 times, most recently from 12d2b78 to 36036f7 Compare July 16, 2026 02:06
@vismaysur vismaysur changed the title [RISCV] Introduce RVI AME (standard, pre-ratification) intrinsics [RISCV] Introduce RVI AME (standard, pre-ratification) backend support Jul 16, 2026
@WuXintong123
WuXintong123 force-pushed the riscv branch 2 times, most recently from e7c4297 to 8d7801d Compare July 17, 2026 16:34
@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch from b1e3edf to 5c844e7 Compare July 18, 2026 00:55
@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch from 5c844e7 to c28b72e Compare July 19, 2026 15:34
@vismaysur
vismaysur marked this pull request as ready for review July 19, 2026 21:48
@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch from b5dac9e to a4a3978 Compare July 20, 2026 04:41
@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch from a4a3978 to 2cc830c Compare July 21, 2026 02:39
@zhanghb97

Copy link
Copy Markdown

A few important observations / notes:

  • mls.rm / mls.cm / mls instructions (for loading squares) have no stride operands (encoding only the destination reg index and the base mem addr). so they can only load tiles that are already contiguous in memory (rather than extracting tiles out of a larger strided row-major / column-major matrix).

Just a detail to keep note of: if a stride operand is later added to the spec, we will not need to repack data in memory into tiles.

Good catch. We will keep our design aligned with the RVI specification and make the corresponding changes if the specification is updated.

@zhanghb97

Copy link
Copy Markdown

Please rebase the PR. I will start the review today.

@vismaysur
vismaysur force-pushed the feature/rvi-ame-backend branch from 2cc830c to b9c7652 Compare July 22, 2026 05:22
@vismaysur

Copy link
Copy Markdown
Author

Note: BOSCAME backend seems to instruction select LLVM IR to pseudo instructions (with immediate operands) which are then directly printed as asm, with no path (as i understand it) to MCInstr encodings / .o output. it has real instruction encodings but these are only reachable from .s or .o inputs, not from LLVM IR (please clarify if my understanding is incorrect).

Since M/Acc indices are already assigned by MLIR before they reach LLVM, so encoding them as immediates (rather than encoding register class operands) lets ISel lower straight to the real, bit-encoded instruction. I took a slightly different path in this backend of omitting the pseudo instructions altogether, instead encoding real instructions with immediate operands, enabling a single path from LLVM IR -> MCInstr with real encodings -> both .o and .s outputs.

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.

[TASK] Add Initial RISC-V AME Support to LLVM

2 participants