rustc_target: add abi::call::Conv::Rust distinct from Conv::C.
This commit is contained in:
parent
e93aa104ab
commit
79d908b301
6 changed files with 14 additions and 10 deletions
|
@ -2441,7 +2441,7 @@ where
|
||||||
|
|
||||||
use rustc_target::spec::abi::Abi::*;
|
use rustc_target::spec::abi::Abi::*;
|
||||||
let conv = match cx.tcx().sess.target.target.adjust_abi(sig.abi) {
|
let conv = match cx.tcx().sess.target.target.adjust_abi(sig.abi) {
|
||||||
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::C,
|
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust,
|
||||||
|
|
||||||
// It's the ABI's job to select this, not ours.
|
// It's the ABI's job to select this, not ours.
|
||||||
System => bug!("system abi should be selected elsewhere"),
|
System => bug!("system abi should be selected elsewhere"),
|
||||||
|
|
|
@ -372,7 +372,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
||||||
|
|
||||||
fn llvm_cconv(&self) -> llvm::CallConv {
|
fn llvm_cconv(&self) -> llvm::CallConv {
|
||||||
match self.conv {
|
match self.conv {
|
||||||
Conv::C => llvm::CCallConv,
|
Conv::C | Conv::Rust => llvm::CCallConv,
|
||||||
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
|
Conv::AmdGpuKernel => llvm::AmdGpuKernel,
|
||||||
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
|
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
|
||||||
Conv::Msp430Intr => llvm::Msp430Intr,
|
Conv::Msp430Intr => llvm::Msp430Intr,
|
||||||
|
|
|
@ -6,15 +6,16 @@ use rustc::hir::CodegenFnAttrFlags;
|
||||||
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::session::config::{Sanitizer, OptLevel};
|
use rustc::session::config::{Sanitizer, OptLevel};
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt, Ty};
|
||||||
use rustc::ty::layout::HasTyCtxt;
|
use rustc::ty::layout::HasTyCtxt;
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc_data_structures::small_c_str::SmallCStr;
|
use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
use rustc_target::abi::call::Conv;
|
||||||
use rustc_target::spec::PanicStrategy;
|
use rustc_target::spec::PanicStrategy;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
|
||||||
use crate::abi::Abi;
|
use crate::abi::FnAbi;
|
||||||
use crate::attributes;
|
use crate::attributes;
|
||||||
use crate::llvm::{self, Attribute};
|
use crate::llvm::{self, Attribute};
|
||||||
use crate::llvm::AttributePlace::Function;
|
use crate::llvm::AttributePlace::Function;
|
||||||
|
@ -203,6 +204,7 @@ pub fn from_fn_attrs(
|
||||||
cx: &CodegenCx<'ll, 'tcx>,
|
cx: &CodegenCx<'ll, 'tcx>,
|
||||||
llfn: &'ll Value,
|
llfn: &'ll Value,
|
||||||
instance: ty::Instance<'tcx>,
|
instance: ty::Instance<'tcx>,
|
||||||
|
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||||
) {
|
) {
|
||||||
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
|
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
|
||||||
|
|
||||||
|
@ -279,10 +281,7 @@ pub fn from_fn_attrs(
|
||||||
// Special attribute for allocator functions, which can't unwind.
|
// Special attribute for allocator functions, which can't unwind.
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
// FIXME(eddyb) avoid this `Instance::fn_sig` call.
|
if fn_abi.conv == Conv::Rust {
|
||||||
// Perhaps store the relevant information in `FnAbi`?
|
|
||||||
let abi = instance.fn_sig(cx.tcx()).abi();
|
|
||||||
if abi == Abi::Rust || abi == Abi::RustCall {
|
|
||||||
// Any Rust method (or `extern "Rust" fn` or `extern
|
// Any Rust method (or `extern "Rust" fn` or `extern
|
||||||
// "rust-call" fn`) is explicitly allowed to unwind
|
// "rust-call" fn`) is explicitly allowed to unwind
|
||||||
// (unless it has no-unwind attribute, handled above).
|
// (unless it has no-unwind attribute, handled above).
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub fn get_fn(
|
||||||
let llfn = cx.declare_fn(&sym, &fn_abi);
|
let llfn = cx.declare_fn(&sym, &fn_abi);
|
||||||
debug!("get_fn: not casting pointer!");
|
debug!("get_fn: not casting pointer!");
|
||||||
|
|
||||||
attributes::from_fn_attrs(cx, llfn, instance);
|
attributes::from_fn_attrs(cx, llfn, instance, &fn_abi);
|
||||||
|
|
||||||
let instance_def_id = instance.def_id();
|
let instance_def_id = instance.def_id();
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
|
|
||||||
debug!("predefine_fn: instance = {:?}", instance);
|
debug!("predefine_fn: instance = {:?}", instance);
|
||||||
|
|
||||||
attributes::from_fn_attrs(self, lldecl, instance);
|
attributes::from_fn_attrs(self, lldecl, instance, &fn_abi);
|
||||||
|
|
||||||
self.instances.borrow_mut().insert(instance, lldecl);
|
self.instances.borrow_mut().insert(instance, lldecl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,7 +492,12 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
pub enum Conv {
|
pub enum Conv {
|
||||||
|
// General language calling conventions, for which every target
|
||||||
|
// should have its own backend (e.g. LLVM) support.
|
||||||
C,
|
C,
|
||||||
|
Rust,
|
||||||
|
|
||||||
|
// Target-specific calling conventions.
|
||||||
|
|
||||||
ArmAapcs,
|
ArmAapcs,
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue