use crate::prelude::*;
-pub(crate) fn trans_fn<'tcx>(
+pub(crate) fn codegen_fn<'tcx>(
cx: &mut crate::CodegenCx<'tcx, impl Module>,
instance: Instance<'tcx>,
linkage: Linkage,
fx.bcx.ins().nop();
for stmt in &bb_data.statements {
fx.set_debug_loc(stmt.source_info);
- trans_stmt(fx, block, stmt);
+ codegen_stmt(fx, block, stmt);
}
#[cfg(debug_assertions)]
continue;
}
}
- let cond = trans_operand(fx, cond).load_scalar(fx);
+ let cond = codegen_operand(fx, cond).load_scalar(fx);
let target = fx.get_block(*target);
let failure = fx.bcx.create_block();
match msg {
AssertKind::BoundsCheck { ref len, ref index } => {
- let len = trans_operand(fx, len).load_scalar(fx);
- let index = trans_operand(fx, index).load_scalar(fx);
+ let len = codegen_operand(fx, len).load_scalar(fx);
+ let index = codegen_operand(fx, index).load_scalar(fx);
let location = fx
.get_caller_location(bb_data.terminator().source_info.span)
.load_scalar(fx);
switch_ty,
targets,
} => {
- let discr = trans_operand(fx, discr).load_scalar(fx);
+ let discr = codegen_operand(fx, discr).load_scalar(fx);
if switch_ty.kind() == fx.tcx.types.bool.kind() {
assert_eq!(targets.iter().count(), 1);
| TerminatorKind::FalseUnwind { .. }
| TerminatorKind::DropAndReplace { .. }
| TerminatorKind::GeneratorDrop => {
- bug!("shouldn't exist at trans {:?}", bb_data.terminator());
+ bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
}
TerminatorKind::Drop {
place,
target,
unwind: _,
} => {
- let drop_place = trans_place(fx, *place);
+ let drop_place = codegen_place(fx, *place);
crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place);
let target_block = fx.get_block(*target);
fx.bcx.finalize();
}
-fn trans_stmt<'tcx>(
+fn codegen_stmt<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
#[allow(unused_variables)] cur_block: Block,
stmt: &Statement<'tcx>,
place,
variant_index,
} => {
- let place = trans_place(fx, **place);
+ let place = codegen_place(fx, **place);
crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
}
StatementKind::Assign(to_place_and_rval) => {
- let lval = trans_place(fx, to_place_and_rval.0);
+ let lval = codegen_place(fx, to_place_and_rval.0);
let dest_layout = lval.layout();
match &to_place_and_rval.1 {
Rvalue::Use(operand) => {
- let val = trans_operand(fx, operand);
+ let val = codegen_operand(fx, operand);
lval.write_cvalue(fx, val);
}
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
- let place = trans_place(fx, *place);
+ let place = codegen_place(fx, *place);
let ref_ = place.place_ref(fx, lval.layout());
lval.write_cvalue(fx, ref_);
}
lval.write_cvalue(fx, val);
}
Rvalue::BinaryOp(bin_op, lhs, rhs) => {
- let lhs = trans_operand(fx, lhs);
- let rhs = trans_operand(fx, rhs);
+ let lhs = codegen_operand(fx, lhs);
+ let rhs = codegen_operand(fx, rhs);
let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs);
lval.write_cvalue(fx, res);
}
Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => {
- let lhs = trans_operand(fx, lhs);
- let rhs = trans_operand(fx, rhs);
+ let lhs = codegen_operand(fx, lhs);
+ let rhs = codegen_operand(fx, rhs);
let res = if !fx.tcx.sess.overflow_checks() {
let val =
- crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx);
+ crate::num::codegen_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx);
let is_overflow = fx.bcx.ins().iconst(types::I8, 0);
CValue::by_val_pair(val, is_overflow, lval.layout())
} else {
- crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs)
+ crate::num::codegen_checked_int_binop(fx, *bin_op, lhs, rhs)
};
lval.write_cvalue(fx, res);
}
Rvalue::UnaryOp(un_op, operand) => {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
let layout = operand.layout();
let val = operand.load_scalar(fx);
let res = match un_op {
ty::Int(IntTy::I128) => {
// FIXME remove this case once ineg.i128 works
let zero = CValue::const_val(fx, layout, 0);
- crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand)
+ crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
}
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout),
| Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty)
| Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => {
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
}
Rvalue::Cast(CastKind::Misc, operand, to_ty) => {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
let from_ty = operand.layout().ty;
let to_ty = fx.monomorphize(to_ty);
operand,
_to_ty,
) => {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
match *operand.layout().ty.kind() {
ty::Closure(def_id, substs) => {
let instance = Instance::resolve_closure(
}
}
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
operand.unsize_value(fx, lval);
}
Rvalue::Discriminant(place) => {
- let place = trans_place(fx, *place);
+ let place = codegen_place(fx, *place);
let value = place.to_cvalue(fx);
let discr =
crate::discriminant::codegen_get_discriminant(fx, value, dest_layout);
lval.write_cvalue(fx, discr);
}
Rvalue::Repeat(operand, times) => {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
let times = fx
.monomorphize(times)
.eval(fx.tcx, ParamEnv::reveal_all())
}
}
Rvalue::Len(place) => {
- let place = trans_place(fx, *place);
+ let place = codegen_place(fx, *place);
let usize_layout = fx.layout_of(fx.tcx.types.usize);
let len = codegen_array_len(fx, place);
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
Rvalue::Aggregate(kind, operands) => match **kind {
AggregateKind::Array(_ty) => {
for (i, operand) in operands.iter().enumerate() {
- let operand = trans_operand(fx, operand);
+ let operand = codegen_operand(fx, operand);
let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64);
let to = lval.place_index(fx, index);
to.write_cvalue(fx, operand);
}
}
- _ => unreachable!("shouldn't exist at trans {:?}", to_place_and_rval.1),
+ _ => unreachable!("shouldn't exist at codegen {:?}", to_place_and_rval.1),
},
}
}
assert!(!alignstack);
assert_eq!(inputs.len(), 2);
- let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax
- let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx
+ let leaf = codegen_operand(fx, &inputs[0].1).load_scalar(fx); // %eax
+ let subleaf = codegen_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx
let (eax, ebx, ecx, edx) =
crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf);
assert_eq!(outputs.len(), 4);
- trans_place(fx, outputs[0])
+ codegen_place(fx, outputs[0])
.write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32)));
- trans_place(fx, outputs[1])
+ codegen_place(fx, outputs[1])
.write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32)));
- trans_place(fx, outputs[2])
+ codegen_place(fx, outputs[2])
.write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32)));
- trans_place(fx, outputs[3])
+ codegen_place(fx, outputs[3])
.write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32)));
}
"xgetbv" => {
}
}
-pub(crate) fn trans_place<'tcx>(
+pub(crate) fn codegen_place<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
place: Place<'tcx>,
) -> CPlace<'tcx> {
cplace
}
-pub(crate) fn trans_operand<'tcx>(
+pub(crate) fn codegen_operand<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
operand: &Operand<'tcx>,
) -> CValue<'tcx> {
match operand {
Operand::Move(place) | Operand::Copy(place) => {
- let cplace = trans_place(fx, *place);
+ let cplace = codegen_place(fx, *place);
cplace.to_cvalue(fx)
}
- Operand::Constant(const_) => crate::constant::trans_constant(fx, const_),
+ Operand::Constant(const_) => crate::constant::codegen_constant(fx, const_),
}
}
$arg
},
(c $fx:expr, $arg:ident) => {
- trans_operand($fx, $arg)
+ codegen_operand($fx, $arg)
},
(v $fx:expr, $arg:ident) => {
- trans_operand($fx, $arg).load_scalar($fx)
+ codegen_operand($fx, $arg).load_scalar($fx)
}
}
assert!($substs.is_noop());
if let [$(ref $arg),*] = *$args {
let ($($arg,)*) = (
- $(trans_operand($fx, $arg),)*
+ $(codegen_operand($fx, $arg),)*
);
let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty);
$ret.write_cvalue($fx, res);
"unchecked_shr" => BinOp::Shr,
_ => unreachable!("intrinsic {}", intrinsic),
};
- let res = crate::num::trans_int_binop(fx, bin_op, x, y);
+ let res = crate::num::codegen_int_binop(fx, bin_op, x, y);
ret.write_cvalue(fx, res);
};
_ if intrinsic.ends_with("_with_overflow"), (c x, c y) {
_ => unreachable!("intrinsic {}", intrinsic),
};
- let res = crate::num::trans_checked_int_binop(
+ let res = crate::num::codegen_checked_int_binop(
fx,
bin_op,
x,
"wrapping_mul" => BinOp::Mul,
_ => unreachable!("intrinsic {}", intrinsic),
};
- let res = crate::num::trans_int_binop(
+ let res = crate::num::codegen_int_binop(
fx,
bin_op,
x,
let signed = type_sign(T);
- let checked_res = crate::num::trans_checked_int_binop(
+ let checked_res = crate::num::codegen_checked_int_binop(
fx,
bin_op,
lhs,
size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () {
let const_val =
fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap();
- let val = crate::constant::trans_const_value(
+ let val = crate::constant::codegen_const_value(
fx,
const_val,
ret.layout().ty,
};
ptr_guaranteed_eq, (c a, c b) {
- let val = crate::num::trans_ptr_binop(fx, BinOp::Eq, a, b);
+ let val = crate::num::codegen_ptr_binop(fx, BinOp::Eq, a, b);
ret.write_cvalue(fx, val);
};
ptr_guaranteed_ne, (c a, c b) {
- let val = crate::num::trans_ptr_binop(fx, BinOp::Ne, a, b);
+ let val = crate::num::codegen_ptr_binop(fx, BinOp::Ne, a, b);
ret.write_cvalue(fx, val);
};
};
fadd_fast | fsub_fast | fmul_fast | fdiv_fast | frem_fast, (c x, c y) {
- let res = crate::num::trans_float_binop(fx, match intrinsic {
+ let res = crate::num::codegen_float_binop(fx, match intrinsic {
"fadd_fast" => BinOp::Add,
"fsub_fast" => BinOp::Sub,
"fmul_fast" => BinOp::Mul,
}
match in_lhs.layout().ty.kind() {
- ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs),
- ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs),
- ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs),
- ty::RawPtr(..) | ty::FnPtr(..) => crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs),
+ ty::Bool => crate::num::codegen_bool_binop(fx, bin_op, in_lhs, in_rhs),
+ ty::Uint(_) | ty::Int(_) => crate::num::codegen_int_binop(fx, bin_op, in_lhs, in_rhs),
+ ty::Float(_) => crate::num::codegen_float_binop(fx, bin_op, in_lhs, in_rhs),
+ ty::RawPtr(..) | ty::FnPtr(..) => crate::num::codegen_ptr_binop(fx, bin_op, in_lhs, in_rhs),
_ => unreachable!(
"{:?}({:?}, {:?})",
bin_op,
}
}
-pub(crate) fn trans_bool_binop<'tcx>(
+pub(crate) fn codegen_bool_binop<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
bin_op: BinOp,
in_lhs: CValue<'tcx>,
CValue::by_val(res, fx.layout_of(fx.tcx.types.bool))
}
-pub(crate) fn trans_int_binop<'tcx>(
+pub(crate) fn codegen_int_binop<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
bin_op: BinOp,
in_lhs: CValue<'tcx>,
CValue::by_val(val, in_lhs.layout())
}
-pub(crate) fn trans_checked_int_binop<'tcx>(
+pub(crate) fn codegen_checked_int_binop<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
bin_op: BinOp,
in_lhs: CValue<'tcx>,
out_place.to_cvalue(fx)
}
-pub(crate) fn trans_float_binop<'tcx>(
+pub(crate) fn codegen_float_binop<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
bin_op: BinOp,
in_lhs: CValue<'tcx>,
CValue::by_val(res, in_lhs.layout())
}
-pub(crate) fn trans_ptr_binop<'tcx>(
+pub(crate) fn codegen_ptr_binop<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
bin_op: BinOp,
in_lhs: CValue<'tcx>,