rustc_trans: rename CrateContext to CodegenCx.

This commit is contained in:
Eduard-Mihai Burtescu 2018-01-05 07:01:54 +02:00
parent 2931af62f0
commit fb7de6a041
39 changed files with 273 additions and 273 deletions

View File

@ -12,7 +12,7 @@ use llvm::{self, ValueRef, AttributePlace};
use base;
use builder::Builder;
use common::{ty_fn_sig, C_usize};
use context::CrateContext;
use context::CodegenCx;
use cabi_x86;
use cabi_x86_64;
use cabi_x86_win64;
@ -209,7 +209,7 @@ impl Reg {
}
impl Reg {
pub fn align(&self, ccx: &CrateContext) -> Align {
pub fn align(&self, ccx: &CodegenCx) -> Align {
let dl = ccx.data_layout();
match self.kind {
RegKind::Integer => {
@ -234,7 +234,7 @@ impl Reg {
}
}
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
match self.kind {
RegKind::Integer => Type::ix(ccx, self.size.bits()),
RegKind::Float => {
@ -276,11 +276,11 @@ impl From<Reg> for Uniform {
}
impl Uniform {
pub fn align(&self, ccx: &CrateContext) -> Align {
pub fn align(&self, ccx: &CodegenCx) -> Align {
self.unit.align(ccx)
}
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
let llunit = self.unit.llvm_type(ccx);
if self.total <= self.unit.size {
@ -307,7 +307,7 @@ impl Uniform {
pub trait LayoutExt<'tcx> {
fn is_aggregate(&self) -> bool;
fn homogeneous_aggregate<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Option<Reg>;
fn homogeneous_aggregate<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Option<Reg>;
}
impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
@ -321,7 +321,7 @@ impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
}
}
fn homogeneous_aggregate<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Option<Reg> {
fn homogeneous_aggregate<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Option<Reg> {
match self.abi {
layout::Abi::Uninhabited => None,
@ -423,7 +423,7 @@ impl From<Uniform> for CastTarget {
}
impl CastTarget {
pub fn size(&self, ccx: &CrateContext) -> Size {
pub fn size(&self, ccx: &CodegenCx) -> Size {
match *self {
CastTarget::Uniform(u) => u.total,
CastTarget::Pair(a, b) => {
@ -433,7 +433,7 @@ impl CastTarget {
}
}
pub fn align(&self, ccx: &CrateContext) -> Align {
pub fn align(&self, ccx: &CodegenCx) -> Align {
match *self {
CastTarget::Uniform(u) => u.align(ccx),
CastTarget::Pair(a, b) => {
@ -444,7 +444,7 @@ impl CastTarget {
}
}
pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
pub fn llvm_type(&self, ccx: &CodegenCx) -> Type {
match *self {
CastTarget::Uniform(u) => u.llvm_type(ccx),
CastTarget::Pair(a, b) => {
@ -547,7 +547,7 @@ impl<'a, 'tcx> ArgType<'tcx> {
/// Get the LLVM type for an place of the original Rust type of
/// this argument/return, i.e. the result of `type_of::type_of`.
pub fn memory_ty(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
pub fn memory_ty(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
self.layout.llvm_type(ccx)
}
@ -647,7 +647,7 @@ pub struct FnType<'tcx> {
}
impl<'a, 'tcx> FnType<'tcx> {
pub fn of_instance(ccx: &CrateContext<'a, 'tcx>, instance: &ty::Instance<'tcx>)
pub fn of_instance(ccx: &CodegenCx<'a, 'tcx>, instance: &ty::Instance<'tcx>)
-> Self {
let fn_ty = instance.ty(ccx.tcx);
let sig = ty_fn_sig(ccx, fn_ty);
@ -655,7 +655,7 @@ impl<'a, 'tcx> FnType<'tcx> {
FnType::new(ccx, sig, &[])
}
pub fn new(ccx: &CrateContext<'a, 'tcx>,
pub fn new(ccx: &CodegenCx<'a, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
let mut fn_ty = FnType::unadjusted(ccx, sig, extra_args);
@ -663,7 +663,7 @@ impl<'a, 'tcx> FnType<'tcx> {
fn_ty
}
pub fn new_vtable(ccx: &CrateContext<'a, 'tcx>,
pub fn new_vtable(ccx: &CodegenCx<'a, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
let mut fn_ty = FnType::unadjusted(ccx, sig, extra_args);
@ -688,7 +688,7 @@ impl<'a, 'tcx> FnType<'tcx> {
fn_ty
}
pub fn unadjusted(ccx: &CrateContext<'a, 'tcx>,
pub fn unadjusted(ccx: &CodegenCx<'a, 'tcx>,
sig: ty::FnSig<'tcx>,
extra_args: &[Ty<'tcx>]) -> FnType<'tcx> {
debug!("FnType::unadjusted({:?}, {:?})", sig, extra_args);
@ -863,7 +863,7 @@ impl<'a, 'tcx> FnType<'tcx> {
}
fn adjust_for_abi(&mut self,
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
abi: Abi) {
if abi == Abi::Unadjusted { return }
@ -939,7 +939,7 @@ impl<'a, 'tcx> FnType<'tcx> {
}
}
pub fn llvm_type(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
pub fn llvm_type(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
let mut llargument_tys = Vec::new();
let llreturn_ty = match self.ret.mode {

View File

@ -119,7 +119,7 @@ pub fn trans_inline_asm<'a, 'tcx>(
}
}
pub fn trans_global_asm<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn trans_global_asm<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ga: &hir::GlobalAsm) {
let asm = CString::new(ga.asm.as_str().as_bytes()).unwrap();
unsafe {

View File

@ -24,7 +24,7 @@ use llvm::AttributePlace::Function;
use llvm_util;
pub use syntax::attr::{self, InlineAttr};
use syntax::ast;
use context::CrateContext;
use context::CodegenCx;
/// Mark LLVM function to use provided inline heuristic.
#[inline]
@ -67,7 +67,7 @@ pub fn naked(val: ValueRef, is_naked: bool) {
Attribute::Naked.toggle_llfn(Function, val, is_naked);
}
pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
pub fn set_frame_pointer_elimination(ccx: &CodegenCx, llfn: ValueRef) {
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
// parameter.
if ccx.sess().must_not_eliminate_frame_pointers() {
@ -77,7 +77,7 @@ pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
}
}
pub fn set_probestack(ccx: &CrateContext, llfn: ValueRef) {
pub fn set_probestack(ccx: &CodegenCx, llfn: ValueRef) {
// Only use stack probes if the target specification indicates that we
// should be using stack probes
if !ccx.sess().target.target.options.stack_probes {
@ -101,7 +101,7 @@ pub fn set_probestack(ccx: &CrateContext, llfn: ValueRef) {
/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
/// attributes.
pub fn from_fn_attrs(ccx: &CrateContext, llfn: ValueRef, id: DefId) {
pub fn from_fn_attrs(ccx: &CodegenCx, llfn: ValueRef, id: DefId) {
use syntax::attr::*;
let attrs = ccx.tcx.get_attrs(id);
inline(llfn, find_inline_attr(Some(ccx.sess().diagnostic()), &attrs));

View File

@ -59,7 +59,7 @@ use common::{C_bool, C_bytes_in_context, C_i32, C_usize};
use rustc_mir::monomorphize::collector::{self, MonoItemCollectionMode};
use common::{self, C_struct_in_context, C_array, val_ty};
use consts;
use context::{self, CrateContext};
use context::{self, CodegenCx};
use debuginfo;
use declare;
use meth;
@ -94,13 +94,13 @@ pub use rustc_trans_utils::{find_exported_symbols, check_for_rustc_errors_attr};
pub use rustc_mir::monomorphize::item::linkage_by_name;
pub struct StatRecorder<'a, 'tcx: 'a> {
ccx: &'a CrateContext<'a, 'tcx>,
ccx: &'a CodegenCx<'a, 'tcx>,
name: Option<String>,
istart: usize,
}
impl<'a, 'tcx> StatRecorder<'a, 'tcx> {
pub fn new(ccx: &'a CrateContext<'a, 'tcx>, name: String) -> StatRecorder<'a, 'tcx> {
pub fn new(ccx: &'a CodegenCx<'a, 'tcx>, name: String) -> StatRecorder<'a, 'tcx> {
let istart = ccx.stats.borrow().n_llvm_insns;
StatRecorder {
ccx,
@ -189,7 +189,7 @@ pub fn compare_simd_types<'a, 'tcx>(
/// The `old_info` argument is a bit funny. It is intended for use
/// in an upcast, where the new vtable for an object will be derived
/// from the old one.
pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
pub fn unsized_info<'ccx, 'tcx>(ccx: &CodegenCx<'ccx, 'tcx>,
source: Ty<'tcx>,
target: Ty<'tcx>,
old_info: Option<ValueRef>)
@ -455,7 +455,7 @@ pub fn call_memset<'a, 'tcx>(b: &Builder<'a, 'tcx>,
b.call(llintrinsicfn, &[ptr, fill_byte, size, align, volatile], None)
}
pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance<'tcx>) {
pub fn trans_instance<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, instance: Instance<'tcx>) {
let _s = if ccx.sess().trans_stats() {
let mut instance_name = String::new();
DefPathBasedNames::new(ccx.tcx, true, true)
@ -506,7 +506,7 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
mir::trans_mir(ccx, lldecl, &mir, instance, sig);
}
pub fn set_link_section(ccx: &CrateContext,
pub fn set_link_section(ccx: &CodegenCx,
llval: ValueRef,
attrs: &[ast::Attribute]) {
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,
/// Create the `main` function which will initialize the rust runtime and call
/// users main function.
fn maybe_create_entry_wrapper(ccx: &CrateContext) {
fn maybe_create_entry_wrapper(ccx: &CodegenCx) {
let (main_def_id, span) = match *ccx.sess().entry_fn.borrow() {
Some((id, span)) => {
(ccx.tcx.hir.local_def_id(id), span)
@ -547,7 +547,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
config::EntryNone => {} // Do nothing.
}
fn create_entry_fn<'ccx>(ccx: &'ccx CrateContext,
fn create_entry_fn<'ccx>(ccx: &'ccx CodegenCx,
sp: Span,
rust_main: ValueRef,
rust_main_def_id: DefId,
@ -1203,7 +1203,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
.to_fingerprint().to_hex());
// Instantiate translation items without filling out definitions yet...
let ccx = CrateContext::new(tcx, cgu, &llmod_id);
let ccx = CodegenCx::new(tcx, cgu, &llmod_id);
let module = {
let trans_items = ccx.codegen_unit
.items_in_deterministic_order(ccx.tcx);

View File

@ -32,7 +32,7 @@ use syntax_pos::Span;
#[must_use]
pub struct Builder<'a, 'tcx: 'a> {
pub llbuilder: BuilderRef,
pub ccx: &'a CrateContext<'a, 'tcx>,
pub ccx: &'a CodegenCx<'a, 'tcx>,
}
impl<'a, 'tcx> Drop for Builder<'a, 'tcx> {
@ -51,7 +51,7 @@ fn noname() -> *const c_char {
}
impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn new_block<'b>(ccx: &'a CrateContext<'a, 'tcx>, llfn: ValueRef, name: &'b str) -> Self {
pub fn new_block<'b>(ccx: &'a CodegenCx<'a, 'tcx>, llfn: ValueRef, name: &'b str) -> Self {
let builder = Builder::with_ccx(ccx);
let llbb = unsafe {
let name = CString::new(name).unwrap();
@ -65,7 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
builder
}
pub fn with_ccx(ccx: &'a CrateContext<'a, 'tcx>) -> Self {
pub fn with_ccx(ccx: &'a CodegenCx<'a, 'tcx>) -> Self {
// Create a fresh builder from the crate context.
let llbuilder = unsafe {
llvm::LLVMCreateBuilderInContext(ccx.llcx)

View File

@ -9,9 +9,9 @@
// except according to those terms.
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
use context::CrateContext;
use context::CodegenCx;
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>)
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
-> Option<Uniform> {
arg.layout.homogeneous_aggregate(ccx).and_then(|unit| {
let size = arg.layout.size;
@ -38,7 +38,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
return;
@ -69,7 +69,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret.make_indirect();
}
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(32);
return;
@ -100,7 +100,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
arg.make_indirect();
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret);
}

View File

@ -9,10 +9,10 @@
// except according to those terms.
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
use context::CrateContext;
use context::CodegenCx;
use llvm::CallConv;
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>)
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
-> Option<Uniform> {
arg.layout.homogeneous_aggregate(ccx).and_then(|unit| {
let size = arg.layout.size;
@ -39,7 +39,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>, vfp: bool) {
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>, vfp: bool) {
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
return;
@ -71,7 +71,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret.make_indirect();
}
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>, vfp: bool) {
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>, vfp: bool) {
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(32);
return;
@ -92,7 +92,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
// If this is a target with a hard-float ABI, and the function is not explicitly
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
let vfp = ccx.sess().target.target.llvm_target.ends_with("hf")

View File

@ -9,14 +9,14 @@
// except according to those terms.
use abi::{FnType, ArgType, LayoutExt, Uniform};
use context::CrateContext;
use context::CodegenCx;
// Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
if ret.layout.is_aggregate() {
if let Some(unit) = ret.layout.homogeneous_aggregate(ccx) {
let size = ret.layout.size;
@ -39,7 +39,7 @@ fn classify_arg_ty(arg: &mut ArgType) {
}
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret);
}

View File

@ -9,11 +9,11 @@
// except according to those terms.
use abi::{ArgType, FnType, LayoutExt, Reg, Uniform};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::Size;
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ret: &mut ArgType<'tcx>,
offset: &mut Size) {
if !ret.layout.is_aggregate() {
@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
fn classify_arg_ty(ccx: &CodegenCx, arg: &mut ArgType, offset: &mut Size) {
let dl = &ccx.tcx.data_layout;
let size = arg.layout.size;
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align);
@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*offset = offset.abi_align(align) + size.abi_align(align);
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let mut offset = Size::from_bytes(0);
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret, &mut offset);

View File

@ -9,11 +9,11 @@
// except according to those terms.
use abi::{ArgType, FnType, LayoutExt, Reg, Uniform};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::Size;
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ret: &mut ArgType<'tcx>,
offset: &mut Size) {
if !ret.layout.is_aggregate() {
@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
fn classify_arg_ty(ccx: &CodegenCx, arg: &mut ArgType, offset: &mut Size) {
let dl = &ccx.tcx.data_layout;
let size = arg.layout.size;
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align);
@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*offset = offset.abi_align(align) + size.abi_align(align);
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let mut offset = Size::from_bytes(0);
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret, &mut offset);

View File

@ -9,11 +9,11 @@
// except according to those terms.
use abi::{ArgType, FnType, LayoutExt, Reg, Uniform};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::Size;
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ret: &mut ArgType<'tcx>,
offset: &mut Size) {
if !ret.layout.is_aggregate() {
@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
fn classify_arg_ty(ccx: &CodegenCx, arg: &mut ArgType, offset: &mut Size) {
let dl = &ccx.tcx.data_layout;
let size = arg.layout.size;
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align);
@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*offset = offset.abi_align(align) + size.abi_align(align);
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let mut offset = Size::from_bytes(0);
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret, &mut offset);

View File

@ -13,7 +13,7 @@
// need to be fixed when PowerPC vector support is added.
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout;
#[derive(Debug, Clone, Copy, PartialEq)]
@ -23,7 +23,7 @@ enum ABI {
}
use self::ABI::*;
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
arg: &mut ArgType<'tcx>,
abi: ABI)
-> Option<Uniform> {
@ -52,7 +52,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
})
}
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>, abi: ABI) {
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>, abi: ABI) {
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
return;
@ -92,7 +92,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret.make_indirect();
}
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>, abi: ABI) {
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>, abi: ABI) {
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(64);
return;
@ -128,7 +128,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let abi = match ccx.sess().target.target.target_endian.as_str() {
"big" => ELFv1,
"little" => ELFv2,

View File

@ -12,7 +12,7 @@
// for a pre-z13 machine or using -mno-vx.
use abi::{FnType, ArgType, LayoutExt, Reg};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::{self, TyLayout};
@ -24,7 +24,7 @@ fn classify_ret_ty(ret: &mut ArgType) {
}
}
fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn is_single_fp_element<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>) -> bool {
match layout.abi {
layout::Abi::Scalar(ref scalar) => {
@ -44,7 +44,7 @@ fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
if !arg.layout.is_aggregate() && arg.layout.size.bits() <= 64 {
arg.extend_integer_width_to(64);
return;
@ -67,7 +67,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
}
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
if !fty.ret.is_ignore() {
classify_ret_ty(&mut fty.ret);
}

View File

@ -9,11 +9,11 @@
// except according to those terms.
use abi::{ArgType, FnType, LayoutExt, Reg, Uniform};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::Size;
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ret: &mut ArgType<'tcx>,
offset: &mut Size) {
if !ret.layout.is_aggregate() {
@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
fn classify_arg_ty(ccx: &CodegenCx, arg: &mut ArgType, offset: &mut Size) {
let dl = &ccx.tcx.data_layout;
let size = arg.layout.size;
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align);
@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*offset = offset.abi_align(align) + size.abi_align(align);
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let mut offset = Size::from_bytes(0);
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret, &mut offset);

View File

@ -11,9 +11,9 @@
// FIXME: This needs an audit for correctness and completeness.
use abi::{FnType, ArgType, LayoutExt, Reg, RegKind, Uniform};
use context::CrateContext;
use context::CodegenCx;
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>)
fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
-> Option<Uniform> {
arg.layout.homogeneous_aggregate(ccx).and_then(|unit| {
// Ensure we have at most eight uniquely addressable members.
@ -38,7 +38,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
fn classify_ret_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
return;
@ -72,7 +72,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret.make_indirect();
}
fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
fn classify_arg_ty<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>) {
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(64);
return;
@ -90,7 +90,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
if !fty.ret.is_ignore() {
classify_ret_ty(ccx, &mut fty.ret);
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
use abi::{ArgAttribute, FnType, LayoutExt, PassMode, Reg, RegKind};
use common::CrateContext;
use common::CodegenCx;
use rustc::ty::layout::{self, TyLayout};
@ -19,7 +19,7 @@ pub enum Flavor {
Fastcall
}
fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn is_single_fp_element<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>) -> bool {
match layout.abi {
layout::Abi::Scalar(ref scalar) => {
@ -39,7 +39,7 @@ fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
fty: &mut FnType<'tcx>,
flavor: Flavor) {
if !fty.ret.is_ignore() {

View File

@ -12,7 +12,7 @@
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
use abi::{ArgType, CastTarget, FnType, LayoutExt, Reg, RegKind};
use context::CrateContext;
use context::CodegenCx;
use rustc::ty::layout::{self, TyLayout, Size};
@ -31,7 +31,7 @@ struct Memory;
const LARGEST_VECTOR_SIZE: usize = 512;
const MAX_EIGHTBYTES: usize = LARGEST_VECTOR_SIZE / 64;
fn classify_arg<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &ArgType<'tcx>)
fn classify_arg<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, arg: &ArgType<'tcx>)
-> Result<[Class; MAX_EIGHTBYTES], Memory> {
fn unify(cls: &mut [Class],
off: Size,
@ -52,7 +52,7 @@ fn classify_arg<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &ArgType<'tcx>)
cls[i] = to_write;
}
fn classify<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn classify<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>,
cls: &mut [Class],
off: Size)
@ -189,7 +189,7 @@ fn cast_target(cls: &[Class], size: Size) -> CastTarget {
target
}
pub fn compute_abi_info<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fty: &mut FnType<'tcx>) {
pub fn compute_abi_info<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) {
let mut int_regs = 6; // RDI, RSI, RDX, RCX, R8, R9
let mut sse_regs = 8; // XMM0-7

View File

@ -15,7 +15,7 @@
//! closure.
use attributes;
use common::{self, CrateContext};
use common::{self, CodegenCx};
use consts;
use declare;
use llvm::{self, ValueRef};
@ -36,7 +36,7 @@ use rustc_back::PanicStrategy;
///
/// - `ccx`: the crate context
/// - `instance`: the instance to be instantiated
pub fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn get_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
instance: Instance<'tcx>)
-> ValueRef
{
@ -176,7 +176,7 @@ pub fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
llfn
}
pub fn resolve_and_get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn resolve_and_get_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
def_id: DefId,
substs: &'tcx Substs<'tcx>)
-> ValueRef

View File

@ -38,7 +38,7 @@ use syntax::abi::Abi;
use syntax::symbol::InternedString;
use syntax_pos::{Span, DUMMY_SP};
pub use context::CrateContext;
pub use context::CodegenCx;
pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
ty.needs_drop(tcx, ty::ParamEnv::empty(traits::Reveal::All))
@ -152,23 +152,23 @@ pub fn C_uint_big(t: Type, u: u128) -> ValueRef {
}
}
pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef {
pub fn C_bool(ccx: &CodegenCx, val: bool) -> ValueRef {
C_uint(Type::i1(ccx), val as u64)
}
pub fn C_i32(ccx: &CrateContext, i: i32) -> ValueRef {
pub fn C_i32(ccx: &CodegenCx, i: i32) -> ValueRef {
C_int(Type::i32(ccx), i as i64)
}
pub fn C_u32(ccx: &CrateContext, i: u32) -> ValueRef {
pub fn C_u32(ccx: &CodegenCx, i: u32) -> ValueRef {
C_uint(Type::i32(ccx), i as u64)
}
pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
pub fn C_u64(ccx: &CodegenCx, i: u64) -> ValueRef {
C_uint(Type::i64(ccx), i)
}
pub fn C_usize(ccx: &CrateContext, i: u64) -> ValueRef {
pub fn C_usize(ccx: &CodegenCx, i: u64) -> ValueRef {
let bit_size = ccx.data_layout().pointer_size.bits();
if bit_size < 64 {
// make sure it doesn't overflow
@ -178,14 +178,14 @@ pub fn C_usize(ccx: &CrateContext, i: u64) -> ValueRef {
C_uint(ccx.isize_ty, i)
}
pub fn C_u8(ccx: &CrateContext, i: u8) -> ValueRef {
pub fn C_u8(ccx: &CodegenCx, i: u8) -> ValueRef {
C_uint(Type::i8(ccx), i as u64)
}
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef {
pub fn C_cstr(cx: &CodegenCx, s: InternedString, null_terminated: bool) -> ValueRef {
unsafe {
if let Some(&llval) = cx.const_cstr_cache.borrow().get(&s) {
return llval;
@ -210,20 +210,20 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
// you will be kicked off fast isel. See issue #4352 for an example of this.
pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
pub fn C_str_slice(cx: &CodegenCx, s: InternedString) -> ValueRef {
let len = s.len();
let cs = consts::ptrcast(C_cstr(cx, s, false),
cx.layout_of(cx.tcx.mk_str()).llvm_type(cx).ptr_to());
C_fat_ptr(cx, cs, C_usize(cx, len as u64))
}
pub fn C_fat_ptr(cx: &CrateContext, ptr: ValueRef, meta: ValueRef) -> ValueRef {
pub fn C_fat_ptr(cx: &CodegenCx, ptr: ValueRef, meta: ValueRef) -> ValueRef {
assert_eq!(abi::FAT_PTR_ADDR, 0);
assert_eq!(abi::FAT_PTR_EXTRA, 1);
C_struct(cx, &[ptr, meta], false)
}
pub fn C_struct(cx: &CrateContext, elts: &[ValueRef], packed: bool) -> ValueRef {
pub fn C_struct(cx: &CodegenCx, elts: &[ValueRef], packed: bool) -> ValueRef {
C_struct_in_context(cx.llcx, elts, packed)
}
@ -247,7 +247,7 @@ pub fn C_vector(elts: &[ValueRef]) -> ValueRef {
}
}
pub fn C_bytes(cx: &CrateContext, bytes: &[u8]) -> ValueRef {
pub fn C_bytes(cx: &CodegenCx, bytes: &[u8]) -> ValueRef {
C_bytes_in_context(cx.llcx, bytes)
}
@ -382,7 +382,7 @@ pub fn shift_mask_val<'a, 'tcx>(
}
}
pub fn ty_fn_sig<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn ty_fn_sig<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ty: Ty<'tcx>)
-> ty::PolyFnSig<'tcx>
{

View File

@ -17,7 +17,7 @@ use rustc::middle::const_val::ConstEvalErr;
use debuginfo;
use base;
use monomorphize::{MonoItem, MonoItemExt};
use common::{CrateContext, val_ty};
use common::{CodegenCx, val_ty};
use declare;
use monomorphize::Instance;
use type_::Type;
@ -43,7 +43,7 @@ pub fn bitcast(val: ValueRef, ty: Type) -> ValueRef {
}
}
fn set_global_alignment(ccx: &CrateContext,
fn set_global_alignment(ccx: &CodegenCx,
gv: ValueRef,
mut align: Align) {
// The target may require greater alignment for globals than the type does.
@ -62,7 +62,7 @@ fn set_global_alignment(ccx: &CrateContext,
}
}
pub fn addr_of_mut(ccx: &CrateContext,
pub fn addr_of_mut(ccx: &CodegenCx,
cv: ValueRef,
align: Align,
kind: &str)
@ -80,7 +80,7 @@ pub fn addr_of_mut(ccx: &CrateContext,
}
}
pub fn addr_of(ccx: &CrateContext,
pub fn addr_of(ccx: &CodegenCx,
cv: ValueRef,
align: Align,
kind: &str)
@ -104,7 +104,7 @@ pub fn addr_of(ccx: &CrateContext,
gv
}
pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
pub fn get_static(ccx: &CodegenCx, def_id: DefId) -> ValueRef {
let instance = Instance::mono(ccx.tcx, def_id);
if let Some(&g) = ccx.instances.borrow().get(&instance) {
return g;
@ -244,7 +244,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
g
}
pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn trans_static<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
m: hir::Mutability,
id: ast::NodeId,
attrs: &[ast::Attribute])

View File

@ -42,10 +42,10 @@ use std::sync::Arc;
use syntax::symbol::InternedString;
use abi::Abi;
/// There is one `CrateContext` per compilation unit. Each one has its own LLVM
/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
/// `ContextRef` so that several compilation units may be optimized in parallel.
/// All other LLVM data structures in the `CrateContext` are tied to that `ContextRef`.
pub struct CrateContext<'a, 'tcx: 'a> {
/// All other LLVM data structures in the `CodegenCx` are tied to that `ContextRef`.
pub struct CodegenCx<'a, 'tcx: 'a> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
pub check_overflow: bool,
pub use_dll_storage_attrs: bool,
@ -107,7 +107,7 @@ pub struct CrateContext<'a, 'tcx: 'a> {
local_gen_sym_counter: Cell<usize>,
}
impl<'a, 'tcx> DepGraphSafe for CrateContext<'a, 'tcx> {
impl<'a, 'tcx> DepGraphSafe for CodegenCx<'a, 'tcx> {
}
pub fn get_reloc_model(sess: &Session) -> llvm::RelocMode {
@ -212,11 +212,11 @@ pub unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (Cont
(llcx, llmod)
}
impl<'a, 'tcx> CrateContext<'a, 'tcx> {
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
codegen_unit: Arc<CodegenUnit<'tcx>>,
llmod_id: &str)
-> CrateContext<'a, 'tcx> {
-> CodegenCx<'a, 'tcx> {
// An interesting part of Windows which MSVC forces our hand on (and
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
// attributes in LLVM IR as well as native dependencies (in C these
@ -280,7 +280,7 @@ impl<'a, 'tcx> CrateContext<'a, 'tcx> {
None
};
let mut ccx = CrateContext {
let mut ccx = CodegenCx {
tcx,
check_overflow,
use_dll_storage_attrs,
@ -318,7 +318,7 @@ impl<'a, 'tcx> CrateContext<'a, 'tcx> {
}
}
impl<'b, 'tcx> CrateContext<'b, 'tcx> {
impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
pub fn sess<'a>(&'a self) -> &'a Session {
&self.tcx.sess
}
@ -448,19 +448,19 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
}
}
impl<'a, 'tcx> ty::layout::HasDataLayout for &'a CrateContext<'a, 'tcx> {
impl<'a, 'tcx> ty::layout::HasDataLayout for &'a CodegenCx<'a, 'tcx> {
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
&self.tcx.data_layout
}
}
impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a CrateContext<'a, 'tcx> {
impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a CodegenCx<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.tcx
}
}
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CrateContext<'a, 'tcx> {
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CodegenCx<'a, 'tcx> {
type TyLayout = TyLayout<'tcx>;
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
@ -474,7 +474,7 @@ impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CrateContext<'a, 'tcx> {
}
/// Declare any llvm intrinsics that you might need
fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> {
fn declare_intrinsic(ccx: &CodegenCx, key: &str) -> Option<ValueRef> {
macro_rules! ifn {
($name:expr, fn() -> $ret:expr) => (
if key == $name {

View File

@ -14,7 +14,7 @@ use super::utils::{DIB, span_start};
use llvm;
use llvm::debuginfo::DIScope;
use common::CrateContext;
use common::CodegenCx;
use rustc::mir::{Mir, VisibilityScope};
use libc::c_uint;
@ -44,7 +44,7 @@ impl MirDebugScope {
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
/// If debuginfo is disabled, the returned vector is empty.
pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &FunctionDebugContext)
pub fn create_mir_scopes(ccx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebugContext)
-> IndexVec<VisibilityScope, MirDebugScope> {
let null_scope = MirDebugScope {
scope_metadata: ptr::null_mut(),
@ -77,7 +77,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
scopes
}
fn make_mir_scope(ccx: &CrateContext,
fn make_mir_scope(ccx: &CodegenCx,
mir: &Mir,
has_variables: &BitVector,
debug_context: &FunctionDebugContextData,

View File

@ -44,7 +44,7 @@
//! that exact file path.
//!
//! All private state used by the module is stored within either the
//! CrateDebugContext struct (owned by the CrateContext) or the
//! CrateDebugContext struct (owned by the CodegenCx) or the
//! FunctionDebugContext (owned by the MirContext).
//!
//! This file consists of three conceptual sections:

View File

@ -12,7 +12,7 @@
use llvm;
use common::{C_bytes, CrateContext, C_i32};
use common::{C_bytes, CodegenCx, C_i32};
use builder::Builder;
use declare;
use type_::Type;
@ -24,7 +24,7 @@ use syntax::attr;
/// Inserts a side-effect free instruction sequence that makes sure that the
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
pub fn insert_reference_to_gdb_debug_scripts_section_global(ccx: &CrateContext, builder: &Builder) {
pub fn insert_reference_to_gdb_debug_scripts_section_global(ccx: &CodegenCx, builder: &Builder) {
if needs_gdb_debug_scripts_section(ccx) {
let gdb_debug_scripts_section_global = get_or_insert_gdb_debug_scripts_section_global(ccx);
// Load just the first byte as that's all that's necessary to force
@ -40,7 +40,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(ccx: &CrateContext,
/// Allocates the global variable responsible for the .debug_gdb_scripts binary
/// section.
pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CodegenCx)
-> llvm::ValueRef {
let c_section_var_name = "__rustc_debug_gdb_scripts_section__\0";
let section_var_name = &c_section_var_name[..c_section_var_name.len()-1];
@ -77,7 +77,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
}
}
pub fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
pub fn needs_gdb_debug_scripts_section(ccx: &CodegenCx) -> bool {
let omit_gdb_pretty_printer_section =
attr::contains_name(&ccx.tcx.hir.krate_attrs(),
"omit_gdb_pretty_printer_section");

View File

@ -29,7 +29,7 @@ use rustc::ty::fold::TypeVisitor;
use rustc::ty::util::TypeIdHasher;
use rustc::ich::Fingerprint;
use rustc::ty::Instance;
use common::CrateContext;
use common::CodegenCx;
use rustc::ty::{self, AdtKind, Ty, TyCtxt};
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
use rustc::session::config;
@ -133,7 +133,7 @@ impl<'tcx> TypeMap<'tcx> {
// Get the UniqueTypeId for the given type. If the UniqueTypeId for the given
// type has been requested before, this is just a table lookup. Otherwise an
// ID will be generated and stored for later lookup.
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>,
type_: Ty<'tcx>) -> UniqueTypeId {
// Let's see if we already have something in the cache
match self.type_to_unique_id.get(&type_).cloned() {
@ -157,7 +157,7 @@ impl<'tcx> TypeMap<'tcx> {
// types of their own, so they need special handling. We still need a
// UniqueTypeId for them, since to debuginfo they *are* real types.
fn get_unique_type_id_of_enum_variant<'a>(&mut self,
cx: &CrateContext<'a, 'tcx>,
cx: &CodegenCx<'a, 'tcx>,
enum_type: Ty<'tcx>,
variant_name: &str)
-> UniqueTypeId {
@ -186,7 +186,7 @@ enum RecursiveTypeDescription<'tcx> {
}
fn create_and_register_recursive_type_forward_declaration<'a, 'tcx>(
cx: &CrateContext<'a, 'tcx>,
cx: &CodegenCx<'a, 'tcx>,
unfinished_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
metadata_stub: DICompositeType,
@ -210,7 +210,7 @@ impl<'tcx> RecursiveTypeDescription<'tcx> {
// Finishes up the description of the type in question (mostly by providing
// descriptions of the fields of the given type) and returns the final type
// metadata.
fn finalize<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> MetadataCreationResult {
fn finalize<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> MetadataCreationResult {
match *self {
FinalMetadata(metadata) => MetadataCreationResult::new(metadata, false),
UnfinishedMetadata {
@ -262,7 +262,7 @@ macro_rules! return_if_metadata_created_in_meantime {
)
}
fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn fixed_vec_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
unique_type_id: UniqueTypeId,
array_or_slice_type: Ty<'tcx>,
element_type: Ty<'tcx>,
@ -298,7 +298,7 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return MetadataCreationResult::new(metadata, false);
}
fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn vec_slice_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
slice_ptr_type: Ty<'tcx>,
element_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
@ -347,7 +347,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
MetadataCreationResult::new(metadata, false)
}
fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn subroutine_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
unique_type_id: UniqueTypeId,
signature: ty::PolyFnSig<'tcx>,
span: Span)
@ -386,7 +386,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// trait_type should be the actual trait (e.g., Trait). Where the trait is part
// of a DST struct, there is no trait_object_type and the results of this
// function will be a little bit weird.
fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn trait_pointer_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
trait_type: Ty<'tcx>,
trait_object_type: Option<Ty<'tcx>>,
unique_type_id: UniqueTypeId)
@ -453,7 +453,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
syntax_pos::DUMMY_SP)
}
pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
pub fn type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>,
usage_site_span: Span)
-> DIType {
@ -673,7 +673,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
metadata
}
pub fn file_metadata(cx: &CrateContext,
pub fn file_metadata(cx: &CodegenCx,
file_name: &FileName,
defining_crate: CrateNum) -> DIFile {
debug!("file_metadata: file_name: {}, defining_crate: {}",
@ -691,11 +691,11 @@ pub fn file_metadata(cx: &CrateContext,
file_metadata_raw(cx, &file_name.to_string(), &directory.to_string_lossy())
}
pub fn unknown_file_metadata(cx: &CrateContext) -> DIFile {
pub fn unknown_file_metadata(cx: &CodegenCx) -> DIFile {
file_metadata_raw(cx, "<unknown>", "")
}
fn file_metadata_raw(cx: &CrateContext,
fn file_metadata_raw(cx: &CodegenCx,
file_name: &str,
directory: &str)
-> DIFile {
@ -721,7 +721,7 @@ fn file_metadata_raw(cx: &CrateContext,
file_metadata
}
fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn basic_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>) -> DIType {
debug!("basic_type_metadata: {:?}", t);
@ -758,7 +758,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return ty_metadata;
}
fn foreign_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn foreign_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>,
unique_type_id: UniqueTypeId) -> DIType {
debug!("foreign_type_metadata: {:?}", t);
@ -767,7 +767,7 @@ fn foreign_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
create_struct_stub(cx, t, &name, unique_type_id, NO_SCOPE_METADATA)
}
fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn pointer_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
pointer_type: Ty<'tcx>,
pointee_type_metadata: DIType)
-> DIType {
@ -901,7 +901,7 @@ enum MemberDescriptionFactory<'tcx> {
}
impl<'tcx> MemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
match *self {
StructMDF(ref this) => {
@ -935,7 +935,7 @@ struct StructMemberDescriptionFactory<'tcx> {
}
impl<'tcx> StructMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
let layout = cx.layout_of(self.ty);
self.variant.fields.iter().enumerate().map(|(i, f)| {
@ -959,7 +959,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
}
fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn prepare_struct_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
struct_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
span: Span)
@ -1004,7 +1004,7 @@ struct TupleMemberDescriptionFactory<'tcx> {
}
impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
let layout = cx.layout_of(self.ty);
self.component_types.iter().enumerate().map(|(i, &component_type)| {
@ -1021,7 +1021,7 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
}
}
fn prepare_tuple_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn prepare_tuple_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
tuple_type: Ty<'tcx>,
component_types: &[Ty<'tcx>],
unique_type_id: UniqueTypeId,
@ -1057,7 +1057,7 @@ struct UnionMemberDescriptionFactory<'tcx> {
}
impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
self.variant.fields.iter().enumerate().map(|(i, f)| {
let field = self.layout.field(cx, i);
@ -1074,7 +1074,7 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
}
}
fn prepare_union_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn prepare_union_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
union_type: Ty<'tcx>,
unique_type_id: UniqueTypeId,
span: Span)
@ -1125,7 +1125,7 @@ struct EnumMemberDescriptionFactory<'tcx> {
}
impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
let adt = &self.enum_type.ty_adt_def().unwrap();
match self.layout.variants {
@ -1210,7 +1210,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
// of discriminant instead of us having to recover its path.
// Right now it's not even going to work for `niche_start > 0`,
// and for multiple niche variants it only supports the first.
fn compute_field_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn compute_field_path<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
name: &mut String,
layout: TyLayout<'tcx>,
offset: Size,
@ -1260,7 +1260,7 @@ struct VariantMemberDescriptionFactory<'tcx> {
}
impl<'tcx> VariantMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
fn create_member_descriptions<'a>(&self, cx: &CodegenCx<'a, 'tcx>)
-> Vec<MemberDescription> {
self.args.iter().enumerate().map(|(i, &(ref name, ty))| {
let (size, align) = cx.size_and_align_of(ty);
@ -1290,7 +1290,7 @@ enum EnumDiscriminantInfo {
// of the variant, and (3) a MemberDescriptionFactory for producing the
// descriptions of the fields of the variant. This is a rudimentary version of a
// full RecursiveTypeDescription.
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn describe_enum_variant<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
layout: layout::TyLayout<'tcx>,
variant: &'tcx ty::VariantDef,
discriminant_info: EnumDiscriminantInfo,
@ -1350,7 +1350,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
(metadata_stub, member_description_factory)
}
fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn prepare_enum_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
enum_type: Ty<'tcx>,
enum_def_id: DefId,
unique_type_id: UniqueTypeId,
@ -1470,7 +1470,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}),
);
fn get_enum_discriminant_name(cx: &CrateContext,
fn get_enum_discriminant_name(cx: &CodegenCx,
def_id: DefId)
-> InternedString {
cx.tcx.item_name(def_id)
@ -1481,7 +1481,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
/// results in a LLVM struct.
///
/// Examples of Rust types to use this are: structs, tuples, boxes, vecs, and enums.
fn composite_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn composite_type_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
composite_type: Ty<'tcx>,
composite_type_name: &str,
composite_type_unique_id: UniqueTypeId,
@ -1507,7 +1507,7 @@ fn composite_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return composite_type_metadata;
}
fn set_members_of_composite_type(cx: &CrateContext,
fn set_members_of_composite_type(cx: &CodegenCx,
composite_type_metadata: DICompositeType,
member_descriptions: &[MemberDescription]) {
// In some rare cases LLVM metadata uniquing would lead to an existing type
@ -1558,7 +1558,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
// A convenience wrapper around LLVMRustDIBuilderCreateStructType(). Does not do
// any caching, does not add any fields to the struct. This can be done later
// with set_members_of_composite_type().
fn create_struct_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn create_struct_stub<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
struct_type: Ty<'tcx>,
struct_type_name: &str,
unique_type_id: UniqueTypeId,
@ -1595,7 +1595,7 @@ fn create_struct_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return metadata_stub;
}
fn create_union_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn create_union_stub<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
union_type: Ty<'tcx>,
union_type_name: &str,
unique_type_id: UniqueTypeId,
@ -1633,7 +1633,7 @@ fn create_union_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
/// Creates debug information for the given global variable.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_global_var_metadata(cx: &CrateContext,
pub fn create_global_var_metadata(cx: &CodegenCx,
node_id: ast::NodeId,
global: ValueRef) {
if cx.dbg_cx.is_none() {
@ -1689,7 +1689,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
}
// Creates an "extension" of an existing DIScope into another file.
pub fn extend_scope_to_file(ccx: &CrateContext,
pub fn extend_scope_to_file(ccx: &CodegenCx,
scope_metadata: DIScope,
file: &syntax_pos::FileMap,
defining_crate: CrateNum)
@ -1707,7 +1707,7 @@ pub fn extend_scope_to_file(ccx: &CrateContext,
/// given type.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub fn create_vtable_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
pub fn create_vtable_metadata<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
ty: ty::Ty<'tcx>,
vtable: ValueRef) {
if cx.dbg_cx.is_none() {

View File

@ -27,7 +27,7 @@ use rustc::hir::def_id::{DefId, CrateNum};
use rustc::ty::subst::Substs;
use abi::Abi;
use common::CrateContext;
use common::CodegenCx;
use builder::Builder;
use monomorphize::Instance;
use rustc::ty::{self, Ty};
@ -150,7 +150,7 @@ pub enum VariableKind {
}
/// Create any deferred debug metadata nodes
pub fn finalize(cx: &CrateContext) {
pub fn finalize(cx: &CodegenCx) {
if cx.dbg_cx.is_none() {
return;
}
@ -201,7 +201,7 @@ pub fn finalize(cx: &CrateContext) {
/// for debug info creation. The function may also return another variant of the
/// FunctionDebugContext enum which indicates why no debuginfo should be created
/// for the function.
pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
instance: Instance<'tcx>,
sig: ty::FnSig<'tcx>,
llfn: ValueRef,
@ -299,7 +299,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return FunctionDebugContext::RegularContext(fn_debug_context);
fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn get_function_signature<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
sig: ty::FnSig<'tcx>) -> DIArray {
if cx.sess().opts.debuginfo == LimitedDebugInfo {
return create_DIArray(DIB(cx), &[]);
@ -358,7 +358,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return create_DIArray(DIB(cx), &signature[..]);
}
fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn get_template_parameters<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
generics: &ty::Generics,
substs: &Substs<'tcx>,
file_metadata: DIFile,
@ -409,7 +409,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return create_DIArray(DIB(cx), &template_params[..]);
}
fn get_type_parameter_names(cx: &CrateContext, generics: &ty::Generics) -> Vec<ast::Name> {
fn get_type_parameter_names(cx: &CodegenCx, generics: &ty::Generics) -> Vec<ast::Name> {
let mut names = generics.parent.map_or(vec![], |def_id| {
get_type_parameter_names(cx, cx.tcx.generics_of(def_id))
});
@ -417,7 +417,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
names
}
fn get_containing_scope<'ccx, 'tcx>(cx: &CrateContext<'ccx, 'tcx>,
fn get_containing_scope<'ccx, 'tcx>(cx: &CodegenCx<'ccx, 'tcx>,
instance: Instance<'tcx>)
-> DIScope {
// First, let's see if this is a method within an inherent impl. Because

View File

@ -20,13 +20,13 @@ use llvm;
use llvm::debuginfo::DIScope;
use rustc::hir::def_id::DefId;
use rustc::hir::map::DefPathData;
use common::CrateContext;
use common::CodegenCx;
use std::ffi::CString;
use std::ptr;
pub fn mangled_name_of_instance<'a, 'tcx>(
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
instance: Instance<'tcx>,
) -> ty::SymbolName {
let tcx = ccx.tcx;
@ -34,7 +34,7 @@ pub fn mangled_name_of_instance<'a, 'tcx>(
}
pub fn mangled_name_of_item<'a, 'tcx>(
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
node_id: ast::NodeId,
) -> ty::SymbolName {
let tcx = ccx.tcx;
@ -43,7 +43,7 @@ pub fn mangled_name_of_item<'a, 'tcx>(
tcx.symbol_name(instance)
}
pub fn item_namespace(ccx: &CrateContext, def_id: DefId) -> DIScope {
pub fn item_namespace(ccx: &CodegenCx, def_id: DefId) -> DIScope {
if let Some(&scope) = debug_context(ccx).namespace_map.borrow().get(&def_id) {
return scope;
}

View File

@ -10,7 +10,7 @@
// Type Names for Debug Info.
use common::CrateContext;
use common::CodegenCx;
use rustc::hir::def_id::DefId;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty};
@ -21,7 +21,7 @@ use rustc::hir;
// any caching, i.e. calling the function twice with the same type will also do
// the work twice. The `qualified` parameter only affects the first level of the
// type name, further levels (i.e. type parameters) are always fully qualified.
pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>,
qualified: bool)
-> String {
@ -32,7 +32,7 @@ pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Pushes the name of the type as it should be stored in debuginfo on the
// `output` String. See also compute_debuginfo_type_name().
pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>,
qualified: bool,
output: &mut String) {
@ -179,7 +179,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
fn push_item_name(cx: &CrateContext,
fn push_item_name(cx: &CodegenCx,
def_id: DefId,
qualified: bool,
output: &mut String) {
@ -199,7 +199,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// reconstructed for items from non-local crates. For local crates, this
// would be possible but with inlining and LTO we have to use the least
// common denominator - otherwise we would run into conflicts.
fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
fn push_type_params<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
substs: &Substs<'tcx>,
output: &mut String) {
if substs.types().next().is_none() {

View File

@ -18,12 +18,12 @@ use rustc::ty::DefIdTree;
use llvm;
use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray};
use common::{CrateContext};
use common::{CodegenCx};
use syntax_pos::{self, Span};
use syntax::ast;
pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
pub fn is_node_local_to_unit(cx: &CodegenCx, node_id: ast::NodeId) -> bool
{
// The is_local_to_unit flag indicates whether a function is local to the
// current compilation unit (i.e. if it is *static* in the C-sense). The
@ -45,23 +45,23 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
}
/// Return syntax_pos::Loc corresponding to the beginning of the span
pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc {
cx.sess().codemap().lookup_char_pos(span.lo())
}
#[inline]
pub fn debug_context<'a, 'tcx>(cx: &'a CrateContext<'a, 'tcx>)
pub fn debug_context<'a, 'tcx>(cx: &'a CodegenCx<'a, 'tcx>)
-> &'a CrateDebugContext<'tcx> {
cx.dbg_cx.as_ref().unwrap()
}
#[inline]
#[allow(non_snake_case)]
pub fn DIB(cx: &CrateContext) -> DIBuilderRef {
pub fn DIB(cx: &CodegenCx) -> DIBuilderRef {
cx.dbg_cx.as_ref().unwrap().builder
}
pub fn get_namespace_for_item(cx: &CrateContext, def_id: DefId) -> DIScope {
pub fn get_namespace_for_item(cx: &CodegenCx, def_id: DefId) -> DIScope {
item_namespace(cx, cx.tcx.parent(def_id)
.expect("get_namespace_for_item: missing parent?"))
}

View File

@ -27,7 +27,7 @@ use rustc::session::config::Sanitizer;
use rustc_back::PanicStrategy;
use abi::{Abi, FnType};
use attributes;
use context::CrateContext;
use context::CodegenCx;
use common;
use type_::Type;
use value::Value;
@ -39,7 +39,7 @@ use std::ffi::CString;
///
/// If theres a value with the same name already declared, the function will
/// return its ValueRef instead.
pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRef {
pub fn declare_global(ccx: &CodegenCx, name: &str, ty: Type) -> llvm::ValueRef {
debug!("declare_global(name={:?})", name);
let namebuf = CString::new(name).unwrap_or_else(|_|{
bug!("name {:?} contains an interior null byte", name)
@ -54,7 +54,7 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
///
/// If theres a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: Type) -> ValueRef {
fn declare_raw_fn(ccx: &CodegenCx, name: &str, callconv: llvm::CallConv, ty: Type) -> ValueRef {
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
let namebuf = CString::new(name).unwrap_or_else(|_|{
bug!("name {:?} contains an interior null byte", name)
@ -114,7 +114,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
///
/// If theres a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type) -> ValueRef {
pub fn declare_cfn(ccx: &CodegenCx, name: &str, fn_type: Type) -> ValueRef {
declare_raw_fn(ccx, name, llvm::CCallConv, fn_type)
}
@ -123,7 +123,7 @@ pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type) -> ValueRef {
///
/// If theres a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
pub fn declare_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>, name: &str,
fn_type: Ty<'tcx>) -> ValueRef {
debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, fn_type);
let sig = common::ty_fn_sig(ccx, fn_type);
@ -154,7 +154,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
/// return None if the name already has a definition associated with it. In that
/// case an error should be reported to the user, because it usually happens due
/// to users fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
pub fn define_global(ccx: &CrateContext, name: &str, ty: Type) -> Option<ValueRef> {
pub fn define_global(ccx: &CodegenCx, name: &str, ty: Type) -> Option<ValueRef> {
if get_defined_value(ccx, name).is_some() {
None
} else {
@ -167,7 +167,7 @@ pub fn define_global(ccx: &CrateContext, name: &str, ty: Type) -> Option<ValueRe
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
pub fn define_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn define_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
name: &str,
fn_type: Ty<'tcx>) -> ValueRef {
if get_defined_value(ccx, name).is_some() {
@ -182,7 +182,7 @@ pub fn define_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
pub fn define_internal_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn define_internal_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
name: &str,
fn_type: Ty<'tcx>) -> ValueRef {
let llfn = define_fn(ccx, name, fn_type);
@ -192,7 +192,7 @@ pub fn define_internal_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
/// Get declared value by name.
pub fn get_declared_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
pub fn get_declared_value(ccx: &CodegenCx, name: &str) -> Option<ValueRef> {
debug!("get_declared_value(name={:?})", name);
let namebuf = CString::new(name).unwrap_or_else(|_|{
bug!("name {:?} contains an interior null byte", name)
@ -209,7 +209,7 @@ pub fn get_declared_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
/// Get defined or externally defined (AvailableExternally linkage) value by
/// name.
pub fn get_defined_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
pub fn get_defined_value(ccx: &CodegenCx, name: &str) -> Option<ValueRef> {
get_declared_value(ccx, name).and_then(|val|{
let declaration = unsafe {
llvm::LLVMIsDeclaration(val) != 0

View File

@ -35,7 +35,7 @@ use syntax_pos::Span;
use std::cmp::Ordering;
use std::iter;
fn get_simple_intrinsic(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
fn get_simple_intrinsic(ccx: &CodegenCx, name: &str) -> Option<ValueRef> {
let llvm_name = match name {
"sqrtf32" => "llvm.sqrt.f32",
"sqrtf64" => "llvm.sqrt.f64",
@ -565,7 +565,7 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
assert_eq!(x.len(), 1);
x.into_iter().next().unwrap()
}
fn ty_to_type(ccx: &CrateContext, t: &intrinsics::Type) -> Vec<Type> {
fn ty_to_type(ccx: &CodegenCx, t: &intrinsics::Type) -> Vec<Type> {
use intrinsics::Type::*;
match *t {
Void => vec![Type::void(ccx)],
@ -750,7 +750,7 @@ fn memset_intrinsic<'a, 'tcx>(
fn try_intrinsic<'a, 'tcx>(
bcx: &Builder<'a, 'tcx>,
ccx: &CrateContext,
ccx: &CodegenCx,
func: ValueRef,
data: ValueRef,
local_ptr: ValueRef,
@ -775,7 +775,7 @@ fn try_intrinsic<'a, 'tcx>(
// writing, however, LLVM does not recommend the usage of these new instructions
// as the old ones are still more optimized.
fn trans_msvc_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
ccx: &CrateContext,
ccx: &CodegenCx,
func: ValueRef,
data: ValueRef,
local_ptr: ValueRef,
@ -883,7 +883,7 @@ fn trans_msvc_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
// functions in play. By calling a shim we're guaranteed that our shim will have
// the right personality function.
fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
ccx: &CrateContext,
ccx: &CodegenCx,
func: ValueRef,
data: ValueRef,
local_ptr: ValueRef,
@ -942,7 +942,7 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
// Helper function to give a Block to a closure to translate a shim function.
// This is currently primarily used for the `try` intrinsic functions above.
fn gen_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn gen_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
name: &str,
inputs: Vec<Ty<'tcx>>,
output: Ty<'tcx>,
@ -965,7 +965,7 @@ fn gen_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// catch exceptions.
//
// This function is only generated once and is then cached.
fn get_rust_try_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn get_rust_try_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
trans: &mut for<'b> FnMut(Builder<'b, 'tcx>))
-> ValueRef {
if let Some(llfn) = ccx.rust_try_fn.get() {
@ -1243,7 +1243,7 @@ fn generic_simd_intrinsic<'a, 'tcx>(
// Returns None if the type is not an integer
// FIXME: theres multiple of this functions, investigate using some of the already existing
// stuffs.
fn int_type_width_signed(ty: Ty, ccx: &CrateContext) -> Option<(u64, bool)> {
fn int_type_width_signed(ty: Ty, ccx: &CodegenCx) -> Option<(u64, bool)> {
match ty.sty {
ty::TyInt(t) => Some((match t {
ast::IntTy::Isize => {

View File

@ -69,7 +69,7 @@ impl<'a, 'tcx> VirtualIndex {
/// The `trait_ref` encodes the erased self type. Hence if we are
/// making an object `Foo<Trait>` from a value of type `Foo<T>`, then
/// `trait_ref` would map `T:Trait`.
pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
pub fn get_vtable<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
ty: Ty<'tcx>,
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>)
-> ValueRef

View File

@ -27,7 +27,7 @@ use base;
use abi::{self, Abi};
use callee;
use builder::Builder;
use common::{self, CrateContext, const_get_elt, val_ty};
use common::{self, CodegenCx, const_get_elt, val_ty};
use common::{C_array, C_bool, C_bytes, C_int, C_uint, C_uint_big, C_u32, C_u64};
use common::{C_null, C_struct, C_str_slice, C_undef, C_usize, C_vector, C_fat_ptr};
use common::const_to_opt_u128;
@ -62,7 +62,7 @@ impl<'a, 'tcx> Const<'tcx> {
}
}
pub fn from_constint(ccx: &CrateContext<'a, 'tcx>, ci: &ConstInt) -> Const<'tcx> {
pub fn from_constint(ccx: &CodegenCx<'a, 'tcx>, ci: &ConstInt) -> Const<'tcx> {
let tcx = ccx.tcx;
let (llval, ty) = match *ci {
I8(v) => (C_int(Type::i8(ccx), v as i64), tcx.types.i8),
@ -82,7 +82,7 @@ impl<'a, 'tcx> Const<'tcx> {
}
/// Translate ConstVal into a LLVM constant value.
pub fn from_constval(ccx: &CrateContext<'a, 'tcx>,
pub fn from_constval(ccx: &CodegenCx<'a, 'tcx>,
cv: &ConstVal,
ty: Ty<'tcx>)
-> Const<'tcx> {
@ -115,7 +115,7 @@ impl<'a, 'tcx> Const<'tcx> {
Const::new(val, ty)
}
fn get_field(&self, ccx: &CrateContext<'a, 'tcx>, i: usize) -> ValueRef {
fn get_field(&self, ccx: &CodegenCx<'a, 'tcx>, i: usize) -> ValueRef {
let layout = ccx.layout_of(self.ty);
let field = layout.field(ccx, i);
if field.is_zst() {
@ -145,11 +145,11 @@ impl<'a, 'tcx> Const<'tcx> {
}
}
fn get_pair(&self, ccx: &CrateContext<'a, 'tcx>) -> (ValueRef, ValueRef) {
fn get_pair(&self, ccx: &CodegenCx<'a, 'tcx>) -> (ValueRef, ValueRef) {
(self.get_field(ccx, 0), self.get_field(ccx, 1))
}
fn get_fat_ptr(&self, ccx: &CrateContext<'a, 'tcx>) -> (ValueRef, ValueRef) {
fn get_fat_ptr(&self, ccx: &CodegenCx<'a, 'tcx>) -> (ValueRef, ValueRef) {
assert_eq!(abi::FAT_PTR_ADDR, 0);
assert_eq!(abi::FAT_PTR_EXTRA, 1);
self.get_pair(ccx)
@ -163,7 +163,7 @@ impl<'a, 'tcx> Const<'tcx> {
}
}
pub fn to_operand(&self, ccx: &CrateContext<'a, 'tcx>) -> OperandRef<'tcx> {
pub fn to_operand(&self, ccx: &CodegenCx<'a, 'tcx>) -> OperandRef<'tcx> {
let layout = ccx.layout_of(self.ty);
let llty = layout.immediate_llvm_type(ccx);
let llvalty = val_ty(self.llval);
@ -232,7 +232,7 @@ impl<'tcx> ConstPlace<'tcx> {
}
}
pub fn len<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> ValueRef {
pub fn len<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> ValueRef {
match self.ty.sty {
ty::TyArray(_, n) => {
C_usize(ccx, n.val.to_const_int().unwrap().to_u64().unwrap())
@ -249,7 +249,7 @@ impl<'tcx> ConstPlace<'tcx> {
/// Machinery for translating a constant's MIR to LLVM values.
/// FIXME(eddyb) use miri and lower its allocations to LLVM.
struct MirConstContext<'a, 'tcx: 'a> {
ccx: &'a CrateContext<'a, 'tcx>,
ccx: &'a CodegenCx<'a, 'tcx>,
mir: &'a mir::Mir<'tcx>,
/// Type parameters for const fn and associated constants.
@ -270,7 +270,7 @@ fn add_err<'tcx, U, V>(failure: &mut Result<U, ConstEvalErr<'tcx>>,
}
impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
fn new(ccx: &'a CrateContext<'a, 'tcx>,
fn new(ccx: &'a CodegenCx<'a, 'tcx>,
mir: &'a mir::Mir<'tcx>,
substs: &'tcx Substs<'tcx>,
args: IndexVec<mir::Local, Result<Const<'tcx>, ConstEvalErr<'tcx>>>)
@ -289,7 +289,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
context
}
fn trans_def(ccx: &'a CrateContext<'a, 'tcx>,
fn trans_def(ccx: &'a CodegenCx<'a, 'tcx>,
def_id: DefId,
substs: &'tcx Substs<'tcx>,
args: IndexVec<mir::Local, Result<Const<'tcx>, ConstEvalErr<'tcx>>>)
@ -1060,7 +1060,7 @@ pub fn const_scalar_checked_binop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
unsafe fn cast_const_float_to_int(ccx: &CrateContext,
unsafe fn cast_const_float_to_int(ccx: &CodegenCx,
operand: &Const,
signed: bool,
int_ty: Type,
@ -1095,7 +1095,7 @@ unsafe fn cast_const_float_to_int(ccx: &CrateContext,
C_uint_big(int_ty, cast_result.value)
}
unsafe fn cast_const_int_to_float(ccx: &CrateContext,
unsafe fn cast_const_int_to_float(ccx: &CodegenCx,
llval: ValueRef,
signed: bool,
float_ty: Type) -> ValueRef {
@ -1154,7 +1154,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
pub fn trans_static_initializer<'a, 'tcx>(
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
def_id: DefId)
-> Result<ValueRef, ConstEvalErr<'tcx>>
{
@ -1182,7 +1182,7 @@ pub fn trans_static_initializer<'a, 'tcx>(
/// this could be changed in the future to avoid allocating unnecessary
/// space after values of shorter-than-maximum cases.
fn trans_const_adt<'a, 'tcx>(
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
t: Ty<'tcx>,
kind: &mir::AggregateKind,
vals: &[Const<'tcx>]
@ -1272,7 +1272,7 @@ fn trans_const_adt<'a, 'tcx>(
/// initializer is 4-byte aligned then simply translating the tuple as
/// a two-element struct will locate it at offset 4, and accesses to it
/// will read the wrong memory.
fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn build_const_struct<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: layout::TyLayout<'tcx>,
vals: &[Const<'tcx>],
discr: Option<Const<'tcx>>)
@ -1332,6 +1332,6 @@ fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
Const::new(C_struct(ccx, &cfields, packed), layout.ty)
}
fn padding(ccx: &CrateContext, size: Size) -> ValueRef {
fn padding(ccx: &CodegenCx, size: Size) -> ValueRef {
C_undef(Type::array(&Type::i8(ccx), size.bytes()))
}

View File

@ -19,7 +19,7 @@ use rustc::infer::TransNormalize;
use rustc::session::config::FullDebugInfo;
use base;
use builder::Builder;
use common::{CrateContext, Funclet};
use common::{CodegenCx, Funclet};
use debuginfo::{self, declare_local, VariableAccess, VariableKind, FunctionDebugContext};
use monomorphize::Instance;
use abi::{ArgAttribute, FnType, PassMode};
@ -48,7 +48,7 @@ pub struct MirContext<'a, 'tcx:'a> {
llfn: ValueRef,
ccx: &'a CrateContext<'a, 'tcx>,
ccx: &'a CodegenCx<'a, 'tcx>,
fn_ty: FnType<'tcx>,
@ -176,7 +176,7 @@ enum LocalRef<'tcx> {
}
impl<'a, 'tcx> LocalRef<'tcx> {
fn new_operand(ccx: &CrateContext<'a, 'tcx>, layout: TyLayout<'tcx>) -> LocalRef<'tcx> {
fn new_operand(ccx: &CodegenCx<'a, 'tcx>, layout: TyLayout<'tcx>) -> LocalRef<'tcx> {
if layout.is_zst() {
// Zero-size temporaries aren't always initialized, which
// doesn't matter because they don't contain data, but
@ -191,7 +191,7 @@ impl<'a, 'tcx> LocalRef<'tcx> {
///////////////////////////////////////////////////////////////////////////
pub fn trans_mir<'a, 'tcx: 'a>(
ccx: &'a CrateContext<'a, 'tcx>,
ccx: &'a CodegenCx<'a, 'tcx>,
llfn: ValueRef,
mir: &'a Mir<'tcx>,
instance: Instance<'tcx>,

View File

@ -15,7 +15,7 @@ use rustc::mir;
use rustc_data_structures::indexed_vec::Idx;
use base;
use common::{self, CrateContext, C_undef, C_usize};
use common::{self, CodegenCx, C_undef, C_usize};
use builder::Builder;
use value::Value;
use type_of::LayoutLlvmExt;
@ -81,7 +81,7 @@ impl<'tcx> fmt::Debug for OperandRef<'tcx> {
}
impl<'a, 'tcx> OperandRef<'tcx> {
pub fn new_zst(ccx: &CrateContext<'a, 'tcx>,
pub fn new_zst(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>) -> OperandRef<'tcx> {
assert!(layout.is_zst());
OperandRef {
@ -99,7 +99,7 @@ impl<'a, 'tcx> OperandRef<'tcx> {
}
}
pub fn deref(self, ccx: &CrateContext<'a, 'tcx>) -> PlaceRef<'tcx> {
pub fn deref(self, ccx: &CodegenCx<'a, 'tcx>) -> PlaceRef<'tcx> {
let projected_ty = self.layout.ty.builtin_deref(true, ty::NoPreference)
.unwrap_or_else(|| bug!("deref of non-pointer {:?}", self)).ty;
let (llptr, llextra) = match self.val {

View File

@ -16,7 +16,7 @@ use rustc::mir::tcx::PlaceTy;
use rustc_data_structures::indexed_vec::Idx;
use base;
use builder::Builder;
use common::{CrateContext, C_usize, C_u8, C_u32, C_uint, C_int, C_null, C_uint_big};
use common::{CodegenCx, C_usize, C_u8, C_u32, C_uint, C_int, C_null, C_uint_big};
use consts;
use type_of::LayoutLlvmExt;
use type_::Type;
@ -63,7 +63,7 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
Self::new_sized(tmp, layout, layout.align)
}
pub fn len(&self, ccx: &CrateContext<'a, 'tcx>) -> ValueRef {
pub fn len(&self, ccx: &CodegenCx<'a, 'tcx>) -> ValueRef {
if let layout::FieldPlacement::Array { count, .. } = self.layout.fields {
if self.layout.is_unsized() {
assert!(self.has_extra());

View File

@ -18,7 +18,7 @@ use asm;
use attributes;
use base;
use consts;
use context::CrateContext;
use context::CodegenCx;
use declare;
use llvm;
use monomorphize::Instance;
@ -38,7 +38,7 @@ pub use rustc_mir::monomorphize::item::*;
pub use rustc_mir::monomorphize::item::MonoItemExt as BaseMonoItemExt;
pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> {
fn define(&self, ccx: &CrateContext<'a, 'tcx>) {
fn define(&self, ccx: &CodegenCx<'a, 'tcx>) {
debug!("BEGIN IMPLEMENTING '{} ({})' in cgu {}",
self.to_string(ccx.tcx),
self.to_raw_string(),
@ -79,7 +79,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> {
}
fn predefine(&self,
ccx: &CrateContext<'a, 'tcx>,
ccx: &CodegenCx<'a, 'tcx>,
linkage: Linkage,
visibility: Visibility) {
debug!("BEGIN PREDEFINING '{} ({})' in cgu {}",
@ -138,7 +138,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> {
impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {}
fn predefine_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn predefine_static<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
node_id: ast::NodeId,
linkage: Linkage,
visibility: Visibility,
@ -162,7 +162,7 @@ fn predefine_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ccx.statics.borrow_mut().insert(g, def_id);
}
fn predefine_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn predefine_fn<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
instance: Instance<'tcx>,
linkage: Linkage,
visibility: Visibility,

View File

@ -14,7 +14,7 @@ use llvm;
use llvm::{ContextRef, TypeRef, Bool, False, True, TypeKind};
use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};
use context::CrateContext;
use context::CodegenCx;
use syntax::ast;
use rustc::ty::layout::{self, Align, Size};
@ -62,19 +62,19 @@ impl Type {
unsafe { mem::transmute(slice) }
}
pub fn void(ccx: &CrateContext) -> Type {
pub fn void(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMVoidTypeInContext(ccx.llcx))
}
pub fn metadata(ccx: &CrateContext) -> Type {
pub fn metadata(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMRustMetadataTypeInContext(ccx.llcx))
}
pub fn i1(ccx: &CrateContext) -> Type {
pub fn i1(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMInt1TypeInContext(ccx.llcx))
}
pub fn i8(ccx: &CrateContext) -> Type {
pub fn i8(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMInt8TypeInContext(ccx.llcx))
}
@ -82,44 +82,44 @@ impl Type {
ty!(llvm::LLVMInt8TypeInContext(llcx))
}
pub fn i16(ccx: &CrateContext) -> Type {
pub fn i16(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMInt16TypeInContext(ccx.llcx))
}
pub fn i32(ccx: &CrateContext) -> Type {
pub fn i32(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMInt32TypeInContext(ccx.llcx))
}
pub fn i64(ccx: &CrateContext) -> Type {
pub fn i64(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMInt64TypeInContext(ccx.llcx))
}
pub fn i128(ccx: &CrateContext) -> Type {
pub fn i128(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMIntTypeInContext(ccx.llcx, 128))
}
// Creates an integer type with the given number of bits, e.g. i24
pub fn ix(ccx: &CrateContext, num_bits: u64) -> Type {
pub fn ix(ccx: &CodegenCx, num_bits: u64) -> Type {
ty!(llvm::LLVMIntTypeInContext(ccx.llcx, num_bits as c_uint))
}
pub fn f32(ccx: &CrateContext) -> Type {
pub fn f32(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMFloatTypeInContext(ccx.llcx))
}
pub fn f64(ccx: &CrateContext) -> Type {
pub fn f64(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMDoubleTypeInContext(ccx.llcx))
}
pub fn bool(ccx: &CrateContext) -> Type {
pub fn bool(ccx: &CodegenCx) -> Type {
Type::i8(ccx)
}
pub fn char(ccx: &CrateContext) -> Type {
pub fn char(ccx: &CodegenCx) -> Type {
Type::i32(ccx)
}
pub fn i8p(ccx: &CrateContext) -> Type {
pub fn i8p(ccx: &CodegenCx) -> Type {
Type::i8(ccx).ptr_to()
}
@ -127,7 +127,7 @@ impl Type {
Type::i8_llcx(llcx).ptr_to()
}
pub fn isize(ccx: &CrateContext) -> Type {
pub fn isize(ccx: &CodegenCx) -> Type {
match &ccx.tcx.sess.target.target.target_pointer_width[..] {
"16" => Type::i16(ccx),
"32" => Type::i32(ccx),
@ -136,7 +136,7 @@ impl Type {
}
}
pub fn c_int(ccx: &CrateContext) -> Type {
pub fn c_int(ccx: &CodegenCx) -> Type {
match &ccx.tcx.sess.target.target.target_c_int_width[..] {
"16" => Type::i16(ccx),
"32" => Type::i32(ccx),
@ -145,7 +145,7 @@ impl Type {
}
}
pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
pub fn int_from_ty(ccx: &CodegenCx, t: ast::IntTy) -> Type {
match t {
ast::IntTy::Isize => ccx.isize_ty,
ast::IntTy::I8 => Type::i8(ccx),
@ -156,7 +156,7 @@ impl Type {
}
}
pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
pub fn uint_from_ty(ccx: &CodegenCx, t: ast::UintTy) -> Type {
match t {
ast::UintTy::Usize => ccx.isize_ty,
ast::UintTy::U8 => Type::i8(ccx),
@ -167,7 +167,7 @@ impl Type {
}
}
pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type {
pub fn float_from_ty(ccx: &CodegenCx, t: ast::FloatTy) -> Type {
match t {
ast::FloatTy::F32 => Type::f32(ccx),
ast::FloatTy::F64 => Type::f64(ccx),
@ -186,14 +186,14 @@ impl Type {
args.len() as c_uint, True))
}
pub fn struct_(ccx: &CrateContext, els: &[Type], packed: bool) -> Type {
pub fn struct_(ccx: &CodegenCx, els: &[Type], packed: bool) -> Type {
let els: &[TypeRef] = Type::to_ref_slice(els);
ty!(llvm::LLVMStructTypeInContext(ccx.llcx, els.as_ptr(),
els.len() as c_uint,
packed as Bool))
}
pub fn named_struct(ccx: &CrateContext, name: &str) -> Type {
pub fn named_struct(ccx: &CodegenCx, name: &str) -> Type {
let name = CString::new(name).unwrap();
ty!(llvm::LLVMStructCreateNamed(ccx.llcx, name.as_ptr()))
}
@ -265,7 +265,7 @@ impl Type {
}
}
pub fn from_integer(cx: &CrateContext, i: layout::Integer) -> Type {
pub fn from_integer(cx: &CodegenCx, i: layout::Integer) -> Type {
use rustc::ty::layout::Integer::*;
match i {
I8 => Type::i8(cx),
@ -278,7 +278,7 @@ impl Type {
/// Return a LLVM type that has at most the required alignment,
/// as a conservative approximation for unknown pointee types.
pub fn pointee_for_abi_align(ccx: &CrateContext, align: Align) -> Type {
pub fn pointee_for_abi_align(ccx: &CodegenCx, align: Align) -> Type {
// FIXME(eddyb) We could find a better approximation if ity.align < align.
let ity = layout::Integer::approximate_abi_align(ccx, align);
Type::from_integer(ccx, ity)
@ -286,7 +286,7 @@ impl Type {
/// Return a LLVM type that has at most the required alignment,
/// and exactly the required size, as a best-effort padding array.
pub fn padding_filler(ccx: &CrateContext, size: Size, align: Align) -> Type {
pub fn padding_filler(ccx: &CodegenCx, size: Size, align: Align) -> Type {
let unit = layout::Integer::approximate_abi_align(ccx, align);
let size = size.bytes();
let unit_size = unit.size().bytes();
@ -294,7 +294,7 @@ impl Type {
Type::array(&Type::from_integer(ccx, unit), size / unit_size)
}
pub fn x86_mmx(ccx: &CrateContext) -> Type {
pub fn x86_mmx(ccx: &CodegenCx) -> Type {
ty!(llvm::LLVMX86MMXTypeInContext(ccx.llcx))
}
}

View File

@ -19,7 +19,7 @@ use type_::Type;
use std::fmt::Write;
fn uncached_llvm_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn uncached_llvm_type<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>,
defer: &mut Option<(Type, TyLayout<'tcx>)>)
-> Type {
@ -110,7 +110,7 @@ fn uncached_llvm_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn struct_llfields<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn struct_llfields<'a, 'tcx>(ccx: &CodegenCx<'a, 'tcx>,
layout: TyLayout<'tcx>)
-> (Vec<Type>, bool) {
debug!("struct_llfields: {:#?}", layout);
@ -158,7 +158,7 @@ fn struct_llfields<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
(result, packed)
}
impl<'a, 'tcx> CrateContext<'a, 'tcx> {
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
pub fn align_of(&self, ty: Ty<'tcx>) -> Align {
self.layout_of(ty).align
}
@ -197,14 +197,14 @@ pub struct PointeeInfo {
pub trait LayoutLlvmExt<'tcx> {
fn is_llvm_immediate(&self) -> bool;
fn is_llvm_scalar_pair<'a>(&self) -> bool;
fn llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type;
fn immediate_llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type;
fn scalar_llvm_type_at<'a>(&self, ccx: &CrateContext<'a, 'tcx>,
fn llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type;
fn immediate_llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type;
fn scalar_llvm_type_at<'a>(&self, ccx: &CodegenCx<'a, 'tcx>,
scalar: &layout::Scalar, offset: Size) -> Type;
fn scalar_pair_element_llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>,
fn scalar_pair_element_llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>,
index: usize) -> Type;
fn llvm_field_index(&self, index: usize) -> u64;
fn pointee_info_at<'a>(&self, ccx: &CrateContext<'a, 'tcx>, offset: Size)
fn pointee_info_at<'a>(&self, ccx: &CodegenCx<'a, 'tcx>, offset: Size)
-> Option<PointeeInfo>;
}
@ -240,7 +240,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
/// with the inner-most trailing unsized field using the "minimal unit"
/// of that field's type - this is useful for taking the address of
/// that field and ensuring the struct has the right alignment.
fn llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
fn llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
if let layout::Abi::Scalar(ref scalar) = self.abi {
// Use a different cache for scalars because pointers to DSTs
// can be either fat or thin (data pointers of fat pointers).
@ -305,7 +305,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
llty
}
fn immediate_llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
fn immediate_llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>) -> Type {
if let layout::Abi::Scalar(ref scalar) = self.abi {
if scalar.is_bool() {
return Type::i1(ccx);
@ -314,7 +314,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
self.llvm_type(ccx)
}
fn scalar_llvm_type_at<'a>(&self, ccx: &CrateContext<'a, 'tcx>,
fn scalar_llvm_type_at<'a>(&self, ccx: &CodegenCx<'a, 'tcx>,
scalar: &layout::Scalar, offset: Size) -> Type {
match scalar.value {
layout::Int(i, _) => Type::from_integer(ccx, i),
@ -332,7 +332,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
}
}
fn scalar_pair_element_llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>,
fn scalar_pair_element_llvm_type<'a>(&self, ccx: &CodegenCx<'a, 'tcx>,
index: usize) -> Type {
// HACK(eddyb) special-case fat pointers until LLVM removes
// pointee types, to avoid bitcasting every `OperandRef::deref`.
@ -396,7 +396,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
}
}
fn pointee_info_at<'a>(&self, ccx: &CrateContext<'a, 'tcx>, offset: Size)
fn pointee_info_at<'a>(&self, ccx: &CodegenCx<'a, 'tcx>, offset: Size)
-> Option<PointeeInfo> {
if let Some(&pointee) = ccx.pointee_infos.borrow().get(&(self.ty, offset)) {
return pointee;