Skip to content

Commit d27f2f0

Browse files
committed
Rename trans to codegen
1 parent 8063c37 commit d27f2f0

File tree

9 files changed

+77
-77
lines changed

9 files changed

+77
-77
lines changed

src/abi/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
497497
.tcx
498498
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx));
499499

500-
let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb));
500+
let destination = destination.map(|(place, bb)| (codegen_place(fx, place), bb));
501501

502502
// Handle special calls like instrinsics and empty drop glue.
503503
let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() {
@@ -550,8 +550,8 @@ pub(crate) fn codegen_terminator_call<'tcx>(
550550
// Unpack arguments tuple for closures
551551
let args = if fn_sig.abi == Abi::RustCall {
552552
assert_eq!(args.len(), 2, "rust-call abi requires two arguments");
553-
let self_arg = trans_operand(fx, &args[0]);
554-
let pack_arg = trans_operand(fx, &args[1]);
553+
let self_arg = codegen_operand(fx, &args[0]);
554+
let pack_arg = codegen_operand(fx, &args[1]);
555555

556556
let tupled_arguments = match pack_arg.layout().ty.kind() {
557557
ty::Tuple(ref tupled_arguments) => tupled_arguments,
@@ -566,7 +566,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
566566
args
567567
} else {
568568
args.iter()
569-
.map(|arg| trans_operand(fx, arg))
569+
.map(|arg| codegen_operand(fx, arg))
570570
.collect::<Vec<_>>()
571571
};
572572

@@ -610,7 +610,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
610610
let nop_inst = fx.bcx.ins().nop();
611611
fx.add_comment(nop_inst, "indirect call");
612612
}
613-
let func = trans_operand(fx, func).load_scalar(fx);
613+
let func = codegen_operand(fx, func).load_scalar(fx);
614614
(
615615
Some(func),
616616
args.get(0)

src/base.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::ty::adjustment::PointerCast;
55

66
use crate::prelude::*;
77

8-
pub(crate) fn trans_fn<'tcx>(
8+
pub(crate) fn codegen_fn<'tcx>(
99
cx: &mut crate::CodegenCx<'tcx, impl Module>,
1010
instance: Instance<'tcx>,
1111
linkage: Linkage,
@@ -202,7 +202,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
202202
fx.bcx.ins().nop();
203203
for stmt in &bb_data.statements {
204204
fx.set_debug_loc(stmt.source_info);
205-
trans_stmt(fx, block, stmt);
205+
codegen_stmt(fx, block, stmt);
206206
}
207207

208208
#[cfg(debug_assertions)]
@@ -258,7 +258,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
258258
continue;
259259
}
260260
}
261-
let cond = trans_operand(fx, cond).load_scalar(fx);
261+
let cond = codegen_operand(fx, cond).load_scalar(fx);
262262

263263
let target = fx.get_block(*target);
264264
let failure = fx.bcx.create_block();
@@ -276,8 +276,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
276276

277277
match msg {
278278
AssertKind::BoundsCheck { ref len, ref index } => {
279-
let len = trans_operand(fx, len).load_scalar(fx);
280-
let index = trans_operand(fx, index).load_scalar(fx);
279+
let len = codegen_operand(fx, len).load_scalar(fx);
280+
let index = codegen_operand(fx, index).load_scalar(fx);
281281
let location = fx
282282
.get_caller_location(bb_data.terminator().source_info.span)
283283
.load_scalar(fx);
@@ -301,7 +301,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
301301
switch_ty,
302302
targets,
303303
} => {
304-
let discr = trans_operand(fx, discr).load_scalar(fx);
304+
let discr = codegen_operand(fx, discr).load_scalar(fx);
305305

306306
if switch_ty.kind() == fx.tcx.types.bool.kind() {
307307
assert_eq!(targets.iter().count(), 1);
@@ -396,14 +396,14 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
396396
| TerminatorKind::FalseUnwind { .. }
397397
| TerminatorKind::DropAndReplace { .. }
398398
| TerminatorKind::GeneratorDrop => {
399-
bug!("shouldn't exist at trans {:?}", bb_data.terminator());
399+
bug!("shouldn't exist at codegen {:?}", bb_data.terminator());
400400
}
401401
TerminatorKind::Drop {
402402
place,
403403
target,
404404
unwind: _,
405405
} => {
406-
let drop_place = trans_place(fx, *place);
406+
let drop_place = codegen_place(fx, *place);
407407
crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place);
408408

409409
let target_block = fx.get_block(*target);
@@ -416,7 +416,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) {
416416
fx.bcx.finalize();
417417
}
418418

419-
fn trans_stmt<'tcx>(
419+
fn codegen_stmt<'tcx>(
420420
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
421421
#[allow(unused_variables)] cur_block: Block,
422422
stmt: &Statement<'tcx>,
@@ -439,19 +439,19 @@ fn trans_stmt<'tcx>(
439439
place,
440440
variant_index,
441441
} => {
442-
let place = trans_place(fx, **place);
442+
let place = codegen_place(fx, **place);
443443
crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
444444
}
445445
StatementKind::Assign(to_place_and_rval) => {
446-
let lval = trans_place(fx, to_place_and_rval.0);
446+
let lval = codegen_place(fx, to_place_and_rval.0);
447447
let dest_layout = lval.layout();
448448
match &to_place_and_rval.1 {
449449
Rvalue::Use(operand) => {
450-
let val = trans_operand(fx, operand);
450+
let val = codegen_operand(fx, operand);
451451
lval.write_cvalue(fx, val);
452452
}
453453
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
454-
let place = trans_place(fx, *place);
454+
let place = codegen_place(fx, *place);
455455
let ref_ = place.place_ref(fx, lval.layout());
456456
lval.write_cvalue(fx, ref_);
457457
}
@@ -460,29 +460,29 @@ fn trans_stmt<'tcx>(
460460
lval.write_cvalue(fx, val);
461461
}
462462
Rvalue::BinaryOp(bin_op, lhs, rhs) => {
463-
let lhs = trans_operand(fx, lhs);
464-
let rhs = trans_operand(fx, rhs);
463+
let lhs = codegen_operand(fx, lhs);
464+
let rhs = codegen_operand(fx, rhs);
465465

466466
let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs);
467467
lval.write_cvalue(fx, res);
468468
}
469469
Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => {
470-
let lhs = trans_operand(fx, lhs);
471-
let rhs = trans_operand(fx, rhs);
470+
let lhs = codegen_operand(fx, lhs);
471+
let rhs = codegen_operand(fx, rhs);
472472

473473
let res = if !fx.tcx.sess.overflow_checks() {
474474
let val =
475-
crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx);
475+
crate::num::codegen_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx);
476476
let is_overflow = fx.bcx.ins().iconst(types::I8, 0);
477477
CValue::by_val_pair(val, is_overflow, lval.layout())
478478
} else {
479-
crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs)
479+
crate::num::codegen_checked_int_binop(fx, *bin_op, lhs, rhs)
480480
};
481481

