use rustc::traits;
use debuginfo;
use callee;
+use back::symbol_export::ExportedSymbols;
use base;
use declare;
use monomorphize::Instance;
use partitioning::CodegenUnit;
+use trans_item::TransItem;
use type_::Type;
use rustc_data_structures::base_n;
-use rustc::session::config::{self, NoDebugInfo};
+use rustc::session::config::{self, NoDebugInfo, OutputFilenames};
use rustc::session::Session;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
-use rustc::util::nodemap::{NodeSet, DefIdMap, FxHashMap};
+use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
use std::ffi::{CStr, CString};
use std::cell::{Cell, RefCell};
use std::ptr;
use std::iter;
use std::str;
+use std::sync::Arc;
use std::marker::PhantomData;
use syntax::ast;
use syntax::symbol::InternedString;
/// crate, so it must not contain references to any LLVM data structures
/// (aside from metadata-related ones).
pub struct SharedCrateContext<'a, 'tcx: 'a> {
- exported_symbols: NodeSet,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
check_overflow: bool,
use_dll_storage_attrs: bool,
+
+ output_filenames: &'a OutputFilenames,
}
/// The local portion of a `CrateContext`. There is one `LocalCrateContext`
llcx: ContextRef,
stats: Stats,
codegen_unit: CodegenUnit<'tcx>,
+
+ /// The translation items of the whole crate.
+ crate_trans_items: Arc<FxHashSet<TransItem<'tcx>>>,
+
+ /// Information about which symbols are exported from the crate.
+ exported_symbols: Arc<ExportedSymbols>,
+
/// Cache instances of monomorphic and polymorphic items
instances: RefCell<FxHashMap<Instance<'tcx>, ValueRef>>,
/// Cache generated vtables
impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
pub fn new(tcx: TyCtxt<'b, 'tcx, 'tcx>,
- exported_symbols: NodeSet,
- check_overflow: bool)
+ check_overflow: bool,
+ output_filenames: &'b OutputFilenames)
-> SharedCrateContext<'b, 'tcx> {
// An interesting part of Windows which MSVC forces our hand on (and
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
let use_dll_storage_attrs = tcx.sess.target.target.options.is_like_msvc;
SharedCrateContext {
- exported_symbols: exported_symbols,
- tcx: tcx,
- check_overflow: check_overflow,
- use_dll_storage_attrs: use_dll_storage_attrs,
+ tcx,
+ check_overflow,
+ use_dll_storage_attrs,
+ output_filenames,
}
}
ty.is_freeze(self.tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP)
}
- pub fn exported_symbols<'a>(&'a self) -> &'a NodeSet {
- &self.exported_symbols
- }
-
pub fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {
self.tcx
}
pub fn use_dll_storage_attrs(&self) -> bool {
self.use_dll_storage_attrs
}
+
+ pub fn output_filenames(&self) -> &OutputFilenames {
+ self.output_filenames
+ }
}
impl<'a, 'tcx> LocalCrateContext<'a, 'tcx> {
pub fn new(shared: &SharedCrateContext<'a, 'tcx>,
- codegen_unit: CodegenUnit<'tcx>)
+ codegen_unit: CodegenUnit<'tcx>,
+ crate_trans_items: Arc<FxHashSet<TransItem<'tcx>>>,
+ exported_symbols: Arc<ExportedSymbols>,)
-> LocalCrateContext<'a, 'tcx> {
unsafe {
// Append ".rs" to LLVM module identifier.
};
let local_ccx = LocalCrateContext {
- llmod: llmod,
- llcx: llcx,
+ llmod,
+ llcx,
stats: Stats::default(),
- codegen_unit: codegen_unit,
+ codegen_unit,
+ crate_trans_items,
+ exported_symbols,
instances: RefCell::new(FxHashMap()),
vtables: RefCell::new(FxHashMap()),
const_cstr_cache: RefCell::new(FxHashMap()),
int_type: Type::from_ref(ptr::null_mut()),
opaque_vec_type: Type::from_ref(ptr::null_mut()),
str_slice_type: Type::from_ref(ptr::null_mut()),
- dbg_cx: dbg_cx,
+ dbg_cx,
eh_personality: Cell::new(None),
eh_unwind_resume: Cell::new(None),
rust_try_fn: Cell::new(None),
-> CrateContext<'a, 'tcx> {
assert!(local_ccxs.len() == 1);
CrateContext {
- shared: shared,
+ shared,
local_ccx: &local_ccxs[0]
}
}
&self.local().codegen_unit
}
+ pub fn crate_trans_items(&self) -> &FxHashSet<TransItem<'tcx>> {
+ &self.local().crate_trans_items
+ }
+
+ pub fn exported_symbols(&self) -> &ExportedSymbols {
+ &self.local().exported_symbols
+ }
+
pub fn td(&self) -> llvm::TargetDataRef {
unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
}