Skip to content

Commit 0340359

Browse files
committed
[AVR] Update ABI type classification logic to match the the AVR-Clang ABI
This patch brings the AVR calling convention argument classification logic in line with AVR Clang's behaviour. AVR-Clang currently uses the `clang::DefaultABIInfo` ABI implementation. This calling convention promotes all aggregates to indirect, no matter their size. It is also unnecessary to perform any integer width extension for AVR as the minimum argument size matches the minimum describable size of abi::Primitive::Int - 8 bits. At some point in the future, an AVR-GCC compatible argument classification implementation should be adopted in both Clang and Rust.
1 parent 1f0652f commit 0340359

File tree

1 file changed

+31
-5
lines changed
  • src/librustc_target/abi/call

1 file changed

+31
-5
lines changed

src/librustc_target/abi/call/avr.rs

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
1-
#![allow(non_upper_case_globals)]
1+
//! LLVM-frontend specific AVR calling convention implementation.
2+
//!
3+
//! # Current calling convention ABI
4+
//!
5+
//! Inherited from Clang's `clang::DefaultABIInfo` implementation - self described
6+
//! as
7+
//!
8+
//! > the default implementation for ABI specific details. This implementation
9+
//! > provides information which results in
10+
//! > self-consistent and sensible LLVM IR generation, but does not
11+
//! > conform to any particular ABI.
12+
//! >
13+
//! > - Doxygen Doxumentation of `clang::DefaultABIInfo`
14+
//!
15+
//! This calling convention may not match AVR-GCC in all cases.
16+
//!
17+
//! In the future, an AVR-GCC compatible argument classification ABI should be
18+
//! adopted in both Rust and Clang.
19+
//!
20+
//! *NOTE*: Currently, this module implements the same calling convention
21+
//! that clang with AVR currently does - the default, simple, unspecialized
22+
//! ABI implementation available to all targets. This ABI is not
23+
//! binary-compatible with AVR-GCC. Once LLVM [PR46140](https://bugs.llvm.org/show_bug.cgi?id=46140)
24+
//! is completed, this module should be updated to match so that both Clang
25+
//! and Rust emit code to the same AVR-GCC compatible ABI.
26+
//!
27+
//! In particular, both Clang and Rust may not have the same semantics
28+
//! when promoting arguments to indirect references as AVR-GCC. It is important
29+
//! to note that the core AVR ABI implementation within LLVM itself is ABI
30+
//! compatible with AVR-GCC - Rust and AVR-GCC only differ in the small amount
31+
//! of compiler frontend specific calling convention logic implemented here.
232
333
use crate::abi::call::{ArgAbi, FnAbi};
434

535
fn classify_ret_ty<Ty>(ret: &mut ArgAbi<'_, Ty>) {
636
if ret.layout.is_aggregate() {
737
ret.make_indirect();
8-
} else {
9-
ret.extend_integer_width_to(8); // Is 8 correct?
1038
}
1139
}
1240

1341
fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>) {
1442
if arg.layout.is_aggregate() {
1543
arg.make_indirect();
16-
} else {
17-
arg.extend_integer_width_to(8);
1844
}
1945
}
2046

0 commit comments

Comments
 (0)