482482
lval.write_cvalue(fx, res);
483483
}
484484
Rvalue::UnaryOp(un_op, operand) => {
485-
let operand = trans_operand(fx, operand);
485+
let operand = codegen_operand(fx, operand);
486486
let layout = operand.layout();
487487
let val = operand.load_scalar(fx);
488488
let res = match un_op {
@@ -500,7 +500,7 @@ fn trans_stmt<'tcx>(
500500
ty::Int(IntTy::I128) => {
501501
// FIXME remove this case once ineg.i128 works
502502
let zero = CValue::const_val(fx, layout, 0);
503-
crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand)
503+
crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
504504
}
505505
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
506506
ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout),
@@ -534,11 +534,11 @@ fn trans_stmt<'tcx>(
534534
| Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty)
535535
| Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => {
536536
let to_layout = fx.layout_of(fx.monomorphize(to_ty));
537-
let operand = trans_operand(fx, operand);
537+
let operand = codegen_operand(fx, operand);
538538
lval.write_cvalue(fx, operand.cast_pointer_to(to_layout));
539539
}
540540
Rvalue::Cast(CastKind::Misc, operand, to_ty) => {
541-
let operand = trans_operand(fx, operand);
541+
let operand = codegen_operand(fx, operand);
542542
let from_ty = operand.layout().ty;
543543
let to_ty = fx.monomorphize(to_ty);
544544

@@ -639,7 +639,7 @@ fn trans_stmt<'tcx>(
639639
operand,
640640
_to_ty,
641641
) => {
642-
let operand = trans_operand(fx, operand);
642+
let operand = codegen_operand(fx, operand);
643643
match *operand.layout().ty.kind() {
644644
ty::Closure(def_id, substs) => {
645645
let instance = Instance::resolve_closure(
@@ -657,18 +657,18 @@ fn trans_stmt<'tcx>(
657657
}
658658
}
659659
Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => {
660-
let operand = trans_operand(fx, operand);
660+
let operand = codegen_operand(fx, operand);
661661
operand.unsize_value(fx, lval);
662662
}
663663
Rvalue::Discriminant(place) => {
664-
let place = trans_place(fx, *place);
664+
let place = codegen_place(fx, *place);
665665
let value = place.to_cvalue(fx);
666666
let discr =
667667
crate::discriminant::codegen_get_discriminant(fx, value, dest_layout);
668668
lval.write_cvalue(fx, discr);
669669
}
670670
Rvalue::Repeat(operand, times) => {
671-
let operand = trans_operand(fx, operand);
671+
let operand = codegen_operand(fx, operand);
672672
let times = fx
673673
.monomorphize(times)
674674
.eval(fx.tcx, ParamEnv::reveal_all())
@@ -706,7 +706,7 @@ fn trans_stmt<'tcx>(
706706
}
707707
}
708708
Rvalue::Len(place) => {
709-
let place = trans_place(fx, *place);
709+
let place = codegen_place(fx, *place);
710710
let usize_layout = fx.layout_of(fx.tcx.types.usize);
711711
let len = codegen_array_len(fx, place);
712712
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
@@ -754,13 +754,13 @@ fn trans_stmt<'tcx>(
754754
Rvalue::Aggregate(kind, operands) => match **kind {
755755
AggregateKind::Array(_ty) => {
756756
for (i, operand) in operands.iter().enumerate() {
757-
let operand = trans_operand(fx, operand);
757+
let operand = codegen_operand(fx, operand);
758758
let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64);
759759
let to = lval.place_index(fx, index);
760760
to.write_cvalue(fx, operand);
761761
}
762762
}
763-
_ => unreachable!("shouldn't exist at trans {:?}", to_place_and_rval.1),
763+
_ => unreachable!("shouldn't exist at codegen {:?}", to_place_and_rval.1),
764764
},
765765
}
766766
}
@@ -813,20 +813,20 @@ fn trans_stmt<'tcx>(
813813
assert!(!alignstack);
814814

815815
assert_eq!(inputs.len(), 2);
816-
let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax
817-
let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx
816+
let leaf = codegen_operand(fx, &inputs[0].1).load_scalar(fx); // %eax
817+
let subleaf = codegen_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx
818818

819819
let (eax, ebx, ecx, edx) =
820820
crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf);
821821

822822
assert_eq!(outputs.len(), 4);
823-
trans_place(fx, outputs[0])
823+
codegen_place(fx, outputs[0])
824824
.write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32)));
825-
trans_place(fx, outputs[1])
825+
codegen_place(fx, outputs[1])
826826
.write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32)));
827-
trans_place(fx, outputs[2])
827+
codegen_place(fx, outputs[2])
828828
.write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32)));
829-
trans_place(fx, outputs[3])
829+
codegen_place(fx, outputs[3])
830830
.write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32)));
831831
}
832832
"xgetbv" => {
@@ -892,7 +892,7 @@ fn codegen_array_len<'tcx>(
892892
}
893893
}
894894

895-
pub(crate) fn trans_place<'tcx>(
895+
pub(crate) fn codegen_place<'tcx>(
896896
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
897897
place: Place<'tcx>,
898898
) -> CPlace<'tcx> {
@@ -964,16 +964,16 @@ pub(crate) fn trans_place<'tcx>(
964964
cplace
965965
}
966966

