]>
Commit | Line | Data |
---|---|---|
f035d41b XL |
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 | //! > | |
49aad941 | 13 | //! > - Doxygen Documentation of `clang::DefaultABIInfo` |
f035d41b XL |
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. | |
32 | ||
33 | use crate::abi::call::{ArgAbi, FnAbi}; | |
34 | ||
35 | fn classify_ret_ty<Ty>(ret: &mut ArgAbi<'_, Ty>) { | |
36 | if ret.layout.is_aggregate() { | |
37 | ret.make_indirect(); | |
38 | } | |
39 | } | |
40 | ||
41 | fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>) { | |
42 | if arg.layout.is_aggregate() { | |
43 | arg.make_indirect(); | |
44 | } | |
45 | } | |
46 | ||
47 | pub fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) { | |
48 | if !fty.ret.is_ignore() { | |
49 | classify_ret_ty(&mut fty.ret); | |
50 | } | |
51 | ||
f2b60f7d | 52 | for arg in fty.args.iter_mut() { |
f035d41b XL |
53 | if arg.is_ignore() { |
54 | continue; | |
55 | } | |
56 | ||
57 | classify_arg_ty(arg); | |
58 | } | |
59 | } |