1
Fork 0

Rollup merge of #81455 - Amanieu:aarch64_ilp32, r=sanxiyn

Add AArch64 big-endian and ILP32 targets

This PR adds 3 new AArch64 targets:
- `aarch64_be-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu_ilp32`
- `aarch64_be-unknown-linux-gnu_ilp32`

It also fixes some ABI issues on big-endian ARM and AArch64.
This commit is contained in:
Jack Huey 2021-02-02 16:01:35 -05:00 committed by GitHub
commit 399c0a8e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 96 additions and 47 deletions

View file

@ -105,7 +105,6 @@ fn emit_aapcs_va_arg(
let mut end = bx.build_sibling_block("va_arg.end");
let zero = bx.const_i32(0);
let offset_align = Align::from_bytes(4).unwrap();
assert_eq!(bx.tcx().sess.target.endian, Endian::Little);
let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
let (reg_off, reg_top_index, slot_size) = if gr_type {
@ -144,9 +143,14 @@ fn emit_aapcs_va_arg(
let top = in_reg.load(top, bx.tcx().data_layout.pointer_align.abi);
// reg_value = *(@top + reg_off_v);
let top = in_reg.gep(top, &[reg_off_v]);
let top = in_reg.bitcast(top, bx.cx.type_ptr_to(layout.llvm_type(bx)));
let reg_value = in_reg.load(top, layout.align.abi);
let mut reg_addr = in_reg.gep(top, &[reg_off_v]);
if bx.tcx().sess.target.endian == Endian::Big && layout.size.bytes() != slot_size {
// On big-endian systems the value is right-aligned in its slot.
let offset = bx.const_i32((slot_size - layout.size.bytes()) as i32);
reg_addr = in_reg.gep(reg_addr, &[offset]);
}
let reg_addr = in_reg.bitcast(reg_addr, bx.cx.type_ptr_to(layout.llvm_type(bx)));
let reg_value = in_reg.load(reg_addr, layout.align.abi);
in_reg.br(&end.llbb());
// On Stack block

View file

@ -40,17 +40,7 @@ where
let size = ret.layout.size;
let bits = size.bits();
if bits <= 128 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else if bits <= 32 {
Reg::i32()
} else {
Reg::i64()
};
ret.cast_to(Uniform { unit, total: size });
ret.cast_to(Uniform { unit: Reg::i64(), total: size });
return;
}
ret.make_indirect();
@ -72,17 +62,7 @@ where
let size = arg.layout.size;
let bits = size.bits();
if bits <= 128 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else if bits <= 32 {
Reg::i32()
} else {
Reg::i64()
};
arg.cast_to(Uniform { unit, total: size });
arg.cast_to(Uniform { unit: Reg::i64(), total: size });
return;
}
arg.make_indirect();

View file

@ -45,14 +45,7 @@ where
let size = ret.layout.size;
let bits = size.bits();
if bits <= 32 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else {
Reg::i32()
};
ret.cast_to(Uniform { unit, total: size });
ret.cast_to(Uniform { unit: Reg::i32(), total: size });
return;
}
ret.make_indirect();

View file

@ -0,0 +1,20 @@
use crate::abi::Endian;
use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.max_atomic_width = Some(128);
Target {
llvm_target: "aarch64_be-unknown-linux-gnu".to_string(),
pointer_width: 64,
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
mcount: "\u{1}_mcount".to_string(),
endian: Endian::Big,
..base
},
}
}

View file

@ -0,0 +1,20 @@
use crate::abi::Endian;
use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.max_atomic_width = Some(128);
Target {
llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".to_string(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
mcount: "\u{1}_mcount".to_string(),
endian: Endian::Big,
..base
},
}
}

View file

@ -0,0 +1,18 @@
use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.max_atomic_width = Some(128);
Target {
llvm_target: "aarch64-unknown-linux-gnu_ilp32".to_string(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
mcount: "\u{1}_mcount".to_string(),
..base
},
}
}

View file

@ -808,6 +808,10 @@ supported_targets! {
("mipsel-sony-psp", mipsel_sony_psp),
("mipsel-unknown-none", mipsel_unknown_none),
("thumbv4t-none-eabi", thumbv4t_none_eabi),
("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu),
("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32),
("aarch64_be-unknown-linux-gnu_ilp32", aarch64_be_unknown_linux_gnu_ilp32),
}
/// Everything `rustc` knows about how to compile for a specific target.