967-
pub(crate) fn trans_operand<'tcx>(
967+
pub(crate) fn codegen_operand<'tcx>(
968968
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
969969
operand: &Operand<'tcx>,
970970
) -> CValue<'tcx> {
971971
match operand {
972972
Operand::Move(place) | Operand::Copy(place) => {
973-
let cplace = trans_place(fx, *place);
973+
let cplace = codegen_place(fx, *place);
974974
cplace.to_cvalue(fx)
975975
}
976-
Operand::Constant(const_) => crate::constant::trans_constant(fx, const_),
976+
Operand::Constant(const_) => crate::constant::codegen_constant(fx, const_),
977977
}
978978
}
979979

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> {
406406
caller.line as u32,
407407
caller.col_display as u32 + 1,
408408
));
409-
crate::constant::trans_const_value(self, const_loc, self.tcx.caller_location_ty())
409+
crate::constant::codegen_const_value(self, const_loc, self.tcx.caller_location_ty())
410410
}
411411

412412
pub(crate) fn triple(&self) -> &target_lexicon::Triple {

src/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn codegen_static_ref<'tcx>(
106106
CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout)
107107
}
108108

109-
pub(crate) fn trans_constant<'tcx>(
109+
pub(crate) fn codegen_constant<'tcx>(
110110
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
111111
constant: &Constant<'tcx>,
112112
) -> CValue<'tcx> {
@@ -151,10 +151,10 @@ pub(crate) fn trans_constant<'tcx>(
151151
| ConstKind::Error(_) => unreachable!("{:?}", const_),
152152
};
153153

154-
trans_const_value(fx, const_val, const_.ty)
154+
codegen_const_value(fx, const_val, const_.ty)
155155
}
156156

157-
pub(crate) fn trans_const_value<'tcx>(
157+
pub(crate) fn codegen_const_value<'tcx>(
158158
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
159159
const_val: ConstValue<'tcx>,
160160
ty: Ty<'tcx>,

src/driver/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ fn codegen_mono_items<'tcx>(
6464

6565
for (mono_item, (linkage, visibility)) in mono_items {
6666
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
67-
trans_mono_item(cx, mono_item, linkage);
67+
codegen_mono_item(cx, mono_item, linkage);
6868
}
6969
}
7070

71-
fn trans_mono_item<'tcx, M: Module>(
71+
fn codegen_mono_item<'tcx, M: Module>(
7272
cx: &mut crate::CodegenCx<'tcx, M>,
7373
mono_item: MonoItem<'tcx>,
7474
linkage: Linkage,
@@ -80,7 +80,7 @@ fn trans_mono_item<'tcx, M: Module>(
8080
crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name));
8181
debug_assert!(!inst.substs.needs_infer());
8282
tcx.sess
83-
.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage));
83+
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
8484
}
8585
MonoItem::Static(def_id) => {
8686
crate::constant::codegen_static(&mut cx.constants_cx, def_id);

src/inline_asm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
5050
inputs.push((
5151
reg,
5252
new_slot(reg.reg_class()),
53-
crate::base::trans_operand(fx, value).load_scalar(fx),
53+
crate::base::codegen_operand(fx, value).load_scalar(fx),
5454
));
5555
}
5656
InlineAsmOperand::Out {
@@ -64,7 +64,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
6464
outputs.push((
6565
reg,
6666
new_slot(reg.reg_class()),
67-
crate::base::trans_place(fx, place),
67+
crate::base::codegen_place(fx, place),
6868
));
6969
}
7070
}
@@ -79,13 +79,13 @@ pub(crate) fn codegen_inline_asm<'tcx>(
7979
inputs.push((
8080
reg,
8181
new_slot(reg.reg_class()),
82-
crate::base::trans_operand(fx, in_value).load_scalar(fx),
82+
crate::base::codegen_operand(fx, in_value).load_scalar(fx),
8383
));
8484
if let Some(out_place) = out_place {
8585
outputs.push((
8686
reg,
8787
new_slot(reg.reg_class()),
88-
crate::base::trans_place(fx, out_place),
88+
crate::base::codegen_place(fx, out_place),
8989
));
9090
}
9191
}

0 commit comments

Comments
 (0)