about summary refs log tree commit diff
path: root/compiler/rustc_target/src/callconv/avr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-14 12:20:35 +0000
committerbors <bors@rust-lang.org>2024-10-14 12:20:35 +0000
commit17a19e684cdf3ca088af8b4da6a6209d128913f4 (patch)
treec5079eb765379d0c131f40fd76365fd5d8a692c8 /compiler/rustc_target/src/callconv/avr.rs
parentf6648f252a05a0a46c865d7ec836b46290613bf9 (diff)
parentd34b9324c0557abbcd52257fdc544e8a8ff77d4d (diff)
downloadrust-17a19e684cdf3ca088af8b4da6a6209d128913f4.tar.gz
rust-17a19e684cdf3ca088af8b4da6a6209d128913f4.zip
Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128967 (std::fs::get_path freebsd update.)
 - #130629 (core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments.)
 - #131274 (library: Const-stabilize `MaybeUninit::assume_init_mut`)
 - #131473 (compiler: `{TyAnd,}Layout` comes home)
 - #131533 (emscripten: Use the latest emsdk 3.1.68)
 - #131593 (miri: avoid cloning AllocExtra)
 - #131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate)
 - #131660 (Also use outermost const-anon for impl items in `non_local_defs` lint)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_target/src/callconv/avr.rs')
-rw-r--r--compiler/rustc_target/src/callconv/avr.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/callconv/avr.rs b/compiler/rustc_target/src/callconv/avr.rs
new file mode 100644
index 00000000000..dfc991e0954
--- /dev/null
+++ b/compiler/rustc_target/src/callconv/avr.rs
@@ -0,0 +1,59 @@
+//! LLVM-frontend specific AVR calling convention implementation.
+//!
+//! # Current calling convention ABI
+//!
+//! Inherited from Clang's `clang::DefaultABIInfo` implementation - self described
+//! as
+//!
+//! > the default implementation for ABI specific details. This implementation
+//! > provides information which results in
+//! > self-consistent and sensible LLVM IR generation, but does not
+//! > conform to any particular ABI.
+//! >
+//! > - Doxygen Documentation of `clang::DefaultABIInfo`
+//!
+//! This calling convention may not match AVR-GCC in all cases.
+//!
+//! In the future, an AVR-GCC compatible argument classification ABI should be
+//! adopted in both Rust and Clang.
+//!
+//! *NOTE*: Currently, this module implements the same calling convention
+//! that clang with AVR currently does - the default, simple, unspecialized
+//! ABI implementation available to all targets. This ABI is not
+//! binary-compatible with AVR-GCC. Once LLVM [PR46140](https://bugs.llvm.org/show_bug.cgi?id=46140)
+//! is completed, this module should be updated to match so that both Clang
+//! and Rust emit code to the same AVR-GCC compatible ABI.
+//!
+//! In particular, both Clang and Rust may not have the same semantics
+//! when promoting arguments to indirect references as AVR-GCC. It is important
+//! to note that the core AVR ABI implementation within LLVM itself is ABI
+//! compatible with AVR-GCC - Rust and AVR-GCC only differ in the small amount
+//! of compiler frontend specific calling convention logic implemented here.
+
+use crate::abi::call::{ArgAbi, FnAbi};
+
+fn classify_ret_ty<Ty>(ret: &mut ArgAbi<'_, Ty>) {
+    if ret.layout.is_aggregate() {
+        ret.make_indirect();
+    }
+}
+
+fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>) {
+    if arg.layout.is_aggregate() {
+        arg.make_indirect();
+    }
+}
+
+pub(crate) fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) {
+    if !fty.ret.is_ignore() {
+        classify_ret_ty(&mut fty.ret);
+    }
+
+    for arg in fty.args.iter_mut() {
+        if arg.is_ignore() {
+            continue;
+        }
+
+        classify_arg_ty(arg);
+    }
+}