Skip to content

Commit

Permalink
rustc_target: rename {Fn,Arg}Type to {Fn,Arg}Abi.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 3, 2019
1 parent 6c1b220 commit 6567154
Show file tree
Hide file tree
Showing 33 changed files with 297 additions and 297 deletions.
24 changes: 12 additions & 12 deletions src/librustc/ty/layout.rs
Expand Up @@ -23,7 +23,7 @@ use rustc_index::vec::{IndexVec, Idx};
pub use rustc_target::abi::*;
use rustc_target::spec::{HasTargetSpec, abi::Abi as SpecAbi};
use rustc_target::abi::call::{
ArgAttribute, ArgAttributes, ArgType, Conv, FnType, PassMode, Reg, RegKind
ArgAttribute, ArgAttributes, ArgAbi, Conv, FnAbi, PassMode, Reg, RegKind
};

pub trait IntegerExt {
Expand Down Expand Up @@ -2502,12 +2502,12 @@ where
cx: &C,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>],
mk_arg_type: impl Fn(Ty<'tcx>, Option<usize>) -> ArgType<'tcx, Ty<'tcx>>,
mk_arg_type: impl Fn(Ty<'tcx>, Option<usize>) -> ArgAbi<'tcx, Ty<'tcx>>,
) -> Self;
fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi);
}

impl<'tcx, C> FnTypeExt<'tcx, C> for call::FnType<'tcx, Ty<'tcx>>
impl<'tcx, C> FnTypeExt<'tcx, C> for call::FnAbi<'tcx, Ty<'tcx>>
where
C: LayoutOf<Ty = Ty<'tcx>, TyLayout = TyLayout<'tcx>>
+ HasDataLayout
Expand All @@ -2520,11 +2520,11 @@ where
let sig = cx
.tcx()
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
call::FnType::new(cx, sig, &[])
call::FnAbi::new(cx, sig, &[])
}

fn new(cx: &C, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self {
call::FnType::new_internal(cx, sig, extra_args, |ty, _| ArgType::new(cx.layout_of(ty)))
call::FnAbi::new_internal(cx, sig, extra_args, |ty, _| ArgAbi::new(cx.layout_of(ty)))
}

fn new_vtable(cx: &C, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self {
Expand Down Expand Up @@ -2578,17 +2578,17 @@ where
layout = cx.layout_of(unit_pointer_ty);
layout.ty = fat_pointer_ty;
}
ArgType::new(layout)
ArgAbi::new(layout)
})
}

fn new_internal(
cx: &C,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>],
mk_arg_type: impl Fn(Ty<'tcx>, Option<usize>) -> ArgType<'tcx, Ty<'tcx>>,
mk_arg_type: impl Fn(Ty<'tcx>, Option<usize>) -> ArgAbi<'tcx, Ty<'tcx>>,
) -> Self {
debug!("FnType::new_internal({:?}, {:?})", sig, extra_args);
debug!("FnAbi::new_internal({:?}, {:?})", sig, extra_args);

use rustc_target::spec::abi::Abi::*;
let conv = match cx.tcx().sess.target.target.adjust_abi(sig.abi) {
Expand Down Expand Up @@ -2741,7 +2741,7 @@ where
arg
};

let mut fn_ty = FnType {
let mut fn_abi = FnAbi {
ret: arg_of(sig.output(), None),
args: inputs
.iter()
Expand All @@ -2753,8 +2753,8 @@ where
c_variadic: sig.c_variadic,
conv,
};
fn_ty.adjust_for_abi(cx, sig.abi);
fn_ty
fn_abi.adjust_for_abi(cx, sig.abi);
fn_abi
}

fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi) {
Expand All @@ -2767,7 +2767,7 @@ where
|| abi == SpecAbi::RustIntrinsic
|| abi == SpecAbi::PlatformIntrinsic
{
let fixup = |arg: &mut ArgType<'tcx, Ty<'tcx>>| {
let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>| {
if arg.is_ignore() {
return;
}
Expand Down
28 changes: 14 additions & 14 deletions src/librustc_codegen_llvm/abi.rs
Expand Up @@ -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::*;

Expand Down Expand Up @@ -179,14 +179,14 @@ pub trait ArgTypeExt<'ll, 'tcx> {
);
}

impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
impl ArgTypeExt<'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.
Expand All @@ -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}.
Expand Down Expand Up @@ -282,21 +282,21 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
impl ArgTypeMethods<'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)
}
}

Expand All @@ -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> FnTypeLlvmExt<'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 } +
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/declare.rs
Expand Up @@ -13,7 +13,7 @@

use crate::llvm;
use crate::llvm::AttributePlace::Function;
use crate::abi::{FnType, FnTypeLlvmExt};
use crate::abi::{FnAbi, FnTypeLlvmExt};
use crate::attributes;
use crate::context::CodegenCx;
use crate::type_::Type;
Expand Down Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_codegen_llvm/intrinsic.rs
@@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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(..) => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/type_.rs
Expand Up @@ -12,7 +12,7 @@ use crate::abi::{LlvmType, FnTypeLlvmExt};
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;

Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/type_of.rs
@@ -1,4 +1,4 @@
use crate::abi::{FnType};
use crate::abi::{FnAbi};
use crate::common::*;
use crate::type_::Type;
use rustc::ty::{self, Ty, TypeFoldable};
Expand Down Expand Up @@ -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)
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_ssa/meth.rs
@@ -1,4 +1,4 @@
use rustc_target::abi::call::FnType;
use rustc_target::abi::call::FnAbi;

use crate::traits::*;

Expand All @@ -20,14 +20,14 @@ impl<'a, 'tcx> VirtualIndex {
self,
bx: &mut Bx,
llvtable: Bx::Value,
fn_ty: &FnType<'tcx, Ty<'tcx>>
fn_abi: &FnAbi<'tcx, Ty<'tcx>>
) -> Bx::Value {
// Load the data pointer from the object.
debug!("get_fn({:?}, {:?})", llvtable, self);

let llvtable = bx.pointercast(
llvtable,
bx.type_ptr_to(bx.fn_ptr_backend_type(fn_ty))
bx.type_ptr_to(bx.fn_ptr_backend_type(fn_abi))
);
let ptr_align = bx.tcx().data_layout.pointer_align.abi;
let gep = bx.inbounds_gep(llvtable, &[bx.const_usize(self.0)]);
Expand Down

0 comments on commit 6567154

Please sign in to comment.