use abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
use abi::{Align, Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use spec::HasTargetSpec;
#[derive(Debug, Clone, Copy, PartialEq)]
enum ABI {
ELFv1, // original ABI used for powerpc64 (big-endian)
- ELFv2, // newer ABI used for powerpc64le
+ ELFv2, // newer ABI used for powerpc64le and musl (both endians)
}
use self::ABI::*;
let size = ret.layout.size;
let bits = size.bits();
if bits <= 128 {
- let unit = if bits <= 8 {
+ let unit = if cx.data_layout().endian == Endian::Big {
+ Reg { kind: RegKind::Integer, size }
+ } else if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
}
let size = arg.layout.size;
- let (unit, total) = match abi {
- ELFv1 => {
- // In ELFv1, aggregates smaller than a doubleword should appear in
- // the least-significant bits of the parameter doubleword. The rest
- // should be padded at their tail to fill out multiple doublewords.
- if size.bits() <= 64 {
- (Reg { kind: RegKind::Integer, size }, size)
- } else {
- let align = Align::from_bits(64, 64).unwrap();
- (Reg::i64(), size.abi_align(align))
- }
- },
- ELFv2 => {
- // In ELFv2, we can just cast directly.
- (Reg::i64(), size)
- },
+ let (unit, total) = if size.bits() <= 64 {
+ // Aggregates smaller than a doubleword should appear in
+ // the least-significant bits of the parameter doubleword.
+ (Reg { kind: RegKind::Integer, size }, size)
+ } else {
+ // Aggregates larger than a doubleword should be padded
+ // at the tail to fill out a whole number of doublewords.
+ let align = Align::from_bits(64, 64).unwrap();
+ (Reg::i64(), size.abi_align(align))
};
arg.cast_to(Uniform {
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
where Ty: TyLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout
+ C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
{
- let abi = match cx.data_layout().endian {
- Endian::Big => ELFv1,
- Endian::Little => ELFv2,
+ let abi = if cx.target_spec().target_env == "musl" {
+ ELFv2
+ } else {
+ match cx.data_layout().endian {
+ Endian::Big => ELFv1,
+ Endian::Little => ELFv2
+ }
};
if !fty.ret.is_ignore() {
}
/// Endianness of the target, which must match cfg(target-endian).
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, PartialEq)]
pub enum Endian {
Little,
Big
("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu),
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe),
+ ("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
+ ("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
("powerpc64le-unknown-linux-musl", powerpc64le_unknown_linux_musl),
("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use spec::{LinkerFlavor, Target, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+ base.cpu = "ppc64".to_string();
+ base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
+ base.max_atomic_width = Some(64);
+
+ Ok(Target {
+ llvm_target: "powerpc64-unknown-linux-musl".to_string(),
+ target_endian: "big".to_string(),
+ target_pointer_width: "64".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "E-m:e-i64:64-n32:64".to_string(),
+ arch: "powerpc64".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "unknown".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: base,
+ })
+}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use spec::{LinkerFlavor, Target, TargetResult};
+
+pub fn target() -> TargetResult {
+ let mut base = super::linux_musl_base::opts();
+ base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
+ base.max_atomic_width = Some(32);
+
+ Ok(Target {
+ llvm_target: "powerpc-unknown-linux-musl".to_string(),
+ target_endian: "big".to_string(),
+ target_pointer_width: "32".to_string(),
+ target_c_int_width: "32".to_string(),
+ data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
+ arch: "powerpc".to_string(),
+ target_os: "linux".to_string(),
+ target_env: "musl".to_string(),
+ target_vendor: "unknown".to_string(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: base,
+ })
+}