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

Added mipsel support #14963

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 31 additions & 1 deletion mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,36 @@ CFG_RUN_TARG_arm-unknown-linux-gnueabi=$(call CFG_RUN_arm-unknown-linux-gnueabi,
RUSTC_FLAGS_arm-unknown-linux-gnueabi :=
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabi :=

# mipsel-linux configuration
CC_mipsel-linux=mipsel-linux-gcc
CXX_mipsel-linux=mipsel-linux-g++
CPP_mipsel-linux=mipsel-linux-gcc
AR_mipsel-linux=mipsel-linux-ar
CFG_LIB_NAME_mipsel-linux=lib$(1).so
CFG_STATIC_LIB_NAME_mipsel-linux=lib$(1).a
CFG_LIB_GLOB_mipsel-linux=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_mipsel-linux=lib$(1)-*.dylib.dSYM
CFG_CFLAGS_mipsel-linux := -mips32 -mabi=32 $(CFLAGS)
CFG_GCCISH_CFLAGS_mipsel-linux := -Wall -g -fPIC -mips32 -mabi=32 $(CFLAGS)
CFG_GCCISH_CXXFLAGS_mipsel-linux := -fno-rtti $(CXXFLAGS)
CFG_GCCISH_LINK_FLAGS_mipsel-linux := -shared -fPIC -g -mips32
CFG_GCCISH_DEF_FLAG_mipsel-linux := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_mipsel-linux := -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_mipsel-linux := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_mipsel-linux := .linux.def
CFG_LLC_FLAGS_mipsel-linux :=
CFG_INSTALL_NAME_mipsel-linux =
CFG_LIBUV_LINK_FLAGS_mipsel-linux =
CFG_EXE_SUFFIX_mipsel-linux :=
CFG_WINDOWSY_mipsel-linux :=
CFG_UNIXY_mipsel-linux := 1
CFG_PATH_MUNGE_mipsel-linux := true
CFG_LDPATH_mipsel-linux :=
CFG_RUN_mipsel-linux=
CFG_RUN_TARG_mipsel-linux=
RUSTC_FLAGS_mipsel-linux := -C target-cpu=mips32 -C target-feature="+mips32,+o32"


# mips-unknown-linux-gnu configuration
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
Expand Down Expand Up @@ -612,7 +642,7 @@ define CFG_MAKE_TOOLCHAIN
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
$$(call CFG_INSTALL_NAME_$(1),$$(4))

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

# We're using llvm-mc as our assembler because it supports
# .cfi pseudo-ops on mac
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ mod tests {
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
fn size_of_32() {
assert_eq!(size_of::<uint>(), 4u);
assert_eq!(size_of::<*uint>(), 4u);
Expand Down Expand Up @@ -501,6 +502,7 @@ mod tests {
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
fn align_of_32() {
assert_eq!(align_of::<uint>(), 4u);
assert_eq!(align_of::<*uint>(), 4u);
Expand Down
3 changes: 3 additions & 0 deletions src/libgreen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,15 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
}

#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
type Registers = [uint, ..32];

#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
fn new_regs() -> Box<Registers> { box {[0, .. 32]} }

#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
procedure: raw::Procedure, sp: *mut uint) {
let sp = align_down(sp);
Expand Down
8 changes: 8 additions & 0 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ pub mod types {
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
Expand Down Expand Up @@ -491,6 +492,7 @@ pub mod types {
}
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u64;
Expand Down Expand Up @@ -599,6 +601,7 @@ pub mod types {
}
}
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
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 @@ -2209,6 +2212,7 @@ pub mod consts {
}

#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
pub mod posix88 {
use types::os::arch::c95::c_int;
use types::common::c95::c_void;
Expand Down Expand Up @@ -2483,6 +2487,7 @@ pub mod consts {
pub static PTHREAD_STACK_MIN: size_t = 16384;

#[cfg(target_arch = "mips", target_os = "linux")]
#[cfg(target_arch = "mipsel", target_os = "linux")]
pub static PTHREAD_STACK_MIN: size_t = 131072;

pub static CLOCK_REALTIME: c_int = 0;
Expand Down Expand Up @@ -2536,6 +2541,7 @@ pub mod consts {
pub static SHUT_RDWR: c_int = 2;
}
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
pub mod bsd44 {
use types::os::arch::c95::c_int;

Expand Down Expand Up @@ -2604,6 +2610,7 @@ pub mod consts {
pub static MAP_STACK : c_int = 0x020000;
}
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
pub mod extra {
use types::os::arch::c95::c_int;

Expand Down Expand Up @@ -2976,6 +2983,7 @@ pub mod consts {
pub static PTHREAD_STACK_MIN: size_t = 4096;

#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
pub static PTHREAD_STACK_MIN: size_t = 2048;
Expand Down
15 changes: 12 additions & 3 deletions src/libnative/io/c_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,26 @@ use libc;
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
pub static FIONBIO: libc::c_ulong = 0x8004667e;
#[cfg(target_os = "linux", not(target_arch = "mips"))]
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
pub static FIONBIO: libc::c_ulong = 0x5421;
#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
pub static FIONBIO: libc::c_ulong = 0x667e;

#[cfg(target_os = "macos")]
#[cfg(target_os = "ios")]
#[cfg(target_os = "freebsd")]
pub static FIOCLEX: libc::c_ulong = 0x20006601;
#[cfg(target_os = "linux", not(target_arch = "mips"))]
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
pub static FIOCLEX: libc::c_ulong = 0x5451;
#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
pub static FIOCLEX: libc::c_ulong = 0x6601;

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -109,7 +115,9 @@ mod select {
}
}

#[cfg(target_os = "linux", not(target_arch = "mips"))]
#[cfg(target_os = "linux", target_arch = "x86")]
#[cfg(target_os = "linux", target_arch = "x86_64")]
#[cfg(target_os = "linux", target_arch = "arm")]
#[cfg(target_os = "android")]
mod signal {
use libc;
Expand Down Expand Up @@ -153,6 +161,7 @@ mod signal {
}

#[cfg(target_os = "linux", target_arch = "mips")]
#[cfg(target_os = "linux", target_arch = "mipsel")]
mod signal {
use libc;

Expand Down
72 changes: 72 additions & 0 deletions src/librustc/back/mipsel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 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 back::target_strs;
use syntax::abi;

pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
return target_strs::t {
module_asm: "".to_string(),

data_layout: match target_os {
abi::OsMacos => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}

abi::OsiOS => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}

abi::OsWin32 => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}

abi::OsLinux => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}

abi::OsAndroid => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}

abi::OsFreebsd => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
},

target_triple: target_triple,

cc_args: Vec::new(),
};
}
12 changes: 8 additions & 4 deletions src/librustc/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use driver::session::Session;
use back;
use back::link;
use back::target_strs;
use back::{arm, x86, x86_64, mips};
use back::{arm, x86, x86_64, mips, mipsel};
use middle::lint;

use syntax::abi;
Expand Down Expand Up @@ -373,7 +373,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
abi::X86 => ("little", "x86", "32"),
abi::X86_64 => ("little", "x86_64", "64"),
abi::Arm => ("little", "arm", "32"),
abi::Mips => ("big", "mips", "32")
abi::Mips => ("big", "mips", "32"),
abi::Mipsel => ("little", "mipsel", "32")
};

let fam = match sess.targ_cfg.os {
Expand Down Expand Up @@ -452,6 +453,7 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
("xscale", abi::Arm),
("thumb", abi::Arm),

("mipsel", abi::Mipsel),
("mips", abi::Mips)];

pub fn build_target_config(sopts: &Options) -> Config {
Expand All @@ -470,14 +472,16 @@ pub fn build_target_config(sopts: &Options) -> Config {
abi::X86 => (ast::TyI32, ast::TyU32),
abi::X86_64 => (ast::TyI64, ast::TyU64),
abi::Arm => (ast::TyI32, ast::TyU32),
abi::Mips => (ast::TyI32, ast::TyU32)
abi::Mips => (ast::TyI32, ast::TyU32),
abi::Mipsel => (ast::TyI32, ast::TyU32)
};
let target_triple = sopts.target_triple.clone();
let target_strs = match arch {
abi::X86 => x86::get_target_strs(target_triple, os),
abi::X86_64 => x86_64::get_target_strs(target_triple, os),
abi::Arm => arm::get_target_strs(target_triple, os),
abi::Mips => mips::get_target_strs(target_triple, os)
abi::Mips => mips::get_target_strs(target_triple, os),
abi::Mipsel => mipsel::get_target_strs(target_triple, os)
};
Config {
os: os,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub mod back {
pub mod link;
pub mod lto;
pub mod mips;
pub mod mipsel;
pub mod rpath;
pub mod svh;
pub mod target_strs;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use middle::trans::type_::Type;
use middle::trans::type_of;
use middle::ty;
use middle::ty::Disr;
use syntax::abi::{X86, X86_64, Arm, Mips};
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};
use syntax::ast;
use syntax::attr;
use syntax::attr::IntType;
Expand Down Expand Up @@ -367,6 +367,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
// corresponding to `choose_shortest`. However, we don't run on those yet...?
Arm => at_least_32,
Mips => at_least_32,
Mipsel => at_least_32,
}
}
attr::ReprAny => {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/trans/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)

#[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")]
#[cfg(target_arch = "mipsel")]
fn get_clobbers() -> String {
"".to_string()
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::{i8, i16, i32, i64};
use std::gc::Gc;
use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic};
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel, Rust, RustIntrinsic};
use syntax::ast_util::{local_def, is_local};
use syntax::attr::AttrMetaMethods;
use syntax::attr;
Expand Down Expand Up @@ -1021,7 +1021,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
let _icx = push_ctxt("call_memcpy");
let ccx = cx.ccx();
let key = match ccx.sess().targ_cfg.arch {
X86 | Arm | Mips => "llvm.memcpy.p0i8.p0i8.i32",
X86 | Arm | Mips | Mipsel => "llvm.memcpy.p0i8.p0i8.i32",
X86_64 => "llvm.memcpy.p0i8.p0i8.i64"
};
let memcpy = ccx.get_intrinsic(&key);
Expand Down Expand Up @@ -1065,7 +1065,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
let ccx = b.ccx;

let intrinsic_key = match ccx.sess().targ_cfg.arch {
X86 | Arm | Mips => "llvm.memset.p0i8.i32",
X86 | Arm | Mips | Mipsel => "llvm.memset.p0i8.i32",
X86_64 => "llvm.memset.p0i8.i64"
};

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use middle::trans::cabi_x86_64;
use middle::trans::cabi_arm;
use middle::trans::cabi_mips;
use middle::trans::type_::Type;
use syntax::abi::{X86, X86_64, Arm, Mips};
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};

#[deriving(Clone, PartialEq)]
pub enum ArgKind {
Expand Down Expand Up @@ -110,5 +110,6 @@ pub fn compute_abi_info(ccx: &CrateContext,
X86_64 => cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def),
Arm => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def),
Mips => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
Mipsel => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
}
}
Loading