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

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 11:36:22 PDT 2024


topperc 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.

> 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.

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


More information about the cfe-commits mailing list