Auto merge of #30567 - steffengy:master, r=alexcrichton
Add support to use functions exported using vectorcall. This essentially only allows to pass a new LLVM calling convention from rust to LLVM. ```rust extern "vectorcall" fn abc(param: c_void); ``` references ---- http://llvm.org/docs/doxygen/html/CallingConv_8h_source.html https://msdn.microsoft.com/en-us/library/dn375768.aspx
This commit is contained in:
commit
077f4eeb84
@ -478,6 +478,8 @@ are:
|
||||
* `aapcs`
|
||||
* `cdecl`
|
||||
* `fastcall`
|
||||
* `vectorcall`
|
||||
This is currently hidden behind the `abi_vectorcall` gate and is subject to change.
|
||||
* `Rust`
|
||||
* `rust-intrinsic`
|
||||
* `system`
|
||||
|
@ -2390,6 +2390,9 @@ The currently implemented features of the reference compiler are:
|
||||
|
||||
* - `type_ascription` - Allows type ascription expressions `expr: Type`.
|
||||
|
||||
* - `abi_vectorcall` - Allows the usage of the vectorcall calling convention
|
||||
(e.g. `extern "vectorcall" func fn_();`)
|
||||
|
||||
If a feature is promoted to a language feature, then all existing programs will
|
||||
start to receive compilation warnings about `#![feature]` directives which enabled
|
||||
the new feature (because the directive is no longer necessary). However, if a
|
||||
|
@ -85,6 +85,7 @@ pub enum CallConv {
|
||||
X86StdcallCallConv = 64,
|
||||
X86FastcallCallConv = 65,
|
||||
X86_64_Win64 = 79,
|
||||
X86_VectorCall = 80
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -35,7 +35,8 @@ use std::cmp;
|
||||
use std::iter::once;
|
||||
use libc::c_uint;
|
||||
use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
|
||||
use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
|
||||
use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall};
|
||||
use syntax::abi::{Fastcall, Vectorcall, System};
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::{InternedString, special_idents};
|
||||
@ -104,6 +105,7 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
|
||||
|
||||
Stdcall => llvm::X86StdcallCallConv,
|
||||
Fastcall => llvm::X86FastcallCallConv,
|
||||
Vectorcall => llvm::X86_VectorCall,
|
||||
C => llvm::CCallConv,
|
||||
Win64 => llvm::X86_64_Win64,
|
||||
|
||||
|
@ -39,6 +39,7 @@ pub enum Abi {
|
||||
Cdecl,
|
||||
Stdcall,
|
||||
Fastcall,
|
||||
Vectorcall,
|
||||
Aapcs,
|
||||
Win64,
|
||||
|
||||
@ -85,6 +86,7 @@ const AbiDatas: &'static [AbiData] = &[
|
||||
AbiData {abi: Cdecl, name: "cdecl" },
|
||||
AbiData {abi: Stdcall, name: "stdcall" },
|
||||
AbiData {abi: Fastcall, name: "fastcall" },
|
||||
AbiData {abi: Vectorcall, name: "vectorcall"},
|
||||
AbiData {abi: Aapcs, name: "aapcs" },
|
||||
AbiData {abi: Win64, name: "win64" },
|
||||
|
||||
|
@ -239,6 +239,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status
|
||||
|
||||
// Allows cfg(target_thread_local)
|
||||
("cfg_target_thread_local", "1.7.0", Some(29594), Active),
|
||||
|
||||
// rustc internal
|
||||
("abi_vectorcall", "1.7.0", None, Active)
|
||||
];
|
||||
// (changing above list without updating src/doc/reference.md makes @cmr sad)
|
||||
|
||||
@ -872,6 +875,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
Abi::PlatformIntrinsic => {
|
||||
Some(("platform_intrinsics",
|
||||
"platform intrinsics are experimental and possibly buggy"))
|
||||
},
|
||||
Abi::Vectorcall => {
|
||||
Some(("abi_vectorcall",
|
||||
"vectorcall is experimental and subject to change"
|
||||
))
|
||||
}
|
||||
_ => None
|
||||
};
|
||||
@ -1045,11 +1053,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
"intrinsics are subject to change")
|
||||
}
|
||||
FnKind::ItemFn(_, _, _, _, abi, _) |
|
||||
FnKind::Method(_, &ast::MethodSig { abi, .. }, _) if abi == Abi::RustCall => {
|
||||
self.gate_feature("unboxed_closures",
|
||||
span,
|
||||
"rust-call ABI is subject to change")
|
||||
}
|
||||
FnKind::Method(_, &ast::MethodSig { abi, .. }, _) => match abi {
|
||||
Abi::RustCall => {
|
||||
self.gate_feature("unboxed_closures", span,
|
||||
"rust-call ABI is subject to change");
|
||||
},
|
||||
Abi::Vectorcall => {
|
||||
self.gate_feature("abi_vectorcall", span,
|
||||
"vectorcall is experimental and subject to change");
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_fn(self, fn_kind, fn_decl, block, span);
|
||||
|
19
src/test/compile-fail/feature-gate-abi-vectorcall.rs
Normal file
19
src/test/compile-fail/feature-gate-abi-vectorcall.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
extern "vectorcall" { //~ ERROR vectorcall is experimental and subject to change
|
||||
fn bar();
|
||||
}
|
||||
|
||||
extern "vectorcall" fn baz() { //~ ERROR vectorcall is experimental and subject to change
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
32
src/test/run-pass/extern-vectorcall.rs
Normal file
32
src/test/run-pass/extern-vectorcall.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
#![feature(abi_vectorcall)]
|
||||
|
||||
trait A {
|
||||
extern "vectorcall" fn test1(i: i32);
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl A for S {
|
||||
extern "vectorcall" fn test1(i: i32) {
|
||||
assert_eq!(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
extern "vectorcall" fn test2(i: i32) {
|
||||
assert_eq!(i, 2);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
<S as A>::test1(1);
|
||||
test2(2);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user