rustc: Implement C stack stdcall

This commit is contained in:
Patrick Walton 2011-10-03 13:59:38 -07:00
parent 9be0dc1250
commit 968b66ad40
7 changed files with 19 additions and 2 deletions

View file

@ -54,7 +54,8 @@ fn visit_item(e: env, i: @ast::item) {
alt i.node {
ast::item_native_mod(m) {
if m.abi != ast::native_abi_rust && m.abi != ast::native_abi_cdecl &&
m.abi != ast::native_abi_c_stack_cdecl {
m.abi != ast::native_abi_c_stack_cdecl &&
m.abi != ast::native_abi_c_stack_stdcall {
ret;
}
let cstore = e.sess.get_cstore();

View file

@ -264,6 +264,7 @@ fn parse_ty(st: @pstate, sd: str_def) -> ty::t {
'l' { abi = ast::native_abi_llvm; }
's' { abi = ast::native_abi_x86stdcall; }
'C' { abi = ast::native_abi_c_stack_cdecl; }
'S' { abi = ast::native_abi_c_stack_stdcall; }
}
let func = parse_ty_fn(st, sd);
ret ty::mk_native_fn(st.tcx, abi, func.args, func.ty);

View file

@ -148,6 +148,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
native_abi_llvm. { w.write_char('l'); }
native_abi_x86stdcall. { w.write_char('s'); }
native_abi_c_stack_cdecl. { w.write_char('C'); }
native_abi_c_stack_stdcall. { w.write_char('S'); }
}
enc_ty_fn(w, cx, args, out, return_val, []);
}

View file

@ -5741,7 +5741,8 @@ pure fn native_abi_requires_pair(abi: ast::native_abi) -> bool {
ast::native_abi_rust. | ast::native_abi_cdecl. |
ast::native_abi_llvm. | ast::native_abi_rust_intrinsic. |
ast::native_abi_x86stdcall. { ret true; }
ast::native_abi_c_stack_cdecl. { ret false; }
ast::native_abi_c_stack_cdecl. |
ast::native_abi_c_stack_stdcall. { ret false; }
}
}
@ -5809,6 +5810,13 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
ccx.item_symbols.insert(id, name);
ret;
}
ast::native_abi_c_stack_stdcall. {
let llfn = decl_fn(ccx.llmod, name, lib::llvm::LLVMX86StdcallCallConv,
T_fn([], T_int()));
ccx.item_ids.insert(id, llfn);
ccx.item_symbols.insert(id, name);
ret;
}
}
let path = path;

View file

@ -420,6 +420,7 @@ tag native_abi {
native_abi_rust_intrinsic;
native_abi_x86stdcall;
native_abi_c_stack_cdecl;
native_abi_c_stack_stdcall;
}
type native_mod =

View file

@ -2014,6 +2014,8 @@ fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item {
abi = ast::native_abi_x86stdcall;
} else if str::eq(t, "c-stack-cdecl") {
abi = ast::native_abi_c_stack_cdecl;
} else if str::eq(t, "c-stack-stdcall") {
abi = ast::native_abi_c_stack_stdcall;
} else {
p.fatal("unsupported abi: " + t);
}

View file

@ -411,6 +411,9 @@ fn print_item(s: ps, item: @ast::item) {
ast::native_abi_c_stack_cdecl. {
word_nbsp(s, "\"c-stack-cdecl\"");
}
ast::native_abi_c_stack_stdcall. {
word_nbsp(s, "\"c-stack-stdcall\"");
}
}
word_nbsp(s, "mod");
word_nbsp(s, item.ident);