Auto merge of #65938 - eddyb:fn-abi-rename, r=oli-obk
rustc_target: rename {Fn,Arg}Type to {Fn,Arg}Abi.
I was trying to tweak the API of `FnType` (now `FnAbi`) and the name kept bothering me.
`FnAbi` is to a function signature a bit like a layout is to a type, so the name still isn't perfect yet, but at least it doesn't have the misleading `Type` in it anymore.
If this can't land I think I can continue my original refactor without it, so I'm not strongly attached to it.
r? @nagisa cc @oli-obk
This commit is contained in:
commit
2e4da3caad
35 changed files with 311 additions and 311 deletions
|
|
@ -7,7 +7,7 @@ use crate::type_of::{LayoutLlvmExt};
|
|||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||
use rustc_codegen_ssa::mir::operand::OperandValue;
|
||||
use rustc_target::abi::call::ArgType;
|
||||
use rustc_target::abi::call::ArgAbi;
|
||||
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ impl LlvmType for CastTarget {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ArgTypeExt<'ll, 'tcx> {
|
||||
pub trait ArgAbiExt<'ll, 'tcx> {
|
||||
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||
fn store(
|
||||
&self,
|
||||
|
|
@ -179,14 +179,14 @@ pub trait ArgTypeExt<'ll, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
|
||||
impl ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
|
||||
/// Gets the LLVM type for a place of the original Rust type of
|
||||
/// this argument/return, i.e., the result of `type_of::type_of`.
|
||||
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
|
||||
self.layout.llvm_type(cx)
|
||||
}
|
||||
|
||||
/// Stores a direct/indirect value described by this ArgType into a
|
||||
/// Stores a direct/indirect value described by this ArgAbi into a
|
||||
/// place for the original Rust type of this argument/return.
|
||||
/// Can be used for both storing formal arguments into Rust variables
|
||||
/// or results of call/invoke instructions into their destinations.
|
||||
|
|
@ -202,7 +202,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
|
|||
if self.is_sized_indirect() {
|
||||
OperandValue::Ref(val, None, self.layout.align.abi).store(bx, dst)
|
||||
} else if self.is_unsized_indirect() {
|
||||
bug!("unsized ArgType must be handled through store_fn_arg");
|
||||
bug!("unsized ArgAbi must be handled through store_fn_arg");
|
||||
} else if let PassMode::Cast(cast) = self.mode {
|
||||
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
|
||||
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
|
||||
|
|
@ -279,28 +279,28 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ArgTypeMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
fn store_fn_arg(
|
||||
&mut self,
|
||||
ty: &ArgType<'tcx, Ty<'tcx>>,
|
||||
arg_abi: &ArgAbi<'tcx, Ty<'tcx>>,
|
||||
idx: &mut usize, dst: PlaceRef<'tcx, Self::Value>
|
||||
) {
|
||||
ty.store_fn_arg(self, idx, dst)
|
||||
arg_abi.store_fn_arg(self, idx, dst)
|
||||
}
|
||||
fn store_arg_ty(
|
||||
fn store_arg(
|
||||
&mut self,
|
||||
ty: &ArgType<'tcx, Ty<'tcx>>,
|
||||
arg_abi: &ArgAbi<'tcx, Ty<'tcx>>,
|
||||
val: &'ll Value,
|
||||
dst: PlaceRef<'tcx, &'ll Value>
|
||||
) {
|
||||
ty.store(self, val, dst)
|
||||
arg_abi.store(self, val, dst)
|
||||
}
|
||||
fn memory_ty(&self, ty: &ArgType<'tcx, Ty<'tcx>>) -> &'ll Type {
|
||||
ty.memory_ty(self)
|
||||
fn arg_memory_ty(&self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
|
||||
arg_abi.memory_ty(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FnTypeLlvmExt<'tcx> {
|
||||
pub trait FnAbiLlvmExt<'tcx> {
|
||||
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
|
||||
fn llvm_cconv(&self) -> llvm::CallConv;
|
||||
|
|
@ -308,7 +308,7 @@ pub trait FnTypeLlvmExt<'tcx> {
|
|||
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value);
|
||||
}
|
||||
|
||||
impl<'tcx> FnTypeLlvmExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
|
||||
impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
||||
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
|
||||
let args_capacity: usize = self.args.iter().map(|arg|
|
||||
if arg.pad.is_some() { 1 } else { 0 } +
|
||||
|
|
@ -478,10 +478,10 @@ impl<'tcx> FnTypeLlvmExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
|
|||
impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
fn apply_attrs_callsite(
|
||||
&mut self,
|
||||
ty: &FnType<'tcx, Ty<'tcx>>,
|
||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
callsite: Self::Value
|
||||
) {
|
||||
ty.apply_attrs_callsite(self, callsite)
|
||||
fn_abi.apply_attrs_callsite(self, callsite)
|
||||
}
|
||||
|
||||
fn get_param(&self, index: usize) -> Self::Value {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
use crate::llvm;
|
||||
use crate::llvm::AttributePlace::Function;
|
||||
use crate::abi::{FnType, FnTypeLlvmExt};
|
||||
use crate::abi::{FnAbi, FnAbiLlvmExt};
|
||||
use crate::attributes;
|
||||
use crate::context::CodegenCx;
|
||||
use crate::type_::Type;
|
||||
use crate::value::Value;
|
||||
use rustc::ty::{self, PolyFnSig};
|
||||
use rustc::ty::layout::{FnTypeExt, LayoutOf};
|
||||
use rustc::ty::layout::{FnAbiExt, LayoutOf};
|
||||
use rustc::session::config::Sanitizer;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
|
@ -100,14 +100,14 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
let sig = self.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
|
||||
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
|
||||
|
||||
let fty = FnType::new(self, sig, &[]);
|
||||
let llfn = declare_raw_fn(self, name, fty.llvm_cconv(), fty.llvm_type(self));
|
||||
let fn_abi = FnAbi::new(self, sig, &[]);
|
||||
let llfn = declare_raw_fn(self, name, fn_abi.llvm_cconv(), fn_abi.llvm_type(self));
|
||||
|
||||
if self.layout_of(sig.output()).abi.is_uninhabited() {
|
||||
llvm::Attribute::NoReturn.apply_llfn(Function, llfn);
|
||||
}
|
||||
|
||||
fty.apply_attrs_llfn(self, llfn);
|
||||
fn_abi.apply_attrs_llfn(self, llfn);
|
||||
|
||||
llfn
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::attributes;
|
||||
use crate::llvm;
|
||||
use crate::llvm_util;
|
||||
use crate::abi::{Abi, FnType, LlvmType, PassMode};
|
||||
use crate::abi::{Abi, FnAbi, LlvmType, PassMode};
|
||||
use crate::context::CodegenCx;
|
||||
use crate::type_::Type;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
|
|
@ -84,7 +84,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
fn codegen_intrinsic_call(
|
||||
&mut self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
fn_ty: &FnType<'tcx, Ty<'tcx>>,
|
||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||
args: &[OperandRef<'tcx, &'ll Value>],
|
||||
llresult: &'ll Value,
|
||||
span: Span,
|
||||
|
|
@ -104,7 +104,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
let name = &*tcx.item_name(def_id).as_str();
|
||||
|
||||
let llret_ty = self.layout_of(ret_ty).llvm_type(self);
|
||||
let result = PlaceRef::new_sized(llresult, fn_ty.ret.layout);
|
||||
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
|
||||
|
||||
let simple = get_simple_intrinsic(self, name);
|
||||
let llval = match name {
|
||||
|
|
@ -147,7 +147,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
self.call(intrinsic, &[args[0].immediate(), args[1].immediate()], None)
|
||||
}
|
||||
"va_arg" => {
|
||||
match fn_ty.ret.layout.abi {
|
||||
match fn_abi.ret.layout.abi {
|
||||
layout::Abi::Scalar(ref scalar) => {
|
||||
match scalar.value {
|
||||
Primitive::Int(..) => {
|
||||
|
|
@ -276,7 +276,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
"volatile_load" | "unaligned_volatile_load" => {
|
||||
let tp_ty = substs.type_at(0);
|
||||
let mut ptr = args[0].immediate();
|
||||
if let PassMode::Cast(ty) = fn_ty.ret.mode {
|
||||
if let PassMode::Cast(ty) = fn_abi.ret.mode {
|
||||
ptr = self.pointercast(ptr, self.type_ptr_to(ty.llvm_type(self)));
|
||||
}
|
||||
let load = self.volatile_load(ptr);
|
||||
|
|
@ -715,8 +715,8 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
|||
_ => bug!("unknown intrinsic '{}'", name),
|
||||
};
|
||||
|
||||
if !fn_ty.ret.is_ignore() {
|
||||
if let PassMode::Cast(ty) = fn_ty.ret.mode {
|
||||
if !fn_abi.ret.is_ignore() {
|
||||
if let PassMode::Cast(ty) = fn_abi.ret.mode {
|
||||
let ptr_llty = self.type_ptr_to(ty.llvm_type(self));
|
||||
let ptr = self.pointercast(result.llval, ptr_llty);
|
||||
self.store(llval, ptr, result.align);
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ use rustc_codegen_ssa::traits::*;
|
|||
|
||||
use crate::common;
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::abi::{LlvmType, FnTypeLlvmExt};
|
||||
use crate::abi::{LlvmType, FnAbiLlvmExt};
|
||||
use syntax::ast;
|
||||
use rustc::ty::Ty;
|
||||
use rustc::ty::layout::{self, Align, Size, TyLayout};
|
||||
use rustc_target::abi::call::{CastTarget, FnType, Reg};
|
||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
|
||||
fn type_ptr_to(&self, ty: &'ll Type) -> &'ll Type {
|
||||
assert_ne!(self.type_kind(ty), TypeKind::Function,
|
||||
"don't call ptr_to on function types, use ptr_to_llvm_type on FnType instead");
|
||||
"don't call ptr_to on function types, use ptr_to_llvm_type on FnAbi instead");
|
||||
ty.ptr_to()
|
||||
}
|
||||
|
||||
|
|
@ -336,8 +336,8 @@ impl LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
fn cast_backend_type(&self, ty: &CastTarget) -> &'ll Type {
|
||||
ty.llvm_type(self)
|
||||
}
|
||||
fn fn_ptr_backend_type(&self, ty: &FnType<'tcx, Ty<'tcx>>) -> &'ll Type {
|
||||
ty.ptr_to_llvm_type(self)
|
||||
fn fn_ptr_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
|
||||
fn_abi.ptr_to_llvm_type(self)
|
||||
}
|
||||
fn reg_backend_type(&self, ty: &Reg) -> &'ll Type {
|
||||
ty.llvm_type(self)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::abi::{FnType};
|
||||
use crate::abi::{FnAbi};
|
||||
use crate::common::*;
|
||||
use crate::type_::Type;
|
||||
use rustc::ty::{self, Ty, TypeFoldable};
|
||||
use rustc::ty::layout::{self, Align, LayoutOf, FnTypeExt, PointeeInfo, Size, TyLayout};
|
||||
use rustc::ty::layout::{self, Align, LayoutOf, FnAbiExt, PointeeInfo, Size, TyLayout};
|
||||
use rustc_target::abi::{FloatTy, TyLayoutMethods};
|
||||
use rustc::ty::print::obsolete::DefPathBasedNames;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
|
|
@ -239,7 +239,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
|||
ty::ParamEnv::reveal_all(),
|
||||
&sig,
|
||||
);
|
||||
cx.fn_ptr_backend_type(&FnType::new(cx, sig, &[]))
|
||||
cx.fn_ptr_backend_type(&FnAbi::new(cx, sig, &[]))
|
||||
}
|
||||
_ => self.scalar_llvm_type_at(cx, scalar, Size::ZERO)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue