[PATCH] RISC-V: Add support for XW extension on some WCH cores

Nelson Chu nelson.chu1990@gmail.com
Mon Nov 24 09:43:49 GMT 2025


I was told the policy was changed that toolchains can accept vendor
extension names before they have pushed to riscv toolchain
conventions.  So if llvm already accepted and committed the name of
xwchc, then all other toolchains including gnu gcc, binutils, and
other documents also need to align the same name.  You probably can
convince the people of toolchain convention, or llvm guys to accept
two different names but for the same extension, with the same
encodings and syntax, and then we will follow-up.  There was a similar
case before and resolved, but the encodings of xthead vectors and the
standard vectors are different.  The xw and xwchc are all vendors, so
probably easier to get approved.

Nelson

On Mon, Nov 24, 2025 at 5:19 PM Andy Lin <andylinpersonal@gmail.com> wrote:
>
> The original toolchain use `-xw'. I can change the `-march' string to
> `-xwchc' but it
> will break the compatibility with the vendor toolchain. Btw, I'm not a
> WCH guy. Should
> I just create a PR on `riscv-toolchain-conventions' for them?
>
> Kito Cheng <kito.cheng@gmail.com> 於 2025年11月24日 週一 下午2:09寫道:
> >
> > Also could you create a PR to
> > https://github.com/riscv-non-isa/riscv-toolchain-conventions/blob/main/src/toolchain-conventions.adoc#list-of-vendor-prefixes
> > ?
> >
> > On Mon, Nov 24, 2025 at 10:39 AM Kito Cheng <kito.cheng@gmail.com> wrote:
> > >
> > > Why it's xwchc in LLVM but xw here?
> > >
> > > On Mon, Nov 24, 2025 at 3:50 AM Andy Lin <andylinpersonal@gmail.com> wrote:
> > > >
> > > >   This patch implements the xw extension found on some QingKe cores from
> > > > QinHeng (WCH). BTW, there is one divergence between this patch and vendor's
> > > > toolchain (based on older binutils 2.38.0) when using `norvc', `rvc' and
> > > > `arch' directives:
> > > >
> > > > Vendor's toolchain:
> > > >
> > > >   `-march' with `_xw':
> > > >     After `.option rvc', xw opcodes are available implicitly.
> > > >
> > > >   `-march' without `_xw':
> > > >     After `.option rvc', xw opcodes are NOT available, even if we explicitly
> > > >     add the `.option arch,+xw'.
> > > >
> > > > This patch:
> > > >
> > > >   `-march' with or without `_xw':
> > > >     After `.option rvc', xw opcodes are not available implicitly, but user
> > > >     can add `.option arch,+xw' to enable it. This behavior is consistent
> > > >     with other Zc* extensions not covered by the existing C extension.
> > > >
> > > > [1] Specs: http://web.archive.org/web/20251121133229/https://discourse.llvm.org/t/rfc-supporting-wch-qingke-xw-compressed-opcodes/79392/12
> > > > [2] LLVM's merged patch: https://github.com/llvm/llvm-project/pull/97925/files


More information about the Binutils mailing list