Skip to content

Commit a795a03

Browse files
committed
Remove triple method from FunctionCx
Instead use the default_call_conv field on TargetFrontendConfig to get the default CallConv.
1 parent fdd0f8a commit a795a03

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

src/abi/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ pub(crate) use self::returning::codegen_return;
1818

1919
fn clif_sig_from_fn_abi<'tcx>(
2020
tcx: TyCtxt<'tcx>,
21-
triple: &target_lexicon::Triple,
21+
default_call_conv: CallConv,
2222
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
2323
) -> Signature {
2424
let call_conv = match fn_abi.conv {
25-
Conv::Rust | Conv::C => CallConv::triple_default(triple),
25+
Conv::Rust | Conv::C => default_call_conv,
2626
Conv::X86_64SysV => CallConv::SystemV,
2727
Conv::X86_64Win64 => CallConv::WindowsFastcall,
2828
Conv::ArmAapcs
@@ -55,7 +55,7 @@ pub(crate) fn get_function_sig<'tcx>(
5555
assert!(!inst.substs.needs_infer());
5656
clif_sig_from_fn_abi(
5757
tcx,
58-
triple,
58+
CallConv::triple_default(triple),
5959
&RevealAllLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()),
6060
)
6161
}
@@ -91,7 +91,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
9191
returns: Vec<AbiParam>,
9292
args: &[Value],
9393
) -> &[Value] {
94-
let sig = Signature { params, returns, call_conv: CallConv::triple_default(self.triple()) };
94+
let sig = Signature { params, returns, call_conv: self.target_config.default_call_conv };
9595
let func_id = self.module.declare_function(name, Linkage::Import, &sig).unwrap();
9696
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
9797
let call_inst = self.bcx.ins().call(func_ref, args);
@@ -420,7 +420,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
420420
}
421421

422422
let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0].value, idx);
423-
let sig = clif_sig_from_fn_abi(fx.tcx, fx.triple(), &fn_abi);
423+
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
424424
let sig = fx.bcx.import_signature(sig);
425425

426426
(CallTarget::Indirect(sig, method), Some(ptr))
@@ -440,7 +440,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
440440
}
441441

442442
let func = codegen_operand(fx, func).load_scalar(fx);
443-
let sig = clif_sig_from_fn_abi(fx.tcx, fx.triple(), &fn_abi);
443+
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
444444
let sig = fx.bcx.import_signature(sig);
445445

446446
(CallTarget::Indirect(sig, func), None)
@@ -531,7 +531,7 @@ pub(crate) fn codegen_drop<'tcx>(
531531
let fn_abi =
532532
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(virtual_drop, ty::List::empty());
533533

534-
let sig = clif_sig_from_fn_abi(fx.tcx, fx.triple(), &fn_abi);
534+
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
535535
let sig = fx.bcx.import_signature(sig);
536536
fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]);
537537
}

src/common.rs

-4
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,6 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
359359
crate::constant::codegen_const_value(self, const_loc, self.tcx.caller_location_ty())
360360
}
361361

362-
pub(crate) fn triple(&self) -> &target_lexicon::Triple {
363-
self.module.isa().triple()
364-
}
365-
366362
pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
367363
let mut data_ctx = DataContext::new();
368364
data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice());

src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
10671067
kw.Try, (v f, v data, v _catch_fn) {
10681068
// FIXME once unwinding is supported, change this to actually catch panics
10691069
let f_sig = fx.bcx.func.import_signature(Signature {
1070-
call_conv: CallConv::triple_default(fx.triple()),
1070+
call_conv: fx.target_config.default_call_conv,
10711071
params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))],
10721072
returns: vec![],
10731073
});

src/trap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, '_>, msg: &str) {
99
"puts",
1010
Linkage::Import,
1111
&Signature {
12-
call_conv: CallConv::triple_default(fx.triple()),
12+
call_conv: fx.target_config.default_call_conv,
1313
params: vec![AbiParam::new(fx.pointer_type)],
1414
returns: vec![AbiParam::new(types::I32)],
1515
},

0 commit comments

Comments
 (0)