Skip to content

Commit 34a384a

Browse files
author
Pawel Olzacki
committed
Added Mipsel architecture support
1 parent 7ec7805 commit 34a384a

File tree

21 files changed

+331
-16
lines changed

21 files changed

+331
-16
lines changed

mk/platform.mk

+31-1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,36 @@ CFG_RUN_TARG_arm-unknown-linux-gnueabi=$(call CFG_RUN_arm-unknown-linux-gnueabi,
374374
RUSTC_FLAGS_arm-unknown-linux-gnueabi :=
375375
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabi :=
376376

377+
# mipsel-linux configuration
378+
CC_mipsel-linux=mipsel-linux-gcc
379+
CXX_mipsel-linux=mipsel-linux-g++
380+
CPP_mipsel-linux=mipsel-linux-gcc
381+
AR_mipsel-linux=mipsel-linux-ar
382+
CFG_LIB_NAME_mipsel-linux=lib$(1).so
383+
CFG_STATIC_LIB_NAME_mipsel-linux=lib$(1).a
384+
CFG_LIB_GLOB_mipsel-linux=lib$(1)-*.so
385+
CFG_LIB_DSYM_GLOB_mipsel-linux=lib$(1)-*.dylib.dSYM
386+
CFG_CFLAGS_mipsel-linux := -mips32 -mabi=32 $(CFLAGS)
387+
CFG_GCCISH_CFLAGS_mipsel-linux := -Wall -g -fPIC -mips32 -mabi=32 $(CFLAGS)
388+
CFG_GCCISH_CXXFLAGS_mipsel-linux := -fno-rtti $(CXXFLAGS)
389+
CFG_GCCISH_LINK_FLAGS_mipsel-linux := -shared -fPIC -g -mips32
390+
CFG_GCCISH_DEF_FLAG_mipsel-linux := -Wl,--export-dynamic,--dynamic-list=
391+
CFG_GCCISH_PRE_LIB_FLAGS_mipsel-linux := -Wl,-whole-archive
392+
CFG_GCCISH_POST_LIB_FLAGS_mipsel-linux := -Wl,-no-whole-archive
393+
CFG_DEF_SUFFIX_mipsel-linux := .linux.def
394+
CFG_LLC_FLAGS_mipsel-linux :=
395+
CFG_INSTALL_NAME_mipsel-linux =
396+
CFG_LIBUV_LINK_FLAGS_mipsel-linux =
397+
CFG_EXE_SUFFIX_mipsel-linux :=
398+
CFG_WINDOWSY_mipsel-linux :=
399+
CFG_UNIXY_mipsel-linux := 1
400+
CFG_PATH_MUNGE_mipsel-linux := true
401+
CFG_LDPATH_mipsel-linux :=
402+
CFG_RUN_mipsel-linux=
403+
CFG_RUN_TARG_mipsel-linux=
404+
RUSTC_FLAGS_mipsel-linux := -C target-cpu=mips32 -C target-feature="+mips32,+o32"
405+
406+
377407
# mips-unknown-linux-gnu configuration
378408
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
379409
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
@@ -612,7 +642,7 @@ define CFG_MAKE_TOOLCHAIN
612642
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
613643
$$(call CFG_INSTALL_NAME_$(1),$$(4))
614644

615-
ifeq ($$(findstring $(HOST_$(1)),arm mips),)
645+
ifeq ($$(findstring $(HOST_$(1)),arm mips mipsel),)
616646

617647
# We're using llvm-mc as our assembler because it supports
618648
# .cfi pseudo-ops on mac

src/libcore/mem.rs

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ mod tests {
470470
#[cfg(target_arch = "x86")]
471471
#[cfg(target_arch = "arm")]
472472
#[cfg(target_arch = "mips")]
473+
#[cfg(target_arch = "mipsel")]
473474
fn size_of_32() {
474475
assert_eq!(size_of::<uint>(), 4u);
475476
assert_eq!(size_of::<*uint>(), 4u);
@@ -501,6 +502,7 @@ mod tests {
501502
#[cfg(target_arch = "x86")]
502503
#[cfg(target_arch = "arm")]
503504
#[cfg(target_arch = "mips")]
505+
#[cfg(target_arch = "mipsel")]
504506
fn align_of_32() {
505507
assert_eq!(align_of::<uint>(), 4u);
506508
assert_eq!(align_of::<*uint>(), 4u);

src/libgreen/context.rs

+3
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,15 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
268268
}
269269

270270
#[cfg(target_arch = "mips")]
271+
#[cfg(target_arch = "mipsel")]
271272
type Registers = [uint, ..32];
272273

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

276278
#[cfg(target_arch = "mips")]
279+
#[cfg(target_arch = "mipsel")]
277280
fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
278281
procedure: raw::Procedure, sp: *mut uint) {
279282
let sp = align_down(sp);

src/liblibc/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ pub mod types {
463463
#[cfg(target_arch = "x86")]
464464
#[cfg(target_arch = "arm")]
465465
#[cfg(target_arch = "mips")]
466+
#[cfg(target_arch = "mipsel")]
466467
pub mod arch {
467468
pub mod c95 {
468469
pub type c_char = i8;
@@ -491,6 +492,7 @@ pub mod types {
491492
}
492493
#[cfg(target_arch = "x86")]
493494
#[cfg(target_arch = "mips")]
495+
#[cfg(target_arch = "mipsel")]
494496
pub mod posix88 {
495497
pub type off_t = i32;
496498
pub type dev_t = u64;
@@ -599,6 +601,7 @@ pub mod types {
599601
}
600602
}
601603
#[cfg(target_arch = "mips")]
604+
#[cfg(target_arch = "mipsel")]
602605
pub mod posix01 {
603606
use types::os::arch::c95::{c_long, c_ulong, time_t};
604607
use types::os::arch::posix88::{gid_t, ino_t};
@@ -2209,6 +2212,7 @@ pub mod consts {
22092212
}
22102213

22112214
#[cfg(target_arch = "mips")]
2215+
#[cfg(target_arch = "mipsel")]
22122216
pub mod posix88 {
22132217
use types::os::arch::c95::c_int;
22142218
use types::common::c95::c_void;
@@ -2483,6 +2487,7 @@ pub mod consts {
24832487
pub static PTHREAD_STACK_MIN: size_t = 16384;
24842488

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

24882493
pub static CLOCK_REALTIME: c_int = 0;
@@ -2536,6 +2541,7 @@ pub mod consts {
25362541
pub static SHUT_RDWR: c_int = 2;
25372542
}
25382543
#[cfg(target_arch = "mips")]
2544+
#[cfg(target_arch = "mipsel")]
25392545
pub mod bsd44 {
25402546
use types::os::arch::c95::c_int;
25412547

@@ -2604,6 +2610,7 @@ pub mod consts {
26042610
pub static MAP_STACK : c_int = 0x020000;
26052611
}
26062612
#[cfg(target_arch = "mips")]
2613+
#[cfg(target_arch = "mipsel")]
26072614
pub mod extra {
26082615
use types::os::arch::c95::c_int;
26092616

@@ -2976,6 +2983,7 @@ pub mod consts {
29762983
pub static PTHREAD_STACK_MIN: size_t = 4096;
29772984

29782985
#[cfg(target_arch = "mips")]
2986+
#[cfg(target_arch = "mipsel")]
29792987
#[cfg(target_arch = "x86")]
29802988
#[cfg(target_arch = "x86_64")]
29812989
pub static PTHREAD_STACK_MIN: size_t = 2048;

src/libnative/io/c_unix.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,26 @@ use libc;
2323
#[cfg(target_os = "ios")]
2424
#[cfg(target_os = "freebsd")]
2525
pub static FIONBIO: libc::c_ulong = 0x8004667e;
26-
#[cfg(target_os = "linux", not(target_arch = "mips"))]
26+
#[cfg(target_os = "linux", target_arch = "x86")]
27+
#[cfg(target_os = "linux", target_arch = "x86_64")]
28+
#[cfg(target_os = "linux", target_arch = "arm")]
2729
#[cfg(target_os = "android")]
2830
pub static FIONBIO: libc::c_ulong = 0x5421;
2931
#[cfg(target_os = "linux", target_arch = "mips")]
32+
#[cfg(target_os = "linux", target_arch = "mipsel")]
3033
pub static FIONBIO: libc::c_ulong = 0x667e;
3134

3235
#[cfg(target_os = "macos")]
3336
#[cfg(target_os = "ios")]
3437
#[cfg(target_os = "freebsd")]
3538
pub static FIOCLEX: libc::c_ulong = 0x20006601;
36-
#[cfg(target_os = "linux", not(target_arch = "mips"))]
39+
#[cfg(target_os = "linux", target_arch = "x86")]
40+
#[cfg(target_os = "linux", target_arch = "x86_64")]
41+
#[cfg(target_os = "linux", target_arch = "arm")]
3742
#[cfg(target_os = "android")]
3843
pub static FIOCLEX: libc::c_ulong = 0x5451;
3944
#[cfg(target_os = "linux", target_arch = "mips")]
45+
#[cfg(target_os = "linux", target_arch = "mipsel")]
4046
pub static FIOCLEX: libc::c_ulong = 0x6601;
4147

4248
#[cfg(target_os = "macos")]
@@ -109,7 +115,9 @@ mod select {
109115
}
110116
}
111117

112-
#[cfg(target_os = "linux", not(target_arch = "mips"))]
118+
#[cfg(target_os = "linux", target_arch = "x86")]
119+
#[cfg(target_os = "linux", target_arch = "x86_64")]
120+
#[cfg(target_os = "linux", target_arch = "arm")]
113121
#[cfg(target_os = "android")]
114122
mod signal {
115123
use libc;
@@ -153,6 +161,7 @@ mod signal {
153161
}
154162

155163
#[cfg(target_os = "linux", target_arch = "mips")]
164+
#[cfg(target_os = "linux", target_arch = "mipsel")]
156165
mod signal {
157166
use libc;
158167

src/librustc/back/mipsel.rs

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use back::target_strs;
12+
use syntax::abi;
13+
14+
pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
15+
return target_strs::t {
16+
module_asm: "".to_string(),
17+
18+
data_layout: match target_os {
19+
abi::OsMacos => {
20+
"e-p:32:32:32\
21+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
22+
-f32:32:32-f64:64:64\
23+
-v64:64:64-v128:64:128\
24+
-a0:0:64-n32".to_string()
25+
}
26+
27+
abi::OsiOS => {
28+
"e-p:32:32:32\
29+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
30+
-f32:32:32-f64:64:64\
31+
-v64:64:64-v128:64:128\
32+
-a0:0:64-n32".to_string()
33+
}
34+
35+
abi::OsWin32 => {
36+
"e-p:32:32:32\
37+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
38+
-f32:32:32-f64:64:64\
39+
-v64:64:64-v128:64:128\
40+
-a0:0:64-n32".to_string()
41+
}
42+
43+
abi::OsLinux => {
44+
"e-p:32:32:32\
45+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
46+
-f32:32:32-f64:64:64\
47+
-v64:64:64-v128:64:128\
48+
-a0:0:64-n32".to_string()
49+
}
50+
51+
abi::OsAndroid => {
52+
"e-p:32:32:32\
53+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
54+
-f32:32:32-f64:64:64\
55+
-v64:64:64-v128:64:128\
56+
-a0:0:64-n32".to_string()
57+
}
58+
59+
abi::OsFreebsd => {
60+
"e-p:32:32:32\
61+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
62+
-f32:32:32-f64:64:64\
63+
-v64:64:64-v128:64:128\
64+
-a0:0:64-n32".to_string()
65+
}
66+
},
67+
68+
target_triple: target_triple,
69+
70+
cc_args: Vec::new(),
71+
};
72+
}

src/librustc/driver/config.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use driver::session::Session;
1818
use back;
1919
use back::link;
2020
use back::target_strs;
21-
use back::{arm, x86, x86_64, mips};
21+
use back::{arm, x86, x86_64, mips, mipsel};
2222
use middle::lint;
2323

2424
use syntax::abi;
@@ -373,7 +373,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
373373
abi::X86 => ("little", "x86", "32"),
374374
abi::X86_64 => ("little", "x86_64", "64"),
375375
abi::Arm => ("little", "arm", "32"),
376-
abi::Mips => ("big", "mips", "32")
376+
abi::Mips => ("big", "mips", "32"),
377+
abi::Mipsel => ("little", "mipsel", "32")
377378
};
378379

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

456+
("mipsel", abi::Mipsel),
455457
("mips", abi::Mips)];
456458

457459
pub fn build_target_config(sopts: &Options) -> Config {
@@ -470,14 +472,16 @@ pub fn build_target_config(sopts: &Options) -> Config {
470472
abi::X86 => (ast::TyI32, ast::TyU32),
471473
abi::X86_64 => (ast::TyI64, ast::TyU64),
472474
abi::Arm => (ast::TyI32, ast::TyU32),
473-
abi::Mips => (ast::TyI32, ast::TyU32)
475+
abi::Mips => (ast::TyI32, ast::TyU32),
476+
abi::Mipsel => (ast::TyI32, ast::TyU32)
474477
};
475478
let target_triple = sopts.target_triple.clone();
476479
let target_strs = match arch {
477480
abi::X86 => x86::get_target_strs(target_triple, os),
478481
abi::X86_64 => x86_64::get_target_strs(target_triple, os),
479482
abi::Arm => arm::get_target_strs(target_triple, os),
480-
abi::Mips => mips::get_target_strs(target_triple, os)
483+
abi::Mips => mips::get_target_strs(target_triple, os),
484+
abi::Mipsel => mipsel::get_target_strs(target_triple, os)
481485
};
482486
Config {
483487
os: os,

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub mod back {
9797
pub mod link;
9898
pub mod lto;
9999
pub mod mips;
100+
pub mod mipsel;
100101
pub mod rpath;
101102
pub mod svh;
102103
pub mod target_strs;

src/librustc/middle/trans/adt.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use middle::trans::type_::Type;
6060
use middle::trans::type_of;
6161
use middle::ty;
6262
use middle::ty::Disr;
63-
use syntax::abi::{X86, X86_64, Arm, Mips};
63+
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};
6464
use syntax::ast;
6565
use syntax::attr;
6666
use syntax::attr::IntType;
@@ -367,6 +367,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
367367
// corresponding to `choose_shortest`. However, we don't run on those yet...?
368368
Arm => at_least_32,
369369
Mips => at_least_32,
370+
Mipsel => at_least_32,
370371
}
371372
}
372373
attr::ReprAny => {

src/librustc/middle/trans/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
135135

136136
#[cfg(target_arch = "arm")]
137137
#[cfg(target_arch = "mips")]
138+
#[cfg(target_arch = "mipsel")]
138139
fn get_clobbers() -> String {
139140
"".to_string()
140141
}

src/librustc/middle/trans/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use std::cell::{Cell, RefCell};
8383
use std::rc::Rc;
8484
use std::{i8, i16, i32, i64};
8585
use std::gc::Gc;
86-
use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic};
86+
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel, Rust, RustIntrinsic};
8787
use syntax::ast_util::{local_def, is_local};
8888
use syntax::attr::AttrMetaMethods;
8989
use syntax::attr;
@@ -1021,7 +1021,7 @@ pub fn call_memcpy(cx: &Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef,
10211021
let _icx = push_ctxt("call_memcpy");
10221022
let ccx = cx.ccx();
10231023
let key = match ccx.sess().targ_cfg.arch {
1024-
X86 | Arm | Mips => "llvm.memcpy.p0i8.p0i8.i32",
1024+
X86 | Arm | Mips | Mipsel => "llvm.memcpy.p0i8.p0i8.i32",
10251025
X86_64 => "llvm.memcpy.p0i8.p0i8.i64"
10261026
};
10271027
let memcpy = ccx.get_intrinsic(&key);
@@ -1065,7 +1065,7 @@ fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
10651065
let ccx = b.ccx;
10661066

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

src/librustc/middle/trans/cabi.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::trans::cabi_x86_64;
1616
use middle::trans::cabi_arm;
1717
use middle::trans::cabi_mips;
1818
use middle::trans::type_::Type;
19-
use syntax::abi::{X86, X86_64, Arm, Mips};
19+
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};
2020

2121
#[deriving(Clone, PartialEq)]
2222
pub enum ArgKind {
@@ -110,5 +110,6 @@ pub fn compute_abi_info(ccx: &CrateContext,
110110
X86_64 => cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def),
111111
Arm => cabi_arm::compute_abi_info(ccx, atys, rty, ret_def),
112112
Mips => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
113+
Mipsel => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
113114
}
114115
}

0 commit comments

Comments
 (0)