From 0340359b2a3e9af1cd94cbf7831f8b77b9bf77a1 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sun, 17 May 2020 16:36:23 +1200 Subject: [PATCH] [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. --- src/librustc_target/abi/call/avr.rs | 36 +++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/librustc_target/abi/call/avr.rs b/src/librustc_target/abi/call/avr.rs index f681302bc03..c1f7a1e3af5 100644 --- a/src/librustc_target/abi/call/avr.rs +++ b/src/librustc_target/abi/call/avr.rs @@ -1,20 +1,46 @@ -#![allow(non_upper_case_globals)] +//! 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 Doxumentation 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(ret: &mut ArgAbi<'_, Ty>) { if ret.layout.is_aggregate() { ret.make_indirect(); - } else { - ret.extend_integer_width_to(8); // Is 8 correct? } } fn classify_arg_ty(arg: &mut ArgAbi<'_, Ty>) { if arg.layout.is_aggregate() { arg.make_indirect(); - } else { - arg.extend_integer_width_to(8); } }