This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add Clang Builtins for Accessing CSRs
AbandonedPublic

Authored by lenary on Dec 20 2019, 11:00 AM.

Details

Reviewers
asb
luismarques
Summary

As of clang 9.0, the only way to access the RISC-V Control and Status Registers
is to use inline assembly, which is ugly and hinders optimisations.

This patch adds some Clang Builtins and LLVM Intrinsics to allow programmers
to access the CSRs without using inline assembly, which should therefore be
safer.

I hope to build a slightly nicer interface to this, to support the read-only or
write-only CSR operations (akin to the csrr, csrw, csrs and csrc
pseudo-instructions) via these builtins, which will eventually be available via
<rvintrin.h>.

Event Timeline

lenary created this revision.Dec 20 2019, 11:00 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 20 2019, 11:00 AM
Jim added a subscriber: Jim.Dec 23 2019, 10:09 PM
lenary abandoned this revision.Dec 10 2021, 5:59 AM
rkruppe removed a subscriber: rkruppe.Dec 10 2021, 7:34 AM