diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-03-13 22:25:28 -0400 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-03-29 18:36:20 -0700 |
| commit | 6965fe4bceea836586bd8e7aa01a92a35b467f78 (patch) | |
| tree | d95089f050cd67db2a5171a799763faa09f5b0a8 /src/librustc/driver | |
| parent | f864934f548be9f03d2c0512de8d7e908469e2ae (diff) | |
| download | rust-6965fe4bceea836586bd8e7aa01a92a35b467f78.tar.gz rust-6965fe4bceea836586bd8e7aa01a92a35b467f78.zip | |
Add AbiSet and integrate it into the AST.
I believe this patch incorporates all expected syntax changes from extern
function reform (#3678). You can now write things like:
extern "<abi>" fn foo(s: S) -> T { ... }
extern "<abi>" mod { ... }
extern "<abi>" fn(S) -> T
The ABI for foreign functions is taken from this syntax (rather than from an
annotation). We support the full ABI specification I described on the mailing
list. The correct ABI is chosen based on the target architecture.
Calls by pointer to C functions are not yet supported, and the Rust type of
crust fns is still *u8.
Diffstat (limited to 'src/librustc/driver')
| -rw-r--r-- | src/librustc/driver/driver.rs | 37 | ||||
| -rw-r--r-- | src/librustc/driver/session.rs | 6 |
2 files changed, 21 insertions, 22 deletions
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 93bc64eafa3..5d0ba4bb911 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -33,6 +33,7 @@ use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; use std::getopts::{opt_present}; use std::getopts; use syntax::ast; +use syntax::abi; use syntax::attr; use syntax::codemap; use syntax::diagnostic; @@ -85,10 +86,10 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) -> // ARM is bi-endian, however using NDK seems to default // to little-endian unless a flag is provided. let (end,arch,wordsz) = match sess.targ_cfg.arch { - session::arch_x86 => (~"little",~"x86",~"32"), - session::arch_x86_64 => (~"little",~"x86_64",~"64"), - session::arch_arm => (~"little",~"arm",~"32"), - session::arch_mips => (~"little",~"arm",~"32") + abi::X86 => (~"little",~"x86",~"32"), + abi::X86_64 => (~"little",~"x86_64",~"64"), + abi::Arm => (~"little",~"arm",~"32"), + abi::Mips => (~"little",~"arm",~"32") }; return ~[ // Target bindings. @@ -308,7 +309,7 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg, }; // NOTE: Android hack - if sess.targ_cfg.arch == session::arch_arm && + if sess.targ_cfg.arch == abi::Arm && (sess.opts.output_type == link::output_type_object || sess.opts.output_type == link::output_type_exe) { let output_type = link::output_type_assembly; @@ -453,20 +454,20 @@ pub fn get_os(triple: &str) -> Option<session::os> { } else { None } } -pub fn get_arch(triple: &str) -> Option<session::arch> { +pub fn get_arch(triple: &str) -> Option<abi::Architecture> { if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") || str::contains(triple, ~"i586") || str::contains(triple, ~"i686") || str::contains(triple, ~"i786") { - Some(session::arch_x86) + Some(abi::X86) } else if str::contains(triple, ~"x86_64") { - Some(session::arch_x86_64) + Some(abi::X86_64) } else if str::contains(triple, ~"arm") || str::contains(triple, ~"xscale") { - Some(session::arch_arm) + Some(abi::Arm) } else if str::contains(triple, ~"mips") { - Some(session::arch_mips) + Some(abi::Mips) } else { None } } @@ -483,16 +484,16 @@ pub fn build_target_config(sopts: @session::options, ~"unknown architecture: " + sopts.target_triple) }; let (int_type, uint_type, float_type) = match arch { - session::arch_x86 => (ast::ty_i32, ast::ty_u32, ast::ty_f64), - session::arch_x86_64 => (ast::ty_i64, ast::ty_u64, ast::ty_f64), - session::arch_arm => (ast::ty_i32, ast::ty_u32, ast::ty_f64), - session::arch_mips => (ast::ty_i32, ast::ty_u32, ast::ty_f64) + abi::X86 => (ast::ty_i32, ast::ty_u32, ast::ty_f64), + abi::X86_64 => (ast::ty_i64, ast::ty_u64, ast::ty_f64), + abi::Arm => (ast::ty_i32, ast::ty_u32, ast::ty_f64), + abi::Mips => (ast::ty_i32, ast::ty_u32, ast::ty_f64) }; let target_strs = match arch { - session::arch_x86 => x86::get_target_strs(os), - session::arch_x86_64 => x86_64::get_target_strs(os), - session::arch_arm => arm::get_target_strs(os), - session::arch_mips => mips::get_target_strs(os) + abi::X86 => x86::get_target_strs(os), + abi::X86_64 => x86_64::get_target_strs(os), + abi::Arm => arm::get_target_strs(os), + abi::Mips => mips::get_target_strs(os) }; let target_cfg = @session::config { os: os, diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index d1f95dbeacc..95740e0f837 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -25,19 +25,17 @@ use syntax::codemap::span; use syntax::diagnostic; use syntax::parse::ParseSess; use syntax::{ast, codemap}; +use syntax::abi; use syntax; #[deriving(Eq)] pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, } -#[deriving(Eq)] -pub enum arch { arch_x86, arch_x86_64, arch_arm, arch_mips, } - pub enum crate_type { bin_crate, lib_crate, unknown_crate, } pub struct config { os: os, - arch: arch, + arch: abi::Architecture, target_strs: target_strs::t, int_type: int_ty, uint_type: uint_ty, |
