Skip to content

Commit 50fb4be

Browse files
committed
Add Win64 calling convention.
1 parent 3d569df commit 50fb4be

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

src/librustc/lib/llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub enum CallConv {
3333
ColdCallConv = 9,
3434
X86StdcallCallConv = 64,
3535
X86FastcallCallConv = 65,
36+
X86_64_Win64 = 79,
3637
}
3738

3839
pub enum Visibility {

src/librustc/middle/trans/foreign.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use syntax::{ast};
3333
use syntax::{attr, ast_map};
3434
use syntax::parse::token::special_idents;
3535
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System,
36-
Cdecl, Aapcs, C, AbiSet};
36+
Cdecl, Aapcs, C, AbiSet, Win64};
3737
use util::ppaux::{Repr, UserString};
3838
use middle::trans::type_::Type;
3939

@@ -96,6 +96,7 @@ pub fn llvm_calling_convention(ccx: &mut CrateContext,
9696
Stdcall => lib::llvm::X86StdcallCallConv,
9797
Fastcall => lib::llvm::X86FastcallCallConv,
9898
C => lib::llvm::CCallConv,
99+
Win64 => lib::llvm::X86_64_Win64,
99100

100101
// NOTE These API constants ought to be more specific
101102
Cdecl => lib::llvm::CCallConv,

src/libsyntax/abi.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub enum Abi {
2323
Stdcall,
2424
Fastcall,
2525
Aapcs,
26+
Win64,
2627

2728
// Multiplatform ABIs second
2829
Rust,
@@ -73,6 +74,8 @@ static AbiDatas: &'static [AbiData] = &[
7374
AbiData {abi: Stdcall, name: "stdcall", abi_arch: Archs(IntelBits)},
7475
AbiData {abi: Fastcall, name:"fastcall", abi_arch: Archs(IntelBits)},
7576
AbiData {abi: Aapcs, name: "aapcs", abi_arch: Archs(ArmBits)},
77+
AbiData {abi: Win64, name: "win64",
78+
abi_arch: Archs(1 << (X86_64 as uint))},
7679

7780
// Cross-platform ABIs
7881
//
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2013 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+
// Make sure Rust generates the correct calling convention for extern
12+
// functions.
13+
14+
#[inline(never)]
15+
pub extern "win64" fn foo(a: int, b: int, c: int, d: int) {
16+
assert!(a == 1);
17+
assert!(b == 2);
18+
assert!(c == 3);
19+
assert!(d == 4);
20+
21+
println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}",
22+
a, b, c, d)
23+
}
24+
25+
fn main() {
26+
foo(1, 2, 3, 4)
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 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+
// xfail-fast: aux-build not compatible with fast
12+
// aux-build:extern_calling_convention.rs
13+
14+
extern mod extern_calling_convention;
15+
16+
use extern_calling_convention::foo;
17+
18+
fn main() {
19+
foo(1, 2, 3, 4);
20+
}

0 commit comments

Comments
 (0)