Skip to content
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

powerpc support #20980

Merged
merged 22 commits into from
Jan 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ case $CFG_CPUTYPE in
CFG_CPUTYPE=aarch64
;;

powerpc)
CFG_CPUTYPE=powerpc
;;

x86_64 | x86-64 | x64 | amd64)
CFG_CPUTYPE=x86_64
;;
Expand Down Expand Up @@ -1004,7 +1008,7 @@ do
make_dir $t/rt/jemalloc
for i in \
isaac sync test \
arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips
arch/i386 arch/x86_64 arch/arm arch/aarch64 arch/mips arch/powerpc
do
make_dir $t/rt/stage$s/$i
done
Expand Down Expand Up @@ -1169,7 +1173,7 @@ do

msg "configuring LLVM for $gnu_t"

LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips"
LLVM_TARGETS="--enable-targets=x86,x86_64,arm,aarch64,mips,powerpc"
LLVM_BUILD="--build=$gnu_t"
LLVM_HOST="--host=$gnu_t"
LLVM_TARGET="--target=$gnu_t"
Expand Down
28 changes: 28 additions & 0 deletions mk/cfg/powerpc-unknown-linux-gnu.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# powerpc-unknown-linux-gnu configuration
CROSS_PREFIX_powerpc-unknown-linux-gnu=powerpc-linux-gnu-
CC_powerpc-unknown-linux-gnu=$(CC)
CXX_powerpc-unknown-linux-gnu=$(CXX)
CPP_powerpc-unknown-linux-gnu=$(CPP)
AR_powerpc-unknown-linux-gnu=$(AR)
CFG_LIB_NAME_powerpc-unknown-linux-gnu=lib$(1).so
CFG_STATIC_LIB_NAME_powerpc-unknown-linux-gnu=lib$(1).a
CFG_LIB_GLOB_powerpc-unknown-linux-gnu=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_powerpc-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
CFG_CFLAGS_powerpc-unknown-linux-gnu := -m32 $(CFLAGS)
CFG_GCCISH_CFLAGS_powerpc-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS)
CFG_GCCISH_CXXFLAGS_powerpc-unknown-linux-gnu := -fno-rtti $(CXXFLAGS)
CFG_GCCISH_LINK_FLAGS_powerpc-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32
CFG_GCCISH_DEF_FLAG_powerpc-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_powerpc-unknown-linux-gnu := .linux.def
CFG_LLC_FLAGS_powerpc-unknown-linux-gnu :=
CFG_INSTALL_NAME_powerpc-unknown-linux-gnu =
CFG_EXE_SUFFIX_powerpc-unknown-linux-gnu =
CFG_WINDOWSY_powerpc-unknown-linux-gnu :=
CFG_UNIXY_powerpc-unknown-linux-gnu := 1
CFG_PATH_MUNGE_powerpc-unknown-linux-gnu := true
CFG_LDPATH_powerpc-unknown-linux-gnu :=
CFG_RUN_powerpc-unknown-linux-gnu=$(2)
CFG_RUN_TARG_powerpc-unknown-linux-gnu=$(call CFG_RUN_powerpc-unknown-linux-gnu,,$(2))
CFG_GNU_TRIPLE_powerpc-unknown-linux-gnu := powerpc-unknown-linux-gnu
2 changes: 1 addition & 1 deletion mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ endif
######################################################################

# FIXME: x86-ism
LLVM_COMPONENTS=x86 arm aarch64 mips ipo bitreader bitwriter linker asmparser mcjit \
LLVM_COMPONENTS=x86 arm aarch64 mips powerpc ipo bitreader bitwriter linker asmparser mcjit \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to this I think you'll also want to touch the llvm-auto-clean-trigger to ensure LLVM is rebuilt.

interpreter instrumentation

# Only build these LLVM tools
Expand Down
4 changes: 2 additions & 2 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ define CFG_MAKE_TOOLCHAIN
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
$$(call CFG_INSTALL_NAME_$(1),$$(4))

ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel),)
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)

# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
Expand All @@ -189,7 +189,7 @@ define CFG_MAKE_TOOLCHAIN
-o=$$(1)
else

# For the ARM, AARCH64 and MIPS crosses, use the toolchain assembler
# For the ARM, AARCH64, MIPS and POWER crosses, use the toolchain assembler
# FIXME: We should be able to use the LLVM assembler
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
$$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ arbitrarily complex configurations through nesting.
The following configurations must be defined by the implementation:

* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, `"arm"`, or `"aarch64"`.
`"mips"`, `"powerpc"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_family = "..."`. Operating system family of the target, e. g.
Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
not(feature = "external_crate"),
any(target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel")))]
target_arch = "mipsel",
target_arch = "powerpc")))]
const MIN_ALIGN: uint = 8;
#[cfg(all(not(feature = "external_funcs"),
not(feature = "external_crate"),
Expand Down
16 changes: 4 additions & 12 deletions src/libcoretest/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ fn size_of_basic() {
}

#[test]
#[cfg(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel"))]
#[cfg(target_pointer_width = "32")]
fn size_of_32() {
assert_eq!(size_of::<uint>(), 4u);
assert_eq!(size_of::<*const uint>(), 4u);
}

#[test]
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))]
#[cfg(target_pointer_width = "64")]
fn size_of_64() {
assert_eq!(size_of::<uint>(), 8u);
assert_eq!(size_of::<*const uint>(), 8u);
Expand All @@ -52,18 +48,14 @@ fn align_of_basic() {
}

#[test]
#[cfg(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel"))]
#[cfg(target_pointer_width = "32")]
fn align_of_32() {
assert_eq!(align_of::<uint>(), 4u);
assert_eq!(align_of::<*const uint>(), 4u);
}

#[test]
#[cfg(any(target_arch = "x86_64",
target_arch = "aarch64"))]
#[cfg(target_pointer_width = "64")]
fn align_of_64() {
assert_eq!(align_of::<uint>(), 8u);
assert_eq!(align_of::<*const uint>(), 8u);
Expand Down
25 changes: 18 additions & 7 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ pub mod types {
#[cfg(any(target_arch = "x86",
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel"))]
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
Expand Down Expand Up @@ -528,7 +529,8 @@ pub mod types {
}
#[cfg(any(target_arch = "x86",
target_arch = "mips",
target_arch = "mipsel"))]
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u64;
Expand Down Expand Up @@ -642,7 +644,9 @@ pub mod types {
pub __size: [u32; 9]
}
}
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[cfg(any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod posix01 {
use types::os::arch::c95::{c_long, c_ulong, time_t};
use types::os::arch::posix88::{gid_t, ino_t};
Expand Down Expand Up @@ -2697,7 +2701,9 @@ pub mod consts {
pub const EHWPOISON: c_int = 133;
}

#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[cfg(any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod posix88 {
use types::os::arch::c95::c_int;
use types::common::c95::c_void;
Expand Down Expand Up @@ -2982,7 +2988,8 @@ pub mod consts {
#[cfg(all(target_os = "linux",
any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "aarch64")))]
target_arch = "aarch64",
target_arch = "powerpc")))]
pub const PTHREAD_STACK_MIN: size_t = 131072;

