Add Win64 calling convention.

This commit is contained in:
Eric Holk 2013-11-16 18:25:56 -05:00
parent 3d569df41d
commit 50fb4be1cc
5 changed files with 53 additions and 1 deletions

View file

@ -33,6 +33,7 @@ pub enum CallConv {
ColdCallConv = 9,
X86StdcallCallConv = 64,
X86FastcallCallConv = 65,
X86_64_Win64 = 79,
}
pub enum Visibility {

View file

@ -33,7 +33,7 @@ use syntax::{ast};
use syntax::{attr, ast_map};
use syntax::parse::token::special_idents;
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System,
Cdecl, Aapcs, C, AbiSet};
Cdecl, Aapcs, C, AbiSet, Win64};
use util::ppaux::{Repr, UserString};
use middle::trans::type_::Type;
@ -96,6 +96,7 @@ pub fn llvm_calling_convention(ccx: &mut CrateContext,
Stdcall => lib::llvm::X86StdcallCallConv,
Fastcall => lib::llvm::X86FastcallCallConv,
C => lib::llvm::CCallConv,
Win64 => lib::llvm::X86_64_Win64,
// NOTE These API constants ought to be more specific
Cdecl => lib::llvm::CCallConv,

View file

@ -23,6 +23,7 @@ pub enum Abi {
Stdcall,
Fastcall,
Aapcs,
Win64,
// Multiplatform ABIs second
Rust,
@ -73,6 +74,8 @@ static AbiDatas: &'static [AbiData] = &[
AbiData {abi: Stdcall, name: "stdcall", abi_arch: Archs(IntelBits)},
AbiData {abi: Fastcall, name:"fastcall", abi_arch: Archs(IntelBits)},
AbiData {abi: Aapcs, name: "aapcs", abi_arch: Archs(ArmBits)},
AbiData {abi: Win64, name: "win64",
abi_arch: Archs(1 << (X86_64 as uint))},
// Cross-platform ABIs
//

View file

@ -0,0 +1,27 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Make sure Rust generates the correct calling convention for extern
// functions.
#[inline(never)]
pub extern "win64" fn foo(a: int, b: int, c: int, d: int) {
assert!(a == 1);
assert!(b == 2);
assert!(c == 3);
assert!(d == 4);
println!("a: {:?}, b: {:?}, c: {:?}, d: {:?}",
a, b, c, d)
}
fn main() {
foo(1, 2, 3, 4)
}

View file

@ -0,0 +1,20 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-fast: aux-build not compatible with fast
// aux-build:extern_calling_convention.rs
extern mod extern_calling_convention;
use extern_calling_convention::foo;
fn main() {
foo(1, 2, 3, 4);
}