[clang] [llvm] [RISC-V] Add CSR read/write builtins (PR #85091)

Nemanja Ivanovic via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 00:08:07 PDT 2024


nemanjai wrote:

> > Individual implementations will provide different sets of CSR's and need a way to read/write them. Of course, this can be done with inline asm, but doing such things with inline asm has its limitations (no error checking,
> 
> Wouldn't the assembler error check the constant? Diagnostic is probably a bit uglier, but its not nothing.
Perhaps it would, but I really don't think it is particularly friendly to the user to rely on the assembler for this.

> 
> > if a user attempts to wrap the asm in a function, they won't be able to build code that calls those functions with -O0 as inlining/constant propagation is required, etc.).
> 
> You mean if they write a generic write_csr or read_csr function? If they use a `write_frm` or `read_fcsr` function then there is no constant propagation issue and they get to refer to the CSR by name in the assembly string instead of maintaining a constant in their code.

Yes, I mean the general, unnamed CSR's.

https://github.com/llvm/llvm-project/pull/85091


More information about the cfe-commits mailing list