Stop taking FunctionCx's fn_abi field
This commit is contained in:
parent
69363cf9e7
commit
fee1204ffa
@ -222,17 +222,15 @@ enum ArgKind<'tcx> {
|
||||
Spread(Vec<Option<CValue<'tcx>>>),
|
||||
}
|
||||
|
||||
let fn_abi = fx.fn_abi.take().unwrap();
|
||||
|
||||
// FIXME implement variadics in cranelift
|
||||
if fn_abi.c_variadic {
|
||||
if fx.fn_abi.c_variadic {
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
"Defining variadic functions is not yet supported by Cranelift",
|
||||
);
|
||||
}
|
||||
|
||||
let mut arg_abis_iter = fn_abi.args.iter();
|
||||
let mut arg_abis_iter = fx.fn_abi.args.iter();
|
||||
|
||||
let func_params = fx
|
||||
.mir
|
||||
@ -279,7 +277,6 @@ enum ArgKind<'tcx> {
|
||||
}
|
||||
|
||||
assert!(arg_abis_iter.next().is_none(), "ArgAbi left behind");
|
||||
fx.fn_abi = Some(fn_abi);
|
||||
assert!(block_params_iter.next().is_none(), "arg_value left behind");
|
||||
|
||||
self::comments::add_locals_header_comment(fx);
|
||||
|
@ -12,27 +12,15 @@ pub(super) fn codegen_return_param<'tcx>(
|
||||
ssa_analyzed: &rustc_index::IndexSlice<Local, crate::analyze::SsaKind>,
|
||||
block_params_iter: &mut impl Iterator<Item = Value>,
|
||||
) -> CPlace<'tcx> {
|
||||
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
|
||||
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.ret.mode {
|
||||
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => {
|
||||
let is_ssa =
|
||||
ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.as_ref().unwrap().ret.layout.ty);
|
||||
(
|
||||
super::make_local_place(
|
||||
fx,
|
||||
RETURN_PLACE,
|
||||
fx.fn_abi.as_ref().unwrap().ret.layout,
|
||||
is_ssa,
|
||||
),
|
||||
smallvec![],
|
||||
)
|
||||
let is_ssa = ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.ret.layout.ty);
|
||||
(super::make_local_place(fx, RETURN_PLACE, fx.fn_abi.ret.layout, is_ssa), smallvec![])
|
||||
}
|
||||
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||
let ret_param = block_params_iter.next().unwrap();
|
||||
assert_eq!(fx.bcx.func.dfg.value_type(ret_param), fx.pointer_type);
|
||||
(
|
||||
CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.as_ref().unwrap().ret.layout),
|
||||
smallvec![ret_param],
|
||||
)
|
||||
(CPlace::for_ptr(Pointer::new(ret_param), fx.fn_abi.ret.layout), smallvec![ret_param])
|
||||
}
|
||||
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
|
||||
unreachable!("unsized return value")
|
||||
@ -45,8 +33,8 @@ pub(super) fn codegen_return_param<'tcx>(
|
||||
Some(RETURN_PLACE),
|
||||
None,
|
||||
&ret_param,
|
||||
&fx.fn_abi.as_ref().unwrap().ret.mode,
|
||||
fx.fn_abi.as_ref().unwrap().ret.layout,
|
||||
&fx.fn_abi.ret.mode,
|
||||
fx.fn_abi.ret.layout,
|
||||
);
|
||||
|
||||
ret_place
|
||||
@ -115,7 +103,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
|
||||
|
||||
/// Codegen a return instruction with the right return value(s) if any.
|
||||
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
|
||||
match fx.fn_abi.as_ref().unwrap().ret.mode {
|
||||
match fx.fn_abi.ret.mode {
|
||||
PassMode::Ignore | PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
|
||||
fx.bcx.ins().return_(&[]);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
instance,
|
||||
symbol_name,
|
||||
mir,
|
||||
fn_abi: Some(RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty())),
|
||||
fn_abi: RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty()),
|
||||
|
||||
bcx,
|
||||
block_map,
|
||||
|
@ -291,7 +291,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
||||
pub(crate) instance: Instance<'tcx>,
|
||||
pub(crate) symbol_name: String,
|
||||
pub(crate) mir: &'tcx Body<'tcx>,
|
||||
pub(crate) fn_abi: Option<&'tcx FnAbi<'tcx, Ty<'tcx>>>,
|
||||
pub(crate) fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
|
||||
|
||||
pub(crate) bcx: FunctionBuilder<'clif>,
|
||||
pub(crate) block_map: IndexVec<BasicBlock, Block>,
|
||||
|
Loading…
Reference in New Issue
Block a user