Skip to content

Commit

Permalink
compiler/rustc_target: Add support for m68k-linux-gnu
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubitz committed Sep 17, 2021
1 parent df7ad3a commit 5805591
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
30 changes: 30 additions & 0 deletions compiler/rustc_target/src/abi/call/m68k.rs
@@ -0,0 +1,30 @@
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(32);
}
}

fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
if arg.layout.is_aggregate() {
arg.make_indirect_byval();
} else {
arg.extend_integer_width_to(32);
}
}

pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
}

for arg in &mut fn_abi.args {
if arg.is_ignore() {
continue;
}
classify_arg(arg);
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/abi/call/mod.rs
Expand Up @@ -8,6 +8,7 @@ mod arm;
mod avr;
mod bpf;
mod hexagon;
mod m68k;
mod mips;
mod mips64;
mod msp430;
Expand Down Expand Up @@ -634,6 +635,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"amdgpu" => amdgpu::compute_abi_info(cx, self),
"arm" => arm::compute_abi_info(cx, self),
"avr" => avr::compute_abi_info(self),
"m68k" => m68k::compute_abi_info(self),
"mips" => mips::compute_abi_info(cx, self),
"mips64" => mips64::compute_abi_info(cx, self),
"powerpc" => powerpc::compute_abi_info(self),
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs
@@ -0,0 +1,15 @@
use crate::abi::Endian;
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.max_atomic_width = Some(32);

Target {
llvm_target: "m68k-unknown-linux-gnu".to_string(),
pointer_width: 32,
data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".to_string(),
arch: "m68k".to_string(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base },
}
}
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Expand Up @@ -742,6 +742,7 @@ supported_targets! {
("x86_64-unknown-linux-gnux32", x86_64_unknown_linux_gnux32),
("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
("i586-unknown-linux-gnu", i586_unknown_linux_gnu),
("m68k-unknown-linux-gnu", m68k_unknown_linux_gnu),
("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
("mips64-unknown-linux-gnuabi64", mips64_unknown_linux_gnuabi64),
("mips64el-unknown-linux-gnuabi64", mips64el_unknown_linux_gnuabi64),
Expand Down

0 comments on commit 5805591

Please sign in to comment.