diff options
| author | Patrick Walton <[email protected]> | 2011-04-29 16:40:30 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-29 16:40:30 -0700 |
| commit | f6c472d816d31d0e497353512abe28a0ed6ab434 (patch) | |
| tree | 3ee487110a24cce1c6c4bf40bd33c46c575d34a2 /src | |
| parent | rustc: Start threading a purity flag through upcalls (diff) | |
| download | rust-f6c472d816d31d0e497353512abe28a0ed6ab434.tar.xz rust-f6c472d816d31d0e497353512abe28a0ed6ab434.zip | |
rustc: Emit pure native glue; we don't call it yet
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/back/abi.rs | 17 | ||||
| -rw-r--r-- | src/comp/back/x86.rs | 26 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 27 |
3 files changed, 50 insertions, 20 deletions
diff --git a/src/comp/back/abi.rs b/src/comp/back/abi.rs index 39c176dc..fc3bc92e 100644 --- a/src/comp/back/abi.rs +++ b/src/comp/back/abi.rs @@ -72,6 +72,12 @@ const int n_native_glues = 7; const int abi_x86_rustboot_cdecl = 1; const int abi_x86_rustc_fastcall = 2; +tag native_glue_type { + ngt_rust; + ngt_pure_rust; + ngt_cdecl; +} + fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; } @@ -84,11 +90,14 @@ fn vec_append_glue_name() -> str { ret "rust_vec_append_glue"; } -fn native_glue_name(int n, bool pass_task) -> str { - if (pass_task) { - ret "rust_native_rust_" + util.common.istr(n); +fn native_glue_name(int n, native_glue_type ngt) -> str { + auto prefix; + alt (ngt) { + case (ngt_rust) { prefix = "rust_native_rust_"; } + case (ngt_pure_rust) { prefix = "rust_native_pure_rust_"; } + case (ngt_cdecl) { prefix = "rust_native_cdecl_"; } } - ret "rust_native_cdecl_" + util.common.istr(n); + ret prefix + util.common.istr(n); } fn activate_glue_name() -> str { diff --git a/src/comp/back/x86.rs b/src/comp/back/x86.rs index 09b18309..063afe03 100644 --- a/src/comp/back/x86.rs +++ b/src/comp/back/x86.rs @@ -209,7 +209,14 @@ fn rust_yield_glue() -> vec[str] { + vec("ret"); } -fn native_glue(int n_args, bool pass_task) -> vec[str] { +fn native_glue(int n_args, abi.native_glue_type ngt) -> vec[str] { + + let bool pass_task; + alt (ngt) { + case (abi.ngt_rust) { pass_task = true; } + case (abi.ngt_pure_rust) { pass_task = true; } + case (abi.ngt_cdecl) { pass_task = false; } + } /* * 0, 4, 8, 12 are callee-saves @@ -275,11 +282,12 @@ fn decl_glue(int align, str prefix, str name, vec[str] insns) -> str { } -fn decl_native_glue(int align, str prefix, bool pass_task, uint n) -> str { +fn decl_native_glue(int align, str prefix, abi.native_glue_type ngt, uint n) + -> str { let int i = n as int; ret decl_glue(align, prefix, - abi.native_glue_name(i, pass_task), - native_glue(i, pass_task)); + abi.native_glue_name(i, ngt), + native_glue(i, ngt)); } fn get_symbol_prefix() -> str { @@ -305,10 +313,12 @@ fn get_module_asm() -> str { abi.yield_glue_name(), rust_yield_glue())) - + _vec.init_fn[str](bind decl_native_glue(align, prefix, true, _), - (abi.n_native_glues + 1) as uint) - + _vec.init_fn[str](bind decl_native_glue(align, prefix, false, _), - (abi.n_native_glues + 1) as uint); + + _vec.init_fn[str](bind decl_native_glue(align, prefix, + abi.ngt_rust, _), (abi.n_native_glues + 1) as uint) + + _vec.init_fn[str](bind decl_native_glue(align, prefix, + abi.ngt_pure_rust, _), (abi.n_native_glues + 1) as uint) + + _vec.init_fn[str](bind decl_native_glue(align, prefix, + abi.ngt_cdecl, _), (abi.n_native_glues + 1) as uint); ret _str.connect(glues, "\n\n"); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index cb6badf4..1447c643 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -57,6 +57,7 @@ type glue_fns = rec(ValueRef activate_glue, ValueRef yield_glue, ValueRef exit_task_glue, vec[ValueRef] native_glues_rust, + vec[ValueRef] native_glues_pure_rust, vec[ValueRef] native_glues_cdecl, ValueRef no_op_type_glue, ValueRef memcpy_glue, @@ -997,17 +998,26 @@ fn decl_glue(ModuleRef llmod, type_names tn, str s) -> ValueRef { } fn decl_native_glue(ModuleRef llmod, type_names tn, - bool pass_task, uint _n) -> ValueRef { + abi.native_glue_type ngt, uint _n) -> ValueRef { + let bool pass_task; + alt (ngt) { + case (abi.ngt_rust) { pass_task = true; } + case (abi.ngt_pure_rust) { pass_task = true; } + case (abi.ngt_cdecl) { pass_task = false; } + } + // It doesn't actually matter what type we come up with here, at the // moment, as we cast the native function pointers to int before passing // them to the indirect native-invocation glue. But eventually we'd like // to call them directly, once we have a calling convention worked out. let int n = _n as int; - let str s = abi.native_glue_name(n, pass_task); + let str s = abi.native_glue_name(n, ngt); let vec[TypeRef] args = vec(T_int()); // callee + if (!pass_task) { args += vec(T_int()); // taskptr, will not be passed } + args += _vec.init_elt[TypeRef](T_int(), n as uint); ret decl_fastcall_fn(llmod, s, T_fn(args, T_int())); @@ -7610,13 +7620,14 @@ fn make_glues(ModuleRef llmod, type_names tn) -> @glue_fns { T_void())), native_glues_rust = - _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, true, - _), - abi.n_native_glues + 1 as uint), + _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + abi.ngt_rust, _), abi.n_native_glues + 1 as uint), + native_glues_pure_rust = + _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + abi.ngt_pure_rust, _), abi.n_native_glues + 1 as uint), native_glues_cdecl = - _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, false, - _), - abi.n_native_glues + 1 as uint), + _vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, + abi.ngt_cdecl, _), abi.n_native_glues + 1 as uint), no_op_type_glue = decl_no_op_type_glue(llmod, tn), memcpy_glue = decl_memcpy_glue(llmod), bzero_glue = decl_bzero_glue(llmod), |