Skip to content

RISC-V intrinsics in Miri #5204

Description

@nazar-pc

Miri doesn't seem to support any of the numerous RISC-V intrinsics yet.

I have implemented a bunch of them as part of my RISC-V interpreter under 0BSC license and wondering what would it take to maybe upstream them into Miri itself?

Specifically, I have implemented the following RISC-V extensions (RV32 and RV64 flavors of each where applicable), and any intrinsic present there is implemented as the result:

  • M
  • B
  • Zba
  • Zbb
  • Zbc
  • Zbkb
  • Zbkc
  • Zbkx
  • Zbs
  • Zca
  • Zcb
  • Zcmp
  • Zkn
  • Zknd
  • Zkne
  • Zknh
  • Zicond
  • Zicsr
  • Zvbb
  • Zvbc
  • Zve64x
  • Zvkb

Implementations have basic unit tests, including under Miri, in CI, as well as validation against RISC-V Architectural Certification Tests as part of comprehensive integration/end-to-end testing.

Intrinsics are hardware-accelerated where possible, for example, RV64 Zknd/Zkne are implemented using platform-specific AES intrinics on aarch64 and x86-64. As more extensions are implemented, more intrinsics may be covered and contributed back to Miri.

I can extract intrinsics into a separate small crate if that is preferred/desirable or the code could be just copied instead (I have no issues with it being relicensed to whatever).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-riscvArea: concerns RISC-V target intrinsicsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions