Skip to content

Commit fb7de6a

Browse files
committed
rustc_trans: rename CrateContext to CodegenCx.
1 parent 2931af6 commit fb7de6a

39 files changed

+273
-273
lines changed

src/librustc_trans/abi.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use llvm::{self, ValueRef, AttributePlace};
1212
use base;
1313
use builder::Builder;
1414
use common::{ty_fn_sig, C_usize};
15-
use context::CrateContext;
15+
use context::CodegenCx;
1616
use cabi_x86;
1717
use cabi_x86_64;
1818
use cabi_x86_win64;
@@ -209,7 +209,7 @@ impl Reg {
209209
}
210210

211211
impl Reg {
212-
pub fn align(&self, ccx: &CrateContext) -> Align {
212+
pub fn align(&self, ccx: &CodegenCx) -> Align {
213213
let dl = ccx.data_layout();
214214
match self.kind {
215215
RegKind::Integer => {
@@ -234,7 +234,7 @@ impl Reg {
234234
}
235235
}
236236

237-
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
237+
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
238238
match self.kind {
239239
RegKind::Integer => Type::ix(ccx, self.size.bits()),
240240
RegKind::Float => {
@@ -276,11 +276,11 @@ impl From<Reg> for Uniform {
276276
}
277277

278278
impl Uniform {
279-
pub fn align(&self, ccx: &CrateContext) -> Align {
279+
pub fn align(&self, ccx: &CodegenCx) -> Align {
280280
self.unit.align(ccx)
281281
}
282282

283-
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
283+
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
284284
let llunit = self.unit.llvm_type(ccx);
285285

286286
if self.total <= self.unit.size {
@@ -307,7 +307,7 @@ impl Uniform {
307307

308308
pub trait LayoutExt<'tcx> {
309309
fn is_aggregate(&self) -> bool;
310-
fn homogeneous_aggregate<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Option<Reg>;
310+
fn homogeneous_aggregate<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Option<Reg>;
311311
}
312312

313313
impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
@@ -321,7 +321,7 @@ impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
321321
}
322322
}
323323

324-
fn homogeneous_aggregate<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Option<Reg> {
324+
fn homogeneous_aggregate<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Option<Reg> {
325325
match self.abi {
326326
layout::Abi::Uninhabited => None,
327327

@@ -423,7 +423,7 @@ impl From<Uniform> for CastTarget {
423423
}
424424

425425
impl CastTarget {
426-
pub fn size(&self, ccx: &CrateContext) -> Size {
426+
pub fn size(&self, ccx: &CodegenCx) -> Size {
427427
match *self {
428428
CastTarget::Uniform(u) => u.total,
429429
CastTarget::Pair(a, b) => {
@@ -433,7 +433,7 @@ impl CastTarget {
433433
}
434434
}
435435

436-
pub fn align(&self, ccx: &CrateContext) -> Align {
436+
pub fn align(&self, ccx: &CodegenCx) -> Align {
437437
match *self {
438438
CastTarget::Uniform(u) => u.align(ccx),
439439
CastTarget::Pair(a, b) => {
@@ -444,7 +444,7 @@ impl CastTarget {
444444
}
445445
}
446446

447-
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
447+
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
448448
match *self {
449449
CastTarget::Uniform(u) => u.llvm_type(ccx),
450450
CastTarget::Pair(a, b) => {
@@ -547,7 +547,7 @@ impl<'a, 'tcx> ArgType<'tcx> {
547547

548548
/// Get the LLVM type for an place of the original Rust type of
549549
/// this argument/return, i.e. the result of `type_of::type_of`.
550-
pub fn memory_ty(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
550+
pub fn memory_ty(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
551551
self.layout.llvm_type(ccx)
552552
}
553553

@@ -647,23 +647,23 @@ pub struct FnType<'tcx> {
647647
}
648648

649649
impl<'a, 'tcx> FnType<'tcx> {
650-
pub fn of_instance(ccx: &CrateContext<'a, 'tcx>, instance: &ty::Instance<'tcx>)
650+
pub fn of_instance(ccx: &CodegenCx<'a, 'tcx>, instance: &ty::Instance<'tcx>)
651651
-> Self {
652652
let fn_ty = instance.ty(ccx.tcx);
653653
let sig = ty_fn_sig(ccx, fn_ty);
654654
let sig = ccx.tcx.erase_late_bound_regions_and_normalize(&sig);
655655
FnType::new(ccx, sig, &[])
656656
}
657657

658-
pub fn new(ccx: &CrateContext<'a, 'tcx>,
658+
pub fn new(ccx: &CodegenCx<'a, 'tcx>,
659659
sig: ty::FnSig<'tcx>,
660660
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
661661
let mut fn_ty = FnType::unadjusted(ccx, sig, extra_args);
662662
fn_ty.adjust_for_abi(ccx, sig.abi);
663663
fn_ty
664664
}
665665

666-
pub fn new_vtable(ccx: &CrateContext<'a, 'tcx>,
666+
pub fn new_vtable(ccx: &CodegenCx<'a, 'tcx>,
667667
sig: ty::FnSig<'tcx>,
668668
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
669669
let mut fn_ty = FnType::unadjusted(ccx, sig, extra_args);
@@ -688,7 +688,7 @@ impl<'a, 'tcx> FnType<'tcx> {
688688
fn_ty
689689
}
690690

691-
pub fn unadjusted(ccx: &CrateContext<'a, 'tcx>,
691+
pub fn unadjusted(ccx: &CodegenCx<'a, 'tcx>,
692692
sig: ty::FnSig<'tcx>,
693693
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
694694
debug!("FnType::unadjusted({:?}, {:?})", sig, extra_args);
@@ -863,7 +863,7 @@ impl<'a, 'tcx> FnType<'tcx> {
863863
}
864864

865865
fn adjust_for_abi(&mut self,
866-
ccx: &CrateContext<'a, 'tcx>,
866+
ccx: &CodegenCx<'a, 'tcx>,
867867
abi: Abi) {
868868
if abi == Abi::Unadjusted { return }
869869

@@ -939,7 +939,7 @@ impl<'a, 'tcx> FnType<'tcx> {
939939
}
940940
}
941941

942-
pub fn llvm_type(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
942+
pub fn llvm_type(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
943943
let mut llargument_tys = Vec::new();
944944

945945
let llreturn_ty = match self.ret.mode {

src/librustc_trans/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn trans_inline_asm<'a, 'tcx>(
119119
}
120120
}
121121

122-
pub fn trans_global_asm<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
122+
pub fn trans_global_asm<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
123123
ga: &hir::GlobalAsm) {
124124
let asm = CString::new(ga.asm.as_str().as_bytes()).unwrap();
125125
unsafe {

src/librustc_trans/attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use llvm::AttributePlace::Function;
2424
use llvm_util;
2525
pub use syntax::attr::{self, InlineAttr};
2626
use syntax::ast;
27-
use context::CrateContext;
27+
use context::CodegenCx;
2828

2929
/// Mark LLVM function to use provided inline heuristic.
3030
#[inline]
@@ -67,7 +67,7 @@ pub fn naked(val: ValueRef, is_naked: bool) {
6767
Attribute::Naked.toggle_llfn(Function, val, is_naked);
6868
}
6969

70-
pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
70+
pub fn set_frame_pointer_elimination(ccx: &CodegenCx, llfn: ValueRef) {
7171
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
7272
// parameter.
7373
if ccx.sess().must_not_eliminate_frame_pointers() {
@@ -77,7 +77,7 @@ pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
7777
}
7878
}
7979

80-
pub fn set_probestack(ccx: &CrateContext, llfn: ValueRef) {
80+
pub fn set_probestack(ccx: &CodegenCx, llfn: ValueRef) {
8181
// Only use stack probes if the target specification indicates that we
8282
// should be using stack probes
8383
if !ccx.sess().target.target.options.stack_probes {
@@ -101,7 +101,7 @@ pub fn set_probestack(ccx: &CrateContext, llfn: ValueRef) {
101101

102102
/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
103103
/// attributes.
104-
pub fn from_fn_attrs(ccx: &CrateContext, llfn: ValueRef, id: DefId) {
104+
pub fn from_fn_attrs(ccx: &CodegenCx, llfn: ValueRef, id: DefId) {
105105
use syntax::attr::*;
106106
let attrs = ccx.tcx.get_attrs(id);
107107
inline(llfn, find_inline_attr(Some(ccx.sess().diagnostic()), &attrs));

src/librustc_trans/base.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use common::{C_bool, C_bytes_in_context, C_i32, C_usize};
5959
use rustc_mir::monomorphize::collector::{self, MonoItemCollectionMode};
6060
use common::{self, C_struct_in_context, C_array, val_ty};
6161
use consts;
62-
use context::{self, CrateContext};
62+
use context::{self, CodegenCx};
6363
use debuginfo;
6464
use declare;
6565
use meth;
@@ -94,13 +94,13 @@ pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr};
9494
pub use rustc_mir::monomorphize::item::linkage_by_name;
9595

9696
pub struct StatRecorder<'a, 'tcx: 'a> {
97-
ccx: &'a CrateContext<'a, 'tcx>,
97+
ccx: &'a CodegenCx<'a, 'tcx>,
9898
name: Option<String>,
9999
istart: usize,
100100
}
101101

102102
impl<'a, 'tcx> StatRecorder<'a, 'tcx> {
103-
pub fn new(ccx: &'a CrateContext<'a, 'tcx>, name: String) -> StatRecorder<'a, 'tcx> {
103+
pub fn new(ccx: &'a CodegenCx<'a, 'tcx>, name: String) -> StatRecorder<'a, 'tcx> {
104104
let istart = ccx.stats.borrow().n_llvm_insns;
105105
StatRecorder {
106106
ccx,
@@ -189,7 +189,7 @@ pub fn compare_simd_types<'a, 'tcx>(
189189
/// The `old_info` argument is a bit funny. It is intended for use
190190
/// in an upcast, where the new vtable for an object will be derived
191191
/// from the old one.
192-
pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
192+
pub fn unsized_info<'ccx, 'tcx>(ccx: &CodegenCx<'ccx, 'tcx>,
193193
source: Ty<'tcx>,
194194
target: Ty<'tcx>,
195195
old_info: Option<ValueRef>)
@@ -455,7 +455,7 @@ pub fn call_memset<'a, 'tcx>(b: &Builder<'a, 'tcx>,
455455
b.call(llintrinsicfn, &[ptr, fill_byte, size, align, volatile], None)
456456
}
457457

458-
pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance<'tcx>) {
458+
pub fn trans_instance<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, instance: Instance<'tcx>) {
459459
let _s = if ccx.sess().trans_stats() {
460460
let mut instance_name = String::new();
461461
DefPathBasedNames::new(ccx.tcx, true, true)
@@ -506,7 +506,7 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
506506
mir::trans_mir(ccx, lldecl, &mir, instance, sig);
507507
}
508508

509-
pub fn set_link_section(ccx: &CrateContext,
509+
pub fn set_link_section(ccx: &CodegenCx,
510510
llval: ValueRef,
511511
attrs: &[ast::Attribute]) {
512512
if let Some(sect) = attr::first_attr_value_str_by_name(attrs, "link_section") {
@@ -522,7 +522,7 @@ pub fn set_link_section(ccx: &CrateContext,
522522

523523
/// Create the `main` function which will initialize the rust runtime and call
524524
/// users main function.
525-
fn maybe_create_entry_wrapper(ccx: &CrateContext) {
525+
fn maybe_create_entry_wrapper(ccx: &CodegenCx) {
526526
let (main_def_id, span) = match *ccx.sess().entry_fn.borrow() {
527527
Some((id, span)) => {
528528
(ccx.tcx.hir.local_def_id(id), span)
@@ -547,7 +547,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
547547
config::EntryNone => {} // Do nothing.
548548
}
549549

550-
fn create_entry_fn<'ccx>(ccx: &'ccx CrateContext,
550+
fn create_entry_fn<'ccx>(ccx: &'ccx CodegenCx,
551551
sp: Span,
552552
rust_main: ValueRef,
553553
rust_main_def_id: DefId,
@@ -1203,7 +1203,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12031203
.to_fingerprint().to_hex());
12041204

12051205
// Instantiate translation items without filling out definitions yet...
1206-
let ccx = CrateContext::new(tcx, cgu, &llmod_id);
1206+
let ccx = CodegenCx::new(tcx, cgu, &llmod_id);
12071207
let module = {
12081208
let trans_items = ccx.codegen_unit
12091209
.items_in_deterministic_order(ccx.tcx);

src/librustc_trans/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax_pos::Span;
3232
#[must_use]
3333
pub struct Builder<'a, 'tcx: 'a> {
3434
pub llbuilder: BuilderRef,
35-
pub ccx: &'a CrateContext<'a, 'tcx>,
35+
pub ccx: &'a CodegenCx<'a, 'tcx>,
3636
}
3737

3838
impl<'a, 'tcx> Drop for Builder<'a, 'tcx> {
@@ -51,7 +51,7 @@ fn noname() -> *const c_char {
5151
}
5252

5353
impl<'a, 'tcx> Builder<'a, 'tcx> {
54-
pub fn new_block<'b>(ccx: &'a CrateContext<'a, 'tcx>, llfn: ValueRef, name: &'b str) -> Self {
54+
pub fn new_block<'b>(ccx: &'a CodegenCx<'a, 'tcx>, llfn: ValueRef, name: &'b str) -> Self {
5555
let builder = Builder::with_ccx(ccx);
5656
let llbb = unsafe {
5757
let name = CString::new(name).unwrap();
@@ -65,7 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6565
builder
6666
}
6767

68-
pub fn with_ccx(ccx: &'a CrateContext<'a, 'tcx>) -> Self {
68+
pub fn with_ccx(ccx: &'a CodegenCx<'a, 'tcx>) -> Self {
6969
// Create a fresh builder from the crate context.
7070
let llbuilder = unsafe {
7171
llvm::LLVMCreateBuilderInContext(ccx.llcx)

src/librustc_trans/cabi_aarch64.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
12-
use context::CrateContext;
12+
use context::CodegenCx;
1313

14-
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>)
14+
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
1515
-> Option<Uniform> {
1616
arg.layout.homogeneous_aggregate(ccx).and_then(|unit| {
1717
let size = arg.layout.size;
@@ -38,7 +38,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
3838
})
3939
}
4040

41-
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
41+
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
4242
if !ret.layout.is_aggregate() {
4343
ret.extend_integer_width_to(32);
4444
return;
@@ -69,7 +69,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
6969
ret.make_indirect();
7070
}
7171

72-
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
72+
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
7373
if !arg.layout.is_aggregate() {
7474
arg.extend_integer_width_to(32);
7575
return;
@@ -100,7 +100,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
100100
arg.make_indirect();
101101
}
102102

103-
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
103+
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
104104
if !fty.ret.is_ignore() {
105105
classify_ret_ty(ccx, &mut fty.ret);
106106
}

src/librustc_trans/cabi_arm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// except according to those terms.
1010

1111
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
12-
use context::CrateContext;
12+
use context::CodegenCx;
1313
use llvm::CallConv;
1414

15-
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>)
15+
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
1616
-> Option<Uniform> {
1717
arg.layout.homogeneous_aggregate(ccx).and_then(|unit| {
1818
let size = arg.layout.size;
@@ -39,7 +39,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
3939
})
4040
}
4141

42-
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>, vfp: bool) {
42+
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>, vfp: bool) {
4343
if !ret.layout.is_aggregate() {
4444
ret.extend_integer_width_to(32);
4545
return;
@@ -71,7 +71,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
7171
ret.make_indirect();
7272
}
7373

74-
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>, vfp: bool) {
74+
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>, vfp: bool) {
7575
if !arg.layout.is_aggregate() {
7676
arg.extend_integer_width_to(32);
7777
return;
@@ -92,7 +92,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
9292
});
9393
}
9494

95-
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
95+
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
9696
// If this is a target with a hard-float ABI, and the function is not explicitly
9797
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
9898
let vfp = ccx.sess().target.target.llvm_target.ends_with("hf")

0 commit comments

Comments
 (0)