Skip to content

[RISCV] Add BOSC AME extension support#16

Merged
zhanghb97 merged 14 commits into
RuyiAI-Stack:riscvfrom
Yranger:riscv
Jun 30, 2026
Merged

[RISCV] Add BOSC AME extension support#16
zhanghb97 merged 14 commits into
RuyiAI-Stack:riscvfrom
Yranger:riscv

Conversation

@Yranger

@Yranger Yranger commented Jun 30, 2026

Copy link
Copy Markdown

Description

This PR adds backend support for the BOSC AME (Advanced Matrix Extension) for RISC-V.

Key Changes

  • Extension Definition: Added FeatureVendorXXiangShanAME (v1.0) to correctly emit the xxiangshaname1p0 arch attribute in the generated assembly file.
  • Command Line Alias: Added FeatureVendorXBOSCAME as a SubtargetFeature. This allows developers to use -mattr=+xboscame from the command line, which implicitly enables the xxiangshaname extension under the hood.
  • Subtarget Predicates: Updated RISCVSubtarget.h with hasVendorXBOSCAME() and hasVendorXXiangShanAME() predicates for instruction selection (ISel).

Testing

  • Compiled C/MLIR test cases with -mattr=+xboscame.
  • Verified that .attribute arch, "...xxiangshaname1p0" is correctly emitted at the top of the .s file without bloated sub-extensions.

XYenChi and others added 13 commits June 25, 2026 00:00
…opsrun test (RuyiAI-Stack#4)

Fix three issues found on RISC-V:

1. Fix use-after-free in block walk (Visitors.h)

When walking blocks with ReverseDominanceIterator, the Traversal object
returned by Iterator::makeIterable(region) was passed as a temporary
directly to llvm::make_early_inc_range(). The temporary was destroyed at
the end of the full expression while iterators from make_early_inc_range
still referenced it. Store the result in a local variable with auto&& to
extend the lifetime of the temporary and bind lvalue references for
ForwardIterator.

2. Fix Shape dialect CstrBroadcastableOp fold and cast canonicalization

Extend getShapeVec to look through tensor.cast operations so that folds
can resolve shapes behind casts inserted by earlier canonicalization
passes (e.g., ShapeOfOpToConstShapeOp). Add a new fold check in
CstrBroadcastableOp::fold that recognizes broadcasting is trivially
valid when at most one operand is non-scalar (resolved via getShapeVec).
Rewrite CanonicalizeCastExtentTensorOperandsPattern to use
modifyOpInPlace instead of replaceOpWithNewOp to avoid issues with
op builder template instantiation.

3. Fix opsrun.py test invocation pattern for multithreaded_tests.py

Convert direct test_foo() calls to run(test_foo) so that
copy_and_update in multithreaded_tests.py properly strips them during
import, preventing JIT execution at module load time which crashes on
RISC-V due to R_RISCV_HI20 relocation range limits.
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Hello @Yranger 👋

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

@zhanghb97
zhanghb97 merged commit 369996d into RuyiAI-Stack:riscv Jun 30, 2026
7 checks passed
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.

6 participants