Skip to content

Commit 717da95

Browse files
committed
Create "platform-intrinsic" ABI for SIMD/platform intrinsics.
This is purposely separate to the "rust-intrinsic" ABI, because these intrinsics are theoretically going to become stable, and should be fine to be independent of the compiler/language internals since they're intimately to the platform.
1 parent 5889127 commit 717da95

File tree

10 files changed

+207
-139
lines changed

10 files changed

+207
-139
lines changed

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'a, 'b> LocalCrateReader<'a, 'b> {
704704
}
705705

706706
fn process_foreign_mod(&mut self, i: &ast::Item, fm: &ast::ForeignMod) {
707-
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
707+
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic || fm.abi == abi::PlatformIntrinsic {
708708
return;
709709
}
710710

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
15011501
encode_family(rbml_w, FN_FAMILY);
15021502
encode_bounds_and_type_for_item(rbml_w, ecx, nitem.id);
15031503
encode_name(rbml_w, nitem.ident.name);
1504-
if abi == abi::RustIntrinsic {
1504+
if abi == abi::RustIntrinsic || abi == abi::PlatformIntrinsic {
15051505
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem));
15061506
}
15071507
encode_attributes(rbml_w, &*nitem.attrs);

src/librustc_lint/builtin.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
603603
match bare_fn.abi {
604604
abi::Rust |
605605
abi::RustIntrinsic |
606+
abi::PlatformIntrinsic |
606607
abi::RustCall => {
607608
return FfiUnsafe(
608609
"found function pointer with Rust calling \
@@ -717,7 +718,9 @@ impl LintPass for ImproperCTypes {
717718
}
718719

719720
match it.node {
720-
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
721+
ast::ItemForeignMod(ref nmod)
722+
if nmod.abi != abi::RustIntrinsic &&
723+
nmod.abi != abi::PlatformIntrinsic => {
721724
for ni in &nmod.items {
722725
match ni.node {
723726
ast::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl),

src/librustc_trans/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use std::collections::{HashMap, HashSet};
9191
use std::mem;
9292
use std::str;
9393
use std::{i8, i16, i32, i64};
94-
use syntax::abi::{Rust, RustCall, RustIntrinsic, Abi};
94+
use syntax::abi::{Rust, RustCall, RustIntrinsic, PlatformIntrinsic, Abi};
9595
use syntax::ast_util::local_def;
9696
use syntax::attr::AttrMetaMethods;
9797
use syntax::attr;
@@ -671,7 +671,7 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
671671
Rust | RustCall => {
672672
get_extern_rust_fn(ccx, t, &name[..], did)
673673
}
674-
RustIntrinsic => {
674+
RustIntrinsic | PlatformIntrinsic => {
675675
ccx.sess().bug("unexpected intrinsic in trans_external_path")
676676
}
677677
_ => {

src/librustc_trans/trans/callee.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
150150
}
151151
}
152152
def::DefFn(did, _) if match expr_ty.sty {
153-
ty::TyBareFn(_, ref f) => f.abi == synabi::RustIntrinsic,
153+
ty::TyBareFn(_, ref f) => f.abi == synabi::RustIntrinsic ||
154+
f.abi == synabi::PlatformIntrinsic,
154155
_ => false
155156
} => {
156157
let substs = common::node_id_substs(bcx.ccx(),
@@ -671,7 +672,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
671672
(d.llfn, Some(d.llself))
672673
}
673674
Intrinsic(node, substs) => {
674-
assert!(abi == synabi::RustIntrinsic);
675+
assert!(abi == synabi::RustIntrinsic || abi == synabi::PlatformIntrinsic);
675676
assert!(dest.is_some());
676677

677678
let call_info = match debug_loc {
@@ -701,7 +702,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
701702

702703
// Intrinsics should not become actual functions.
703704
// We trans them in place in `trans_intrinsic_call`
704-
assert!(abi != synabi::RustIntrinsic);
705+
assert!(abi != synabi::RustIntrinsic && abi != synabi::PlatformIntrinsic);
705706

706707
let is_rust_fn = abi == synabi::Rust || abi == synabi::RustCall;
707708

src/librustc_trans/trans/foreign.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use middle::subst::Substs;
3434
use std::cmp;
3535
use libc::c_uint;
3636
use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
37-
use syntax::abi::{RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
37+
use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
3838
use syntax::codemap::Span;
3939
use syntax::parse::token::{InternedString, special_idents};
4040
use syntax::ast;
@@ -81,6 +81,10 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
8181
// Intrinsics are emitted at the call site
8282
ccx.sess().bug("asked to register intrinsic fn");
8383
}
84+
PlatformIntrinsic => {
85+
// Intrinsics are emitted at the call site
86+
ccx.sess().bug("asked to register platform intrinsic fn");
87+
}
8488

8589
Rust => {
8690
// FIXME(#3678) Implement linking to foreign fns with Rust ABI
@@ -475,7 +479,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
475479

476480
if let ast::ForeignItemFn(ref decl, _) = foreign_item.node {
477481
match foreign_mod.abi {
478-
Rust | RustIntrinsic => {}
482+
Rust | RustIntrinsic | PlatformIntrinsic => {}
479483
abi => {
480484
let ty = ccx.tcx().node_id_to_type(foreign_item.id);
481485
match ty.sty {
@@ -612,7 +616,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
612616
// normal Rust function. This will be the type of the wrappee fn.
613617
match t.sty {
614618
ty::TyBareFn(_, ref f) => {
615-
assert!(f.abi != Rust && f.abi != RustIntrinsic);
619+
assert!(f.abi != Rust && f.abi != RustIntrinsic && f.abi != PlatformIntrinsic);
616620
}
617621
_ => {
618622
ccx.sess().bug(&format!("build_rust_fn: extern fn {} has ty {:?}, \

src/librustc_trans/trans/monomorphize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
9090
});
9191

9292
if let ast_map::NodeForeignItem(_) = map_node {
93-
if ccx.tcx().map.get_foreign_abi(fn_id.node) != abi::RustIntrinsic {
93+
let abi = ccx.tcx().map.get_foreign_abi(fn_id.node);
94+
if abi != abi::RustIntrinsic && abi != abi::PlatformIntrinsic {
9495
// Foreign externs don't have to be monomorphized.
9596
return (get_item_val(ccx, fn_id.node), mono_ty, true);
9697
}

0 commit comments

Comments
 (0)