Hi,
Now some of the bitmanip extensions have been ratified and marked as non-experimental, you do not need any of the previous bitmanip-specific builds of things, any LLVM 14 build (if using a stable release), or any upstream main
branch as of January 13th 2022 will work for generating ratified bitmanip. The underlying support has been in LLVM for a number of years upstream (requiring the -menable-experimental-extensions
flag), but LLVM 14 was the first to support the ratified extensions without the experimental flag.
When you are calling clang, to generate bitmanip instructions, you also need to provide a -march string to it that includes one (or more) of the supported bitmanip extensions (zba, zbb, zbc, zbs), and it will generate these extensions.
As an example, if I use the file
long hello(long a, long b) {
return a&~b;
}
If I put zbb in the -march string, then I would expect the andn
instruction from that extension to be generated (here I’m using -S
to output assembly and -o-
to send that to stdout rather than a file):
$ clang --target=riscv64 -O -S -o- hello.c -march=rv64imaczbb
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_c2p0_zbb1p0"
.file "hello.c"
.globl hello
.p2align 2
.type hello,@function
hello:
andn a0, a0, a1
ret
.Lfunc_end0:
.size hello, .Lfunc_end0-hello
Hope this helps.