rust-lang / compiler-builtins

Porting `compiler-rt` intrinsics to Rust
https://github.com/rust-lang/rust/issues/35437
Other
374 stars 211 forks source link

Native support for AVR instrinsics #711

Open Patryk27 opened 1 month ago

Patryk27 commented 1 month ago

At the moment compiler-builtins isn't useful for AVR, because that platform uses a custom calling convention for intrinsics - supporting AVR here would require:

  1. Implementing this custom calling convention in LLVM.
  2. Exposing it in rustc.
  3. Finally, using it within compiler-builtins.

There are no ongoing plans to do so yet, but over https://github.com/rust-lang/rust/pull/131651 it was pointed out it would be nice to have some kind of message of this issue left, so here we go 🙂

tgross35 commented 1 month ago

Thanks for filing this. I don't think we are blocked on LLVM having support for the calling convention, instead we should be able to use naked functions to translate the cc like we do for aeabi intrinsics https://github.com/rust-lang/compiler-builtins/blob/cb060052ab7e4bad408c85d44be7e60096e93e38/src/arm.rs#L21-L35.

I'm not positive how this would interact with the clobbers, however.

Patryk27 commented 1 month ago

Oh, sure, that seems like a good idea 🙂

tgross35 commented 1 month ago

Separately you may be interested in getting AVR asm to stable. This isn't a blocker for this crate but it may be useful in user code https://github.com/rust-lang/rust/issues/93335

tgross35 commented 1 month ago

Also, do you know if there is a version of these symbols in assembly that don't come from libgcc? Some of these are probably easy enough that we could provide our own assembly implementations, but we need to be careful with licensing.

Patryk27 commented 1 month ago

Also, do you know if there is a version of these symbols in assembly that don't come from libgcc?

I'm aware only of the libgcc implementation, unfortunately.