diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-08-21 10:41:56 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-08-21 10:41:56 -0700 |
| commit | b31998ec93c1738642fd1557b419fa651bb6b543 (patch) | |
| tree | c9461144895ec8d0f937fd16b7f5fbf2942e6706 /src/librustc_trans | |
| parent | bf3ebcc98788d805f96b171362d272c93e0a50a0 (diff) | |
| parent | 757b7ac2abd69d97ba196b76f0bbf78c377aaea9 (diff) | |
| download | rust-b31998ec93c1738642fd1557b419fa651bb6b543.tar.gz rust-b31998ec93c1738642fd1557b419fa651bb6b543.zip | |
Merge remote-tracking branch 'origin/master' into gen
Diffstat (limited to 'src/librustc_trans')
| -rw-r--r-- | src/librustc_trans/back/archive.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/back/link.rs | 8 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 7 | ||||
| -rw-r--r-- | src/librustc_trans/context.rs | 70 | ||||
| -rw-r--r-- | src/librustc_trans/lib.rs | 20 | ||||
| -rw-r--r-- | src/librustc_trans/type_.rs | 32 |
6 files changed, 10 insertions, 131 deletions
diff --git a/src/librustc_trans/back/archive.rs b/src/librustc_trans/back/archive.rs index 31dee241de4..0d39db9e10a 100644 --- a/src/librustc_trans/back/archive.rs +++ b/src/librustc_trans/back/archive.rs @@ -10,7 +10,7 @@ //! A helper class for dealing with static archives -use std::ffi::{CString, CStr, OsString}; +use std::ffi::{CString, CStr}; use std::io; use std::mem; use std::path::{Path, PathBuf}; @@ -28,8 +28,6 @@ pub struct ArchiveConfig<'a> { pub dst: PathBuf, pub src: Option<PathBuf>, pub lib_search_paths: Vec<PathBuf>, - pub ar_prog: String, - pub command_path: OsString, } /// Helper for adding many files to an archive with a single invocation of diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index d2c96a877fd..338f3bb08aa 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -138,12 +138,6 @@ pub fn msvc_link_exe_cmd(_sess: &Session) -> (Command, Vec<(OsString, OsString)> (Command::new("link.exe"), vec![]) } -pub fn get_ar_prog(sess: &Session) -> String { - sess.opts.cg.ar.clone().unwrap_or_else(|| { - sess.target.target.options.ar.clone() - }) -} - fn command_path(sess: &Session) -> OsString { // The compiler's sysroot often has some bundled tools, so add it to the // PATH for the child. @@ -383,8 +377,6 @@ fn archive_config<'a>(sess: &'a Session, dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), - ar_prog: get_ar_prog(sess), - command_path: command_path(sess), } } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 8ed9daed49b..3f9b28d3d61 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -785,8 +785,6 @@ pub fn start_async_translation(sess: &Session, crate_name, link, metadata, - exported_symbols, - no_builtins, windows_subsystem, linker_info, no_integrated_as, @@ -1801,8 +1799,6 @@ pub struct OngoingCrateTranslation { crate_name: Symbol, link: LinkMeta, metadata: EncodedMetadata, - exported_symbols: Arc<ExportedSymbols>, - no_builtins: bool, windows_subsystem: Option<String>, linker_info: LinkerInfo, no_integrated_as: bool, @@ -1852,13 +1848,10 @@ impl OngoingCrateTranslation { crate_name: self.crate_name, link: self.link, metadata: self.metadata, - exported_symbols: self.exported_symbols, - no_builtins: self.no_builtins, windows_subsystem: self.windows_subsystem, linker_info: self.linker_info, modules: compiled_modules.modules, - metadata_module: compiled_modules.metadata_module, allocator_module: compiled_modules.allocator_module, }; diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 8c6bd302e4b..f2b07cf6a58 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -27,10 +27,9 @@ use type_::Type; use rustc_data_structures::base_n; 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::{DefIdMap, FxHashMap, FxHashSet}; +use rustc::util::nodemap::{FxHashMap, FxHashSet}; use std::ffi::{CStr, CString}; use std::cell::{Cell, RefCell}; @@ -39,7 +38,6 @@ use std::iter; use std::str; use std::sync::Arc; use std::marker::PhantomData; -use syntax::ast; use syntax::symbol::InternedString; use syntax_pos::DUMMY_SP; use abi::Abi; @@ -124,12 +122,6 @@ pub struct LocalCrateContext<'a, 'tcx: 'a> { /// Cache of emitted const globals (value -> global) const_globals: RefCell<FxHashMap<ValueRef, ValueRef>>, - /// Cache of emitted const values - const_values: RefCell<FxHashMap<(ast::NodeId, &'tcx Substs<'tcx>), ValueRef>>, - - /// Cache of external const values - extern_const_values: RefCell<DefIdMap<ValueRef>>, - /// Mapping from static definitions to their DefId's. statics: RefCell<FxHashMap<ValueRef, DefId>>, @@ -144,7 +136,6 @@ pub struct LocalCrateContext<'a, 'tcx: 'a> { used_statics: RefCell<Vec<ValueRef>>, lltypes: RefCell<FxHashMap<Ty<'tcx>, Type>>, - type_hashcodes: RefCell<FxHashMap<Ty<'tcx>, String>>, int_type: Type, opaque_vec_type: Type, str_slice_type: Type, @@ -157,9 +148,6 @@ pub struct LocalCrateContext<'a, 'tcx: 'a> { intrinsics: RefCell<FxHashMap<&'static str, ValueRef>>, - /// Depth of the current type-of computation - used to bail out - type_of_depth: Cell<usize>, - /// A counter that is used for generating local symbol names local_gen_sym_counter: Cell<usize>, @@ -406,13 +394,10 @@ impl<'a, 'tcx> LocalCrateContext<'a, 'tcx> { const_cstr_cache: RefCell::new(FxHashMap()), const_unsized: RefCell::new(FxHashMap()), const_globals: RefCell::new(FxHashMap()), - const_values: RefCell::new(FxHashMap()), - extern_const_values: RefCell::new(DefIdMap()), statics: RefCell::new(FxHashMap()), statics_to_rauw: RefCell::new(Vec::new()), used_statics: RefCell::new(Vec::new()), lltypes: RefCell::new(FxHashMap()), - type_hashcodes: 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()), @@ -421,7 +406,6 @@ impl<'a, 'tcx> LocalCrateContext<'a, 'tcx> { eh_unwind_resume: Cell::new(None), rust_try_fn: Cell::new(None), intrinsics: RefCell::new(FxHashMap()), - type_of_depth: Cell::new(0), local_gen_sym_counter: Cell::new(0), placeholder: PhantomData, }; @@ -545,15 +529,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.local().const_globals } - pub fn const_values<'a>(&'a self) -> &'a RefCell<FxHashMap<(ast::NodeId, &'tcx Substs<'tcx>), - ValueRef>> { - &self.local().const_values - } - - pub fn extern_const_values<'a>(&'a self) -> &'a RefCell<DefIdMap<ValueRef>> { - &self.local().extern_const_values - } - pub fn statics<'a>(&'a self) -> &'a RefCell<FxHashMap<ValueRef, DefId>> { &self.local().statics } @@ -570,10 +545,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.local().lltypes } - pub fn type_hashcodes<'a>(&'a self) -> &'a RefCell<FxHashMap<Ty<'tcx>, String>> { - &self.local().type_hashcodes - } - pub fn stats<'a>(&'a self) -> &'a Stats { &self.local().stats } @@ -582,10 +553,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { self.local().int_type } - pub fn opaque_vec_type(&self) -> Type { - self.local().opaque_vec_type - } - pub fn str_slice_type(&self) -> Type { self.local().str_slice_type } @@ -602,27 +569,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.local().intrinsics } - pub fn obj_size_bound(&self) -> u64 { - self.tcx().data_layout.obj_size_bound() - } - - pub fn report_overbig_object(&self, obj: Ty<'tcx>) -> ! { - self.sess().fatal( - &format!("the type `{:?}` is too big for the current architecture", - obj)) - } - - pub fn enter_type_of(&self, ty: Ty<'tcx>) -> TypeOfDepthLock<'b, 'tcx> { - let current_depth = self.local().type_of_depth.get(); - debug!("enter_type_of({:?}) at depth {:?}", ty, current_depth); - if current_depth > self.sess().recursion_limit.get() { - self.sess().fatal( - &format!("overflow representing the type `{}`", ty)) - } - self.local().type_of_depth.set(current_depth + 1); - TypeOfDepthLock(self.local()) - } - pub fn check_overflow(&self) -> bool { self.shared.check_overflow } @@ -631,12 +577,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { self.shared.use_dll_storage_attrs() } - /// Given the def-id of some item that has no type parameters, make - /// a suitable "empty substs" for it. - pub fn empty_substs_for_def_id(&self, item_def_id: DefId) -> &'tcx Substs<'tcx> { - self.tcx().empty_substs_for_def_id(item_def_id) - } - /// Generate a new symbol name with the given prefix. This symbol name must /// only be used for definitions with `internal` or `private` linkage. pub fn generate_local_symbol_name(&self, prefix: &str) -> String { @@ -776,14 +716,6 @@ impl<'a, 'tcx> LayoutTyper<'tcx> for &'a CrateContext<'a, 'tcx> { } } -pub struct TypeOfDepthLock<'a, 'tcx: 'a>(&'a LocalCrateContext<'a, 'tcx>); - -impl<'a, 'tcx> Drop for TypeOfDepthLock<'a, 'tcx> { - fn drop(&mut self) { - self.0.type_of_depth.set(self.0.type_of_depth.get() - 1); - } -} - /// Declare any llvm intrinsics that you might need fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> { macro_rules! ifn { diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 5a4a5b95cf9..6da42caf75b 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -36,7 +36,6 @@ use rustc::dep_graph::WorkProduct; use syntax_pos::symbol::Symbol; -use std::sync::Arc; extern crate flate2; extern crate libc; @@ -46,7 +45,7 @@ extern crate rustc_allocator; extern crate rustc_back; extern crate rustc_data_structures; extern crate rustc_incremental; -pub extern crate rustc_llvm as llvm; +extern crate rustc_llvm as llvm; extern crate rustc_platform_intrinsics as intrinsics; extern crate rustc_const_math; #[macro_use] @@ -78,7 +77,7 @@ pub mod back { pub(crate) mod symbol_export; pub(crate) mod symbol_names; pub mod write; - pub mod rpath; + mod rpath; } mod diagnostics; @@ -138,8 +137,8 @@ pub struct ModuleTranslation { /// unique amongst **all** crates. Therefore, it should contain /// something unique to this crate (e.g., a module path) as well /// as the crate name and disambiguator. - pub name: String, - pub symbol_name_hash: u64, + name: String, + symbol_name_hash: u64, pub source: ModuleSource, pub kind: ModuleKind, } @@ -206,7 +205,7 @@ pub enum ModuleSource { #[derive(Copy, Clone, Debug)] pub struct ModuleLlvm { - pub llcx: llvm::ContextRef, + llcx: llvm::ContextRef, pub llmod: llvm::ModuleRef, } @@ -216,14 +215,11 @@ unsafe impl Sync for ModuleTranslation { } pub struct CrateTranslation { pub crate_name: Symbol, pub modules: Vec<CompiledModule>, - pub metadata_module: CompiledModule, - pub allocator_module: Option<CompiledModule>, + allocator_module: Option<CompiledModule>, pub link: rustc::middle::cstore::LinkMeta, pub metadata: rustc::middle::cstore::EncodedMetadata, - pub exported_symbols: Arc<back::symbol_export::ExportedSymbols>, - pub no_builtins: bool, - pub windows_subsystem: Option<String>, - pub linker_info: back::linker::LinkerInfo + windows_subsystem: Option<String>, + linker_info: back::linker::LinkerInfo } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/librustc_trans/type_.rs b/src/librustc_trans/type_.rs index d70afc0cce5..b8a8068d36a 100644 --- a/src/librustc_trans/type_.rs +++ b/src/librustc_trans/type_.rs @@ -237,19 +237,6 @@ impl Type { ty!(llvm::LLVMPointerType(self.to_ref(), 0)) } - pub fn is_aggregate(&self) -> bool { - match self.kind() { - TypeKind::Struct | TypeKind::Array => true, - _ => false - } - } - - pub fn is_packed(&self) -> bool { - unsafe { - llvm::LLVMIsPackedStruct(self.to_ref()) == True - } - } - pub fn element_type(&self) -> Type { unsafe { Type::from_ref(llvm::LLVMGetElementType(self.to_ref())) @@ -263,12 +250,6 @@ impl Type { } } - pub fn array_length(&self) -> usize { - unsafe { - llvm::LLVMGetArrayLength(self.to_ref()) as usize - } - } - pub fn field_types(&self) -> Vec<Type> { unsafe { let n_elts = llvm::LLVMCountStructElementTypes(self.to_ref()) as usize; @@ -282,10 +263,6 @@ impl Type { } } - pub fn return_type(&self) -> Type { - ty!(llvm::LLVMGetReturnType(self.to_ref())) - } - pub fn func_params(&self) -> Vec<Type> { unsafe { let n_args = llvm::LLVMCountParamTypes(self.to_ref()) as usize; @@ -324,13 +301,4 @@ impl Type { I128 => Type::i128(cx), } } - - pub fn from_primitive(ccx: &CrateContext, p: layout::Primitive) -> Type { - match p { - layout::Int(i) => Type::from_integer(ccx, i), - layout::F32 => Type::f32(ccx), - layout::F64 => Type::f64(ccx), - layout::Pointer => bug!("It is not possible to convert Pointer directly to Type.") - } - } } |
