Skip to content

Commit b31dd54

Browse files
committed
---
yaml --- r: 2288 b: refs/heads/master c: f6c472d h: refs/heads/master v: v3
1 parent d16d29e commit b31dd54

File tree

4 files changed

+51
-21
lines changed

4 files changed

+51
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 593fb195a4c14252909745e6eec0d48a23061611
2+
refs/heads/master: f6c472d816d31d0e497353512abe28a0ed6ab434

trunk/src/comp/back/abi.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ const int n_native_glues = 7;
7272
const int abi_x86_rustboot_cdecl = 1;
7373
const int abi_x86_rustc_fastcall = 2;
7474

75+
tag native_glue_type {
76+
ngt_rust;
77+
ngt_pure_rust;
78+
ngt_cdecl;
79+
}
80+
7581
fn memcpy_glue_name() -> str {
7682
ret "rust_memcpy_glue";
7783
}
@@ -84,11 +90,14 @@ fn vec_append_glue_name() -> str {
8490
ret "rust_vec_append_glue";
8591
}
8692

87-
fn native_glue_name(int n, bool pass_task) -> str {
88-
if (pass_task) {
89-
ret "rust_native_rust_" + util.common.istr(n);
93+
fn native_glue_name(int n, native_glue_type ngt) -> str {
94+
auto prefix;
95+
alt (ngt) {
96+
case (ngt_rust) { prefix = "rust_native_rust_"; }
97+
case (ngt_pure_rust) { prefix = "rust_native_pure_rust_"; }
98+
case (ngt_cdecl) { prefix = "rust_native_cdecl_"; }
9099
}
91-
ret "rust_native_cdecl_" + util.common.istr(n);
100+
ret prefix + util.common.istr(n);
92101
}
93102

94103
fn activate_glue_name() -> str {

trunk/src/comp/back/x86.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ fn rust_yield_glue() -> vec[str] {
209209
+ vec("ret");
210210
}
211211

212-
fn native_glue(int n_args, bool pass_task) -> vec[str] {
212+
fn native_glue(int n_args, abi.native_glue_type ngt) -> vec[str] {
213+
214+
let bool pass_task;
215+
alt (ngt) {
216+
case (abi.ngt_rust) { pass_task = true; }
217+
case (abi.ngt_pure_rust) { pass_task = true; }
218+
case (abi.ngt_cdecl) { pass_task = false; }
219+
}
213220

214221
/*
215222
* 0, 4, 8, 12 are callee-saves
@@ -275,11 +282,12 @@ fn decl_glue(int align, str prefix, str name, vec[str] insns) -> str {
275282
}
276283

277284

278-
fn decl_native_glue(int align, str prefix, bool pass_task, uint n) -> str {
285+
fn decl_native_glue(int align, str prefix, abi.native_glue_type ngt, uint n)
286+
-> str {
279287
let int i = n as int;
280288
ret decl_glue(align, prefix,
281-
abi.native_glue_name(i, pass_task),
282-
native_glue(i, pass_task));
289+
abi.native_glue_name(i, ngt),
290+
native_glue(i, ngt));
283291
}
284292

285293
fn get_symbol_prefix() -> str {
@@ -305,10 +313,12 @@ fn get_module_asm() -> str {
305313
abi.yield_glue_name(),
306314
rust_yield_glue()))
307315

308-
+ _vec.init_fn[str](bind decl_native_glue(align, prefix, true, _),
309-
(abi.n_native_glues + 1) as uint)
310-
+ _vec.init_fn[str](bind decl_native_glue(align, prefix, false, _),
311-
(abi.n_native_glues + 1) as uint);
316+
+ _vec.init_fn[str](bind decl_native_glue(align, prefix,
317+
abi.ngt_rust, _), (abi.n_native_glues + 1) as uint)
318+
+ _vec.init_fn[str](bind decl_native_glue(align, prefix,
319+
abi.ngt_pure_rust, _), (abi.n_native_glues + 1) as uint)
320+
+ _vec.init_fn[str](bind decl_native_glue(align, prefix,
321+
abi.ngt_cdecl, _), (abi.n_native_glues + 1) as uint);
312322

313323

314324
ret _str.connect(glues, "\n\n");

trunk/src/comp/middle/trans.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type glue_fns = rec(ValueRef activate_glue,
5757
ValueRef yield_glue,
5858
ValueRef exit_task_glue,
5959
vec[ValueRef] native_glues_rust,
60+
vec[ValueRef] native_glues_pure_rust,
6061
vec[ValueRef] native_glues_cdecl,
6162
ValueRef no_op_type_glue,
6263
ValueRef memcpy_glue,
@@ -997,17 +998,26 @@ fn decl_glue(ModuleRef llmod, type_names tn, str s) -> ValueRef {
997998
}
998999

9991000
fn decl_native_glue(ModuleRef llmod, type_names tn,
1000-
bool pass_task, uint _n) -> ValueRef {
1001+
abi.native_glue_type ngt, uint _n) -> ValueRef {
1002+
let bool pass_task;
1003+
alt (ngt) {
1004+
case (abi.ngt_rust) { pass_task = true; }
1005+
case (abi.ngt_pure_rust) { pass_task = true; }
1006+
case (abi.ngt_cdecl) { pass_task = false; }
1007+
}
1008+
10011009
// It doesn't actually matter what type we come up with here, at the
10021010
// moment, as we cast the native function pointers to int before passing
10031011
// them to the indirect native-invocation glue. But eventually we'd like
10041012
// to call them directly, once we have a calling convention worked out.
10051013
let int n = _n as int;
1006-
let str s = abi.native_glue_name(n, pass_task);
1014+
let str s = abi.native_glue_name(n, ngt);
10071015
let vec[TypeRef] args = vec(T_int()); // callee
1016+
10081017
if (!pass_task) {
10091018
args += vec(T_int()); // taskptr, will not be passed
10101019
}
1020+
10111021
args += _vec.init_elt[TypeRef](T_int(), n as uint);
10121022

10131023
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 {
76107620
T_void())),
76117621

76127622
native_glues_rust =
7613-
_vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, true,
7614-
_),
7615-
abi.n_native_glues + 1 as uint),
7623+
_vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
7624+
abi.ngt_rust, _), abi.n_native_glues + 1 as uint),
7625+
native_glues_pure_rust =
7626+
_vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
7627+
abi.ngt_pure_rust, _), abi.n_native_glues + 1 as uint),
76167628
native_glues_cdecl =
7617-
_vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn, false,
7618-
_),
7619-
abi.n_native_glues + 1 as uint),
7629+
_vec.init_fn[ValueRef](bind decl_native_glue(llmod, tn,
7630+
abi.ngt_cdecl, _), abi.n_native_glues + 1 as uint),
76207631
no_op_type_glue = decl_no_op_type_glue(llmod, tn),
76217632
memcpy_glue = decl_memcpy_glue(llmod),
76227633
bzero_glue = decl_bzero_glue(llmod),

0 commit comments

Comments
 (0)