pub const CLOCK_REALTIME: c_int = 0;
Expand Down Expand Up @@ -3040,7 +3047,9 @@ pub mod consts {
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
}
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[cfg(any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod bsd44 {
use types::os::arch::c95::c_int;

Expand Down Expand Up @@ -3115,7 +3124,9 @@ pub mod consts {
pub const MAP_NONBLOCK : c_int = 0x010000;
pub const MAP_STACK : c_int = 0x020000;
}
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
#[cfg(any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"))]
pub mod extra {
use types::os::arch::c95::c_int;

Expand Down
4 changes: 3 additions & 1 deletion src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mod i686_unknown_dragonfly;
mod i686_unknown_linux_gnu;
mod mips_unknown_linux_gnu;
mod mipsel_unknown_linux_gnu;
mod powerpc_unknown_linux_gnu;
mod x86_64_apple_darwin;
mod x86_64_apple_ios;
mod x86_64_pc_windows_gnu;
Expand All @@ -95,7 +96,7 @@ pub struct Target {
/// OS name to use for conditional compilation.
pub target_os: String,
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
/// "aarch64", and "mips". "mips" includes "mipsel".
/// "aarch64", "mips", and "powerpc". "mips" includes "mipsel".
pub arch: String,
/// Optional settings with defaults.
pub options: TargetOptions,
Expand Down Expand Up @@ -339,6 +340,7 @@ impl Target {
i686_unknown_linux_gnu,
mips_unknown_linux_gnu,
mipsel_unknown_linux_gnu,
powerpc_unknown_linux_gnu,
arm_linux_androideabi,
arm_unknown_linux_gnueabi,
arm_unknown_linux_gnueabihf,
Expand Down
26 changes: 26 additions & 0 deletions src/librustc_back/target/powerpc_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2012 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 target::Target;

pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-m32".to_string());

Target {
data_layout: "E-S8-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
arch: "powerpc".to_string(),
target_os: "linux".to_string(),
options: base,
}
}
11 changes: 11 additions & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,11 @@ extern {
pub fn LLVMInitializeMipsTargetMC();
pub fn LLVMInitializeMipsAsmPrinter();
pub fn LLVMInitializeMipsAsmParser();
pub fn LLVMInitializePowerPCTargetInfo();
pub fn LLVMInitializePowerPCTarget();
pub fn LLVMInitializePowerPCTargetMC();
pub fn LLVMInitializePowerPCAsmPrinter();
pub fn LLVMInitializePowerPCAsmParser();

pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
Expand Down Expand Up @@ -2249,6 +2254,12 @@ pub unsafe fn static_link_hack_this_sucks() {
LLVMInitializeMipsAsmPrinter();
LLVMInitializeMipsAsmParser();

LLVMInitializePowerPCTargetInfo();
LLVMInitializePowerPCTarget();
LLVMInitializePowerPCTargetMC();
LLVMInitializePowerPCAsmPrinter();
LLVMInitializePowerPCAsmParser();

LLVMRustSetLLVMOptions(0 as c_int,
0 as *const _);

Expand Down
6 changes: 6 additions & 0 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,12 @@ unsafe fn configure_llvm(sess: &Session) {
llvm::LLVMInitializeMipsAsmPrinter();
llvm::LLVMInitializeMipsAsmParser();

llvm::LLVMInitializePowerPCTargetInfo();
llvm::LLVMInitializePowerPCTarget();
llvm::LLVMInitializePowerPCTargetMC();
llvm::LLVMInitializePowerPCAsmPrinter();
llvm::LLVMInitializePowerPCAsmParser();

llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
llvm_args.as_ptr());
});
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_trans/trans/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
// Default per-arch clobbers
// Basically what clang does

#[cfg(any(target_arch = "arm",
target_arch = "aarch64",
target_arch = "mips",
target_arch = "mipsel"))]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
fn get_clobbers() -> String {
"".to_string()
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_trans/trans/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use trans::cabi_x86_64;
use trans::cabi_x86_win64;
use trans::cabi_arm;
use trans::cabi_aarch64;
use trans::cabi_powerpc;
use trans::cabi_mips;
use trans::type_::Type;

Expand Down Expand Up @@ -125,6 +126,7 @@ pub fn compute_abi_info(ccx: &CrateContext,
cabi_arm::compute_abi_info(ccx, atys, rty, ret_def, flavor)
},
"mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
"powerpc" => cabi_powerpc::compute_abi_info(ccx, atys, rty, ret_def),
a => ccx.sess().fatal(&format!("unrecognized arch \"{}\" in target specification", a)
[]),
}
Expand Down
Loading