-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Enable AVR as a Tier 3 target upstream #69478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
690bb8a
[AVR] Add AVR platform support
shepmaster 91bff8c
[AVR] Fix debug printing of function pointers
dylanmckay 13edc57
[AVR] Add required references for AVR to the parser test suites
dylanmckay edc344e
[AVR] Raise and link to a tracking issue for the `avr-interrupt` call…
dylanmckay e369cf6
[AVR] Re-bless the UI tests
dylanmckay b4a041c
[AVR] Update the compiletest library to recognize AVR as a 16-bit target
dylanmckay 8ba9cbd
[AVR] Remove AVR-specific logic from libstd
dylanmckay 1f0652f
[AVR] Rename the 'none_base' target spec module to 'freestanding_base'
dylanmckay 0340359
[AVR] Update ABI type classification logic to match the the AVR-Clang…
dylanmckay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ fn main() { | |
"arm", | ||
"aarch64", | ||
"amdgpu", | ||
"avr", | ||
"mips", | ||
"powerpc", | ||
"systemz", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 | ||
jonas-schievink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! 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 fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) { | ||
if !fty.ret.is_ignore() { | ||
classify_ret_ty(&mut fty.ret); | ||
} | ||
|
||
for arg in &mut fty.args { | ||
if arg.is_ignore() { | ||
continue; | ||
} | ||
|
||
classify_arg_ty(arg); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::spec::{LinkerFlavor, Target, TargetResult}; | ||
|
||
pub fn target() -> TargetResult { | ||
Ok(Target { | ||
llvm_target: "avr-unknown-unknown".to_string(), | ||
target_endian: "little".to_string(), | ||
target_pointer_width: "16".to_string(), | ||
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".to_string(), | ||
dylanmckay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
arch: "avr".to_string(), | ||
linker_flavor: LinkerFlavor::Gcc, | ||
target_os: "unknown".to_string(), | ||
target_env: "".to_string(), | ||
target_vendor: "unknown".to_string(), | ||
target_c_int_width: 16.to_string(), | ||
options: super::freestanding_base::opts(), | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; | ||
use std::default::Default; | ||
|
||
pub fn opts() -> TargetOptions { | ||
let mut args = LinkArgs::new(); | ||
|
||
args.insert( | ||
LinkerFlavor::Gcc, | ||
vec![ | ||
// We want to be able to strip as much executable code as possible | ||
// from the linker command line, and this flag indicates to the | ||
// linker that it can avoid linking in dynamic libraries that don't | ||
// actually satisfy any symbols up to that point (as with many other | ||
// resolutions the linker does). This option only applies to all | ||
// following libraries so we're sure to pass it as one of the first | ||
// arguments. | ||
"-Wl,--as-needed".to_string(), | ||
], | ||
); | ||
|
||
TargetOptions { | ||
dynamic_linking: false, | ||
executables: true, | ||
linker_is_gnu: true, | ||
has_rpath: false, | ||
pre_link_args: args, | ||
position_independent_executables: false, | ||
..Default::default() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Test that the AVR interrupt ABI cannot be used when avr_interrupt | ||
// feature gate is not used. | ||
|
||
extern "avr-interrupt" fn foo() {} | ||
//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change | ||
|
||
fn main() { | ||
foo(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change | ||
--> $DIR/feature-gate-abi-avr-interrupt.rs:4:8 | ||
| | ||
LL | extern "avr-interrupt" fn foo() {} | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information | ||
= help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[ | |
("armv7", "arm"), | ||
("armv7s", "arm"), | ||
("asmjs", "asmjs"), | ||
("avr", "avr"), | ||
("hexagon", "hexagon"), | ||
("i386", "x86"), | ||
("i586", "x86"), | ||
|
@@ -114,6 +115,8 @@ pub fn matches_env(triple: &str, name: &str) -> bool { | |
pub fn get_pointer_width(triple: &str) -> &'static str { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh I would've expected There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - writing this line made me feel very dirty. |
||
if (triple.contains("64") && !triple.ends_with("gnux32")) || triple.starts_with("s390x") { | ||
"64bit" | ||
} else if triple.starts_with("avr") { | ||
"16bit" | ||
} else { | ||
"32bit" | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.