From dc6e414e6f85293aceca3357e2466bcc4bcf425c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 15 Nov 2014 20:30:33 -0500 Subject: [PATCH] Move trans, back, driver, and back into a new crate, rustc_trans. Reduces memory usage significantly and opens opportunities for more parallel compilation. --- mk/crates.mk | 11 +-- src/driver/driver.rs | 2 +- src/librustc/README.txt | 85 ++++++++++++------ src/librustc/lib.rs | 15 +--- src/librustc/lint/context.rs | 3 +- src/librustc/metadata/creader.rs | 9 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/metadata/loader.rs | 2 +- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/check_loop.rs | 2 +- src/librustc/middle/check_static_recursion.rs | 2 +- src/librustc/middle/dependency_format.rs | 4 +- src/librustc/middle/entry.rs | 3 +- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/ty.rs | 2 +- src/librustc/middle/typeck/check/mod.rs | 2 +- src/librustc/middle/typeck/infer/mod.rs | 11 ++- src/librustc/middle/typeck/mod.rs | 3 +- src/librustc/middle/weak_lang_items.rs | 4 +- src/librustc/plugin/load.rs | 2 +- src/librustc/{driver => session}/config.rs | 51 +++++++---- .../{driver/session.rs => session/mod.rs} | 20 ++++- src/librustc_trans/README.txt | 1 + src/{librustc => librustc_trans}/back/link.rs | 12 +-- src/{librustc => librustc_trans}/back/lto.rs | 7 +- .../back/write.rs | 69 +++++++-------- .../driver/driver.rs | 45 ++++------ .../driver/mod.rs | 24 ++--- .../driver/pretty.rs | 3 +- src/librustc_trans/lib.rs | 87 +++++++++++++++++++ .../middle => librustc_trans}/save/mod.rs | 8 +- .../save/recorder.rs | 4 +- .../save/span_utils.rs | 4 +- .../typeck/infer => librustc_trans}/test.rs | 11 +-- .../middle => librustc_trans}/trans/_match.rs | 30 +++---- .../middle => librustc_trans}/trans/adt.rs | 18 ++-- .../middle => librustc_trans}/trans/asm.rs | 16 ++-- .../middle => librustc_trans}/trans/base.rs | 75 ++++++++-------- .../trans/basic_block.rs | 2 +- .../middle => librustc_trans}/trans/build.rs | 6 +- .../trans/builder.rs | 8 +- .../middle => librustc_trans}/trans/cabi.rs | 14 +-- .../trans/cabi_arm.rs | 6 +- .../trans/cabi_mips.rs | 6 +- .../trans/cabi_x86.rs | 4 +- .../trans/cabi_x86_64.rs | 6 +- .../trans/cabi_x86_win64.rs | 4 +- .../middle => librustc_trans}/trans/callee.rs | 42 ++++----- .../trans/cleanup.rs | 16 ++-- .../trans/closure.rs | 24 ++--- .../middle => librustc_trans}/trans/common.rs | 28 +++--- .../middle => librustc_trans}/trans/consts.rs | 24 ++--- .../trans/context.rs | 18 ++-- .../trans/controlflow.rs | 32 +++---- .../middle => librustc_trans}/trans/datum.rs | 16 ++-- .../trans/debuginfo.rs | 17 ++-- .../middle => librustc_trans}/trans/doc.rs | 0 .../middle => librustc_trans}/trans/expr.rs | 46 +++++----- .../trans/foreign.rs | 18 ++-- .../middle => librustc_trans}/trans/glue.rs | 28 +++--- .../middle => librustc_trans}/trans/inline.rs | 4 +- .../trans/intrinsic.rs | 28 +++--- .../middle => librustc_trans}/trans/llrepr.rs | 4 +- .../trans/machine.rs | 4 +- .../middle => librustc_trans}/trans/macros.rs | 0 .../middle => librustc_trans}/trans/meth.rs | 26 +++--- .../middle => librustc_trans}/trans/mod.rs | 0 .../trans/monomorphize.rs | 14 +-- .../middle => librustc_trans}/trans/tvec.rs | 28 +++--- .../middle => librustc_trans}/trans/type_.rs | 2 +- .../trans/type_of.rs | 10 +-- .../middle => librustc_trans}/trans/value.rs | 4 +- src/librustdoc/clean/mod.rs | 4 +- src/librustdoc/core.rs | 7 +- src/librustdoc/lib.rs | 3 +- src/librustdoc/test.rs | 8 +- 80 files changed, 640 insertions(+), 532 deletions(-) rename src/librustc/{driver => session}/config.rs (96%) rename src/librustc/{driver/session.rs => session/mod.rs} (95%) create mode 100644 src/librustc_trans/README.txt rename src/{librustc => librustc_trans}/back/link.rs (99%) rename src/{librustc => librustc_trans}/back/lto.rs (98%) rename src/{librustc => librustc_trans}/back/write.rs (95%) rename src/{librustc => librustc_trans}/driver/driver.rs (95%) rename src/{librustc => librustc_trans}/driver/mod.rs (96%) rename src/{librustc => librustc_trans}/driver/pretty.rs (99%) create mode 100644 src/librustc_trans/lib.rs rename src/{librustc/middle => librustc_trans}/save/mod.rs (99%) rename src/{librustc/middle => librustc_trans}/save/recorder.rs (99%) rename src/{librustc/middle => librustc_trans}/save/span_utils.rs (99%) rename src/{librustc/middle/typeck/infer => librustc_trans}/test.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/_match.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/adt.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/asm.rs (95%) rename src/{librustc/middle => librustc_trans}/trans/base.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/basic_block.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/build.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/builder.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/cabi.rs (93%) rename src/{librustc/middle => librustc_trans}/trans/cabi_arm.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/cabi_mips.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/cabi_x86.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/cabi_x86_64.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/cabi_x86_win64.rs (96%) rename src/{librustc/middle => librustc_trans}/trans/callee.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/cleanup.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/closure.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/common.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/consts.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/context.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/controlflow.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/datum.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/debuginfo.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/doc.rs (100%) rename src/{librustc/middle => librustc_trans}/trans/expr.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/foreign.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/glue.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/inline.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/intrinsic.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/llrepr.rs (93%) rename src/{librustc/middle => librustc_trans}/trans/machine.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/macros.rs (100%) rename src/{librustc/middle => librustc_trans}/trans/meth.rs (98%) rename src/{librustc/middle => librustc_trans}/trans/mod.rs (100%) rename src/{librustc/middle => librustc_trans}/trans/monomorphize.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/tvec.rs (97%) rename src/{librustc/middle => librustc_trans}/trans/type_.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/type_of.rs (99%) rename src/{librustc/middle => librustc_trans}/trans/value.rs (98%) diff --git a/mk/crates.mk b/mk/crates.mk index 771c1821e38..1a9d1e82467 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -53,7 +53,7 @@ TARGET_CRATES := libc std green native flate arena term \ serialize sync getopts collections test time rand \ log regex graphviz core rbml alloc rustrt \ unicode -HOST_CRATES := syntax rustc rustdoc regex_macros fmt_macros \ +HOST_CRATES := syntax rustc rustc_trans rustdoc regex_macros fmt_macros \ rustc_llvm rustc_back CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc @@ -69,11 +69,12 @@ DEPS_graphviz := std DEPS_green := std native:context_switch DEPS_native := std DEPS_syntax := std term serialize log fmt_macros arena libc +DEPS_rustc_trans := rustc rustc_back rustc_llvm libc DEPS_rustc := syntax flate arena serialize getopts rbml \ time log graphviz rustc_llvm rustc_back DEPS_rustc_llvm := native:rustllvm libc std DEPS_rustc_back := std syntax rustc_llvm flate log libc -DEPS_rustdoc := rustc native:hoedown serialize getopts \ +DEPS_rustdoc := rustc rustc_trans native:hoedown serialize getopts \ test time DEPS_flate := std native:miniz DEPS_arena := std @@ -96,7 +97,7 @@ DEPS_fmt_macros = std TOOL_DEPS_compiletest := test getopts native TOOL_DEPS_rustdoc := rustdoc native -TOOL_DEPS_rustc := rustc native +TOOL_DEPS_rustc := rustc_trans native TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs TOOL_SOURCE_rustc := $(S)src/driver/driver.rs @@ -112,8 +113,8 @@ ONLY_RLIB_unicode := 1 # You should not need to edit below this line ################################################################################ -DOC_CRATES := $(filter-out rustc, $(filter-out syntax, $(CRATES))) -COMPILER_DOC_CRATES := rustc syntax +DOC_CRATES := $(filter-out rustc, $(filter-out rustc_trans, $(filter-out syntax, $(CRATES)))) +COMPILER_DOC_CRATES := rustc rustc_trans syntax # This macro creates some simple definitions for each crate being built, just # some munging of all of the parameters above. diff --git a/src/driver/driver.rs b/src/driver/driver.rs index 8ac09ed909b..632d21d7b9c 100644 --- a/src/driver/driver.rs +++ b/src/driver/driver.rs @@ -12,6 +12,6 @@ extern crate "rustdoc" as this; #[cfg(rustc)] -extern crate "rustc" as this; +extern crate "rustc_trans" as this; fn main() { this::main() } diff --git a/src/librustc/README.txt b/src/librustc/README.txt index 15e751a283e..e79ee7fa647 100644 --- a/src/librustc/README.txt +++ b/src/librustc/README.txt @@ -13,31 +13,62 @@ https://github.com/rust-lang/rust/issues Your concerns are probably the same as someone else's. - -High-level concepts +The crates of rustc =================== -Rustc consists of the following subdirectories: +Rustc consists of four crates altogether: `libsyntax`, `librustc`, +`librustc_back`, and `librustc_trans` (the names and divisions are not +set in stone and may change; in general, a finer-grained division of +crates is preferable): -front/ - front-end: attributes, conditional compilation -middle/ - middle-end: name resolution, typechecking, LLVM code +- `libsyntax` contains those things concerned purely with syntax -- + that is, the AST, parser, pretty-printer, lexer, macro expander, and + utilities for traversing ASTs -- are in a separate crate called + "syntax", whose files are in ./../libsyntax, where . is the current + directory (that is, the parent directory of front/, middle/, back/, + and so on). + +- `librustc` (the current directory) contains the high-level analysis + passes, such as the type checker, borrow checker, and so forth. + It is the heart of the compiler. + +- `librustc_back` contains some very low-level details that are + specific to different LLVM targets and so forth. + +- `librustc_trans` contains the code to convert from Rust IR into LLVM + IR, and then from LLVM IR into machine code, as well as the main + driver that orchestrates all the other passes and various other bits + of miscellany. In general it contains code that runs towards the + end of the compilation process. + +Roughly speaking the "order" of the three crates is as follows: + + libsyntax -> librustc -> librustc_trans + | | + +-----------------+-------------------+ + | + librustc_trans/driver + +Here the role of `librustc_trans/driver` is to invoke the compiler +from libsyntax, then the analysis phases from librustc, and finally +the lowering and codegen passes from librustc_trans. + +Modules in the rustc crate +========================== + +The rustc crate itself consists of the following subdirectories +(mostly, but not entirely, in their own directories): + +session - options and data that pertain to the compilation session as a whole +middle - middle-end: name resolution, typechecking, LLVM code generation -back/ - back-end: linking and ABI -metadata/ - encoder and decoder for data required by +metadata - encoder and decoder for data required by separate compilation -driver/ - command-line processing, main() entrypoint -util/ - ubiquitous types and helper functions -lib/ - bindings to LLVM - -The files concerned purely with syntax -- that is, the AST, parser, -pretty-printer, lexer, macro expander, and utilities for traversing -ASTs -- are in a separate crate called "syntax", whose files are in -./../libsyntax, where . is the current directory (that is, the parent -directory of front/, middle/, back/, and so on). - -The entry-point for the compiler is main() in lib.rs, and -this file sequences the various parts together. +util - ubiquitous types and helper functions +lib - bindings to LLVM +The entry-point for the compiler is main() in the librustc_trans +crate. But the The 3 central data structures: ------------------------------ @@ -66,10 +97,10 @@ The 3 central data structures: compilation. Most variants in the ast::ty tag have a corresponding variant in the ty::sty tag. -#3: lib/llvm.rs defines the exported types ValueRef, TypeRef, - BasicBlockRef, and several others. Each of these is an opaque - pointer to an LLVM type, manipulated through the lib::llvm - interface. +#3: lib/llvm.rs (in librustc_trans) defines the exported types + ValueRef, TypeRef, BasicBlockRef, and several others. Each of + these is an opaque pointer to an LLVM type, manipulated through + the lib::llvm interface. Control and information flow within the compiler: @@ -87,7 +118,7 @@ Control and information flow within the compiler: structures. The driver passes environments to each compiler pass that needs to refer to them. -- Finally middle/trans.rs translates the Rust AST to LLVM bitcode in a - type-directed way. When it's finished synthesizing LLVM values, - rustc asks LLVM to write them out in some form (.bc, .o) and - possibly run the system linker. +- Finally, the `trans` module in `librustc_trans` translates the Rust + AST to LLVM bitcode in a type-directed way. When it's finished + synthesizing LLVM values, rustc asks LLVM to write them out in some + form (.bc, .o) and possibly run the system linker. diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index c9a1d47f558..0da9b05d4f8 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -62,11 +62,6 @@ pub mod back { pub use rustc_back::target_strs; pub use rustc_back::x86; pub use rustc_back::x86_64; - - pub mod link; - pub mod lto; - pub mod write; - } pub mod middle { @@ -99,11 +94,9 @@ pub mod middle { pub mod region; pub mod resolve; pub mod resolve_lifetime; - pub mod save; pub mod stability; pub mod subst; pub mod traits; - pub mod trans; pub mod ty; pub mod ty_fold; pub mod typeck; @@ -112,7 +105,7 @@ pub mod middle { pub mod metadata; -pub mod driver; +pub mod session; pub mod plugin; @@ -142,9 +135,3 @@ __build_diagnostic_array!(DIAGNOSTICS) mod rustc { pub use lint; } - -pub fn main() { - let args = std::os::args(); - let result = driver::run(args); - std::os::set_exit_status(result); -} diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index aa6a021a210..e9b235a2fe3 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -30,8 +30,7 @@ use middle::subst; use middle::ty; use middle::typeck::astconv::AstConv; use middle::typeck::infer; -use driver::session::Session; -use driver::early_error; +use session::{early_error, Session}; use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass, LintPassObject}; use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid}; use lint::builtin; diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index d9e7437216e..7f0941db6b2 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -13,8 +13,7 @@ //! Validates all used crates and extern libraries and loads their metadata use back::svh::Svh; -use driver::session::Session; -use driver::driver; +use session::{config, Session}; use metadata::cstore; use metadata::cstore::{CStore, CrateSource}; use metadata::decoder; @@ -455,7 +454,7 @@ impl<'a> PluginMetadataReader<'a> { pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata { let info = extract_crate_info(&self.env, krate).unwrap(); let target_triple = self.env.sess.opts.target_triple.as_slice(); - let is_cross = target_triple != driver::host_triple(); + let is_cross = target_triple != config::host_triple(); let mut should_link = info.should_link && !is_cross; let mut load_ctxt = loader::Context { sess: self.env.sess, @@ -464,7 +463,7 @@ impl<'a> PluginMetadataReader<'a> { crate_name: info.name.as_slice(), hash: None, filesearch: self.env.sess.host_filesearch(), - triple: driver::host_triple(), + triple: config::host_triple(), root: &None, rejected_via_hash: vec!(), rejected_via_triple: vec!(), @@ -481,7 +480,7 @@ impl<'a> PluginMetadataReader<'a> { if decoder::get_plugin_registrar_fn(lib.metadata.as_slice()).is_some() { let message = format!("crate `{}` contains a plugin_registrar fn but \ only a version for triple `{}` could be found (need {})", - info.ident, target_triple, driver::host_triple()); + info.ident, target_triple, config::host_triple()); self.env.sess.span_err(krate.span, message.as_slice()); // need to abort now because the syntax expansion // code will shortly attempt to load and execute diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e7a31520915..e90bf1e2b33 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -16,7 +16,7 @@ pub use self::InlinedItemRef::*; use back::svh::Svh; -use driver::config; +use session::config; use metadata::common::*; use metadata::cstore; use metadata::decoder; diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 30bef248b47..269c15e7d81 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -214,7 +214,7 @@ use back::archive::{METADATA_FILENAME}; use back::svh::Svh; -use driver::session::Session; +use session::Session; use llvm; use llvm::{False, ObjectFile, mk_section_iter}; use llvm::archive_ro::ArchiveRO; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 926197ad7d2..20dcf094b66 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -14,7 +14,7 @@ use metadata::common as c; use metadata::cstore as cstore; -use driver::session::Session; +use session::Session; use metadata::decoder; use middle::def; use metadata::encoder as e; diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index 9fc44744cf9..01ec9bbc13d 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -9,7 +9,7 @@ // except according to those terms. use self::Context::*; -use driver::session::Session; +use session::Session; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/check_static_recursion.rs b/src/librustc/middle/check_static_recursion.rs index a3738f031a9..b32eb64025f 100644 --- a/src/librustc/middle/check_static_recursion.rs +++ b/src/librustc/middle/check_static_recursion.rs @@ -11,7 +11,7 @@ // This compiler pass detects static items that refer to themselves // recursively. -use driver::session::Session; +use session::Session; use middle::resolve; use middle::def::{DefStatic, DefConst}; diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 75e61690685..e8e90e74989 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -63,8 +63,8 @@ use syntax::ast; -use driver::session; -use driver::config; +use session; +use session::config; use metadata::cstore; use metadata::csearch; use middle::ty; diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 01854564c05..fd0162b30d8 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -9,8 +9,7 @@ // except according to those terms. -use driver::config; -use driver::session::Session; +use session::{config, Session}; use syntax::ast::{Name, NodeId, Item, ItemFn}; use syntax::ast_map; use syntax::attr; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index ffc8a83e42e..da1c0bd649a 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -21,7 +21,7 @@ pub use self::LangItem::*; -use driver::session::Session; +use session::Session; use metadata::csearch::each_lang_item; use middle::ty; use middle::weak_lang_items; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index dbeb2e289fb..7dcc0510a6a 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -15,11 +15,11 @@ // makes all other generics or inline functions that it references // reachable as well. -use driver::config; use middle::def; use middle::ty; use middle::typeck; use middle::privacy; +use session::config; use util::nodemap::NodeSet; use std::collections::HashSet; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2cc8f20b562..f3d62988cc0 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -21,7 +21,7 @@ Most of the documentation on regions can be found in */ -use driver::session::Session; +use session::Session; use middle::ty::{FreeRegion}; use middle::ty; use util::nodemap::{FnvHashMap, NodeMap, NodeSet}; diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 134e4bc8d18..94b52532a94 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -36,7 +36,7 @@ use self::ModuleKind::*; use self::TraitReferenceType::*; use self::FallbackChecks::*; -use driver::session::Session; +use session::Session; use lint; use metadata::csearch; use metadata::decoder::{DefLike, DlDef, DlField, DlImpl}; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 359f58a1100..4077629f76d 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -20,7 +20,7 @@ pub use self::DefRegion::*; use self::ScopeChain::*; -use driver::session::Session; +use session::Session; use middle::subst; use std::fmt; use syntax::ast; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 52b29ff8b2e..5ec89ffb9e7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -37,7 +37,7 @@ pub use self::sty::*; pub use self::IntVarValue::*; use back::svh::Svh; -use driver::session::Session; +use session::Session; use lint; use metadata::csearch; use middle::const_eval; diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d58b0322433..33705343dab 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -82,7 +82,7 @@ use self::Expectation::*; use self::IsBinopAssignment::*; use self::TupleArgumentsFlag::*; -use driver::session::Session; +use session::Session; use middle::const_eval; use middle::def; use middle::lang_items::IteratorItem; diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index f9dffc04ceb..a75e3a78e4b 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -67,7 +67,6 @@ pub mod region_inference; pub mod resolve; mod skolemize; pub mod sub; -pub mod test; pub mod type_variable; pub mod unify; @@ -996,6 +995,16 @@ impl TypeTrace { pub fn span(&self) -> Span { self.origin.span() } + + pub fn dummy() -> TypeTrace { + TypeTrace { + origin: Misc(codemap::DUMMY_SP), + values: Types(ty::expected_found { + expected: ty::mk_err(), + found: ty::mk_err(), + }) + } + } } impl Repr for TypeTrace { diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 8561594212f..634b153a9ce 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -65,13 +65,12 @@ pub use self::ExprAdjustment::*; pub use self::vtable_origin::*; pub use self::MethodOrigin::*; -use driver::config; - use middle::def; use middle::resolve; use middle::subst; use middle::subst::VecPerParamSpace; use middle::ty; +use session::config; use util::common::time; use util::ppaux::Repr; use util::ppaux; diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index e107ac73d79..e0fe87d6d06 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -10,8 +10,8 @@ //! Validity checking for weak lang items -use driver::config; -use driver::session::Session; +use session::config; +use session::Session; use metadata::csearch; use middle::lang_items; diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index 921cd7a4107..1a270d0b1b7 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -10,7 +10,7 @@ //! Used by `rustc` when loading a plugin. -use driver::session::Session; +use session::Session; use metadata::creader::PluginMetadataReader; use plugin::registry::Registry; diff --git a/src/librustc/driver/config.rs b/src/librustc/session/config.rs similarity index 96% rename from src/librustc/driver/config.rs rename to src/librustc/session/config.rs index 1a40a04350d..e10a1a4342c 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/session/config.rs @@ -15,14 +15,11 @@ pub use self::EntryFnType::*; pub use self::CrateType::*; pub use self::Passes::*; pub use self::OptLevel::*; +pub use self::OutputType::*; pub use self::DebugInfoLevel::*; -use driver::{early_error, early_warn}; -use driver::driver; -use driver::session::Session; +use session::{early_error, early_warn, Session}; -use back; -use back::write; use rustc_back::target::Target; use lint; use metadata::cstore; @@ -65,6 +62,15 @@ pub enum DebugInfoLevel { FullDebugInfo, } +#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)] +pub enum OutputType { + OutputTypeBitcode, + OutputTypeAssembly, + OutputTypeLlvmAssembly, + OutputTypeObject, + OutputTypeExe, +} + #[deriving(Clone)] pub struct Options { // The crate config requested for the session, which may be combined @@ -76,7 +82,7 @@ pub struct Options { pub debuginfo: DebugInfoLevel, pub lint_opts: Vec<(String, lint::Level)>, pub describe_lints: bool, - pub output_types: Vec , + pub output_types: Vec , // This was mutable for rustpkg, which updates search paths based on the // parsed code. It remains mutable in case its replacements wants to use // this. @@ -108,6 +114,19 @@ pub struct Options { pub alt_std_name: Option } +pub fn host_triple() -> &'static str { + // Get the host triple out of the build environment. This ensures that our + // idea of the host triple is the same as for the set of libraries we've + // actually built. We can't just take LLVM's host triple because they + // normalize all ix86 architectures to i386. + // + // Instead of grabbing the host triple (for the current host), we grab (at + // compile time) the target triple that this rustc is built with and + // calling that (at runtime) the host triple. + (option_env!("CFG_COMPILER_HOST_TRIPLE")). + expect("CFG_COMPILER_HOST_TRIPLE") +} + /// Some reasonable defaults pub fn basic_options() -> Options { Options { @@ -120,7 +139,7 @@ pub fn basic_options() -> Options { output_types: Vec::new(), addl_lib_search_paths: RefCell::new(Vec::new()), maybe_sysroot: None, - target_triple: driver::host_triple().to_string(), + target_triple: host_triple().to_string(), cfg: Vec::new(), test: false, parse_only: false, @@ -673,11 +692,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { for unparsed_output_type in unparsed_output_types.iter() { for part in unparsed_output_type.as_slice().split(',') { let output_type = match part.as_slice() { - "asm" => write::OutputTypeAssembly, - "ir" => write::OutputTypeLlvmAssembly, - "bc" => write::OutputTypeBitcode, - "obj" => write::OutputTypeObject, - "link" => write::OutputTypeExe, + "asm" => OutputTypeAssembly, + "ir" => OutputTypeLlvmAssembly, + "bc" => OutputTypeBitcode, + "obj" => OutputTypeObject, + "link" => OutputTypeExe, _ => { early_error(format!("unknown emission type: `{}`", part).as_slice()) @@ -690,12 +709,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { output_types.as_mut_slice().sort(); output_types.dedup(); if output_types.len() == 0 { - output_types.push(write::OutputTypeExe); + output_types.push(OutputTypeExe); } let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m)); let target = matches.opt_str("target").unwrap_or( - driver::host_triple().to_string()); + host_triple().to_string()); let opt_level = { if matches.opt_present("O") { if matches.opt_present("opt-level") { @@ -880,8 +899,8 @@ impl fmt::Show for CrateType { #[cfg(test)] mod test { - use driver::config::{build_configuration, optgroups, build_session_options}; - use driver::session::build_session; + use session::config::{build_configuration, optgroups, build_session_options}; + use session::build_session; use getopts::getopts; use syntax::attr; diff --git a/src/librustc/driver/session.rs b/src/librustc/session/mod.rs similarity index 95% rename from src/librustc/driver/session.rs rename to src/librustc/session/mod.rs index 35ccbb4c7b4..d723db7706f 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/session/mod.rs @@ -9,8 +9,6 @@ // except according to those terms. -use driver::config; -use driver::driver; use metadata::cstore::CStore; use metadata::filesearch; use lint; @@ -18,7 +16,7 @@ use util::nodemap::NodeMap; use syntax::ast::NodeId; use syntax::codemap::Span; -use syntax::diagnostic; +use syntax::diagnostic::{mod, Emitter}; use syntax::diagnostics; use syntax::feature_gate; use syntax::parse; @@ -29,6 +27,8 @@ use syntax::{ast, codemap}; use std::os; use std::cell::{Cell, RefCell}; +pub mod config; + // Represents the data associated with a compilation // session for a single crate. pub struct Session { @@ -197,7 +197,7 @@ impl Session { pub fn host_filesearch<'a>(&'a self) -> filesearch::FileSearch<'a> { filesearch::FileSearch::new( self.sysroot(), - driver::host_triple(), + config::host_triple(), &self.opts.addl_lib_search_paths) } } @@ -263,3 +263,15 @@ pub fn build_session_(sopts: config::Options, pub fn expect(sess: &Session, opt: Option, msg: || -> String) -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } + +pub fn early_error(msg: &str) -> ! { + let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); + emitter.emit(None, msg, None, diagnostic::Fatal); + panic!(diagnostic::FatalError); +} + +pub fn early_warn(msg: &str) { + let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); + emitter.emit(None, msg, None, diagnostic::Warning); +} + diff --git a/src/librustc_trans/README.txt b/src/librustc_trans/README.txt new file mode 100644 index 00000000000..3904db4433c --- /dev/null +++ b/src/librustc_trans/README.txt @@ -0,0 +1 @@ +See the README.txt in ../librustc. diff --git a/src/librustc/back/link.rs b/src/librustc_trans/back/link.rs similarity index 99% rename from src/librustc/back/link.rs rename to src/librustc_trans/back/link.rs index 766715ff251..d5d488e8965 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -13,15 +13,15 @@ use super::archive; use super::rpath; use super::rpath::RPathConfig; use super::svh::Svh; -use super::write::{OutputTypeBitcode, OutputTypeExe, OutputTypeObject}; use driver::driver::{CrateTranslation, OutputFilenames, Input, FileInput}; -use driver::config::NoDebugInfo; -use driver::session::Session; -use driver::config; +use session::config; +use session::config::NoDebugInfo; +use session::config::{OutputTypeBitcode, OutputTypeExe, OutputTypeObject}; +use session::Session; use metadata::common::LinkMeta; use metadata::{encoder, cstore, filesearch, csearch, creader}; -use middle::trans::context::CrateContext; -use middle::trans::common::gensym_name; +use trans::context::CrateContext; +use trans::common::gensym_name; use middle::ty; use util::common::time; use util::ppaux; diff --git a/src/librustc/back/lto.rs b/src/librustc_trans/back/lto.rs similarity index 98% rename from src/librustc/back/lto.rs rename to src/librustc_trans/back/lto.rs index 3fbf830485b..407f632bee7 100644 --- a/src/librustc/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -10,13 +10,12 @@ use super::link; use super::write; -use driver::session; -use driver::config; +use rustc::session::{mod, config}; use llvm; use llvm::archive_ro::ArchiveRO; use llvm::{ModuleRef, TargetMachineRef, True, False}; -use metadata::cstore; -use util::common::time; +use rustc::metadata::cstore; +use rustc::util::common::time; use libc; use flate; diff --git a/src/librustc/back/write.rs b/src/librustc_trans/back/write.rs similarity index 95% rename from src/librustc/back/write.rs rename to src/librustc_trans/back/write.rs index 19ddb844bec..abf29fe3a4c 100644 --- a/src/librustc/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -8,14 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub use self::OutputType::*; - use back::lto; use back::link::{get_cc_prog, remove}; use driver::driver::{CrateTranslation, ModuleTranslation, OutputFilenames}; -use driver::config::{NoDebugInfo, Passes, SomePasses, AllPasses}; -use driver::session::Session; -use driver::config; +use session::config::{NoDebugInfo, Passes, SomePasses, AllPasses}; +use session::Session; +use session::config; use llvm; use llvm::{ModuleRef, TargetMachineRef, PassManagerRef, DiagnosticInfoRef, ContextRef}; use llvm::SMDiagnosticRef; @@ -35,15 +33,6 @@ use std::sync::{Arc, Mutex}; use std::task::TaskBuilder; use libc::{c_uint, c_int, c_void}; -#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)] -pub enum OutputType { - OutputTypeBitcode, - OutputTypeAssembly, - OutputTypeLlvmAssembly, - OutputTypeObject, - OutputTypeExe, -} - pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! { unsafe { let cstr = llvm::LLVMRustGetLastError(); @@ -536,7 +525,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext, pub fn run_passes(sess: &Session, trans: &CrateTranslation, - output_types: &[OutputType], + output_types: &[config::OutputType], crate_output: &OutputFilenames) { // It's possible that we have `codegen_units > 1` but only one item in // `trans.modules`. We could theoretically proceed and do LTO in that @@ -580,26 +569,26 @@ pub fn run_passes(sess: &Session, // archive in order to allow LTO against it. let needs_crate_bitcode = sess.crate_types.borrow().contains(&config::CrateTypeRlib) && - sess.opts.output_types.contains(&OutputTypeExe); + sess.opts.output_types.contains(&config::OutputTypeExe); if needs_crate_bitcode { modules_config.emit_bc = true; } for output_type in output_types.iter() { match *output_type { - OutputTypeBitcode => { modules_config.emit_bc = true; }, - OutputTypeLlvmAssembly => { modules_config.emit_ir = true; }, - OutputTypeAssembly => { + config::OutputTypeBitcode => { modules_config.emit_bc = true; }, + config::OutputTypeLlvmAssembly => { modules_config.emit_ir = true; }, + config::OutputTypeAssembly => { modules_config.emit_asm = true; // If we're not using the LLVM assembler, this function // could be invoked specially with output_type_assembly, so // in this case we still want the metadata object file. - if !sess.opts.output_types.contains(&OutputTypeAssembly) { + if !sess.opts.output_types.contains(&config::OutputTypeAssembly) { metadata_config.emit_obj = true; } }, - OutputTypeObject => { modules_config.emit_obj = true; }, - OutputTypeExe => { + config::OutputTypeObject => { modules_config.emit_obj = true; }, + config::OutputTypeExe => { modules_config.emit_obj = true; metadata_config.emit_obj = true; }, @@ -647,7 +636,7 @@ pub fn run_passes(sess: &Session, // Produce final compile outputs. - let copy_if_one_unit = |ext: &str, output_type: OutputType, keep_numbered: bool| { + let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| { // Three cases: if sess.opts.cg.codegen_units == 1 { // 1) Only one codegen unit. In this case it's no difficulty @@ -750,25 +739,31 @@ pub fn run_passes(sess: &Session, let mut user_wants_bitcode = false; for output_type in output_types.iter() { match *output_type { - OutputTypeBitcode => { + config::OutputTypeBitcode => { user_wants_bitcode = true; // Copy to .bc, but always keep the .0.bc. There is a later // check to figure out if we should delete .0.bc files, or keep // them for making an rlib. - copy_if_one_unit("0.bc", OutputTypeBitcode, true); - }, - OutputTypeLlvmAssembly => { copy_if_one_unit("0.ll", OutputTypeLlvmAssembly, false); }, - OutputTypeAssembly => { copy_if_one_unit("0.s", OutputTypeAssembly, false); }, - OutputTypeObject => { link_obj(&crate_output.path(OutputTypeObject)); }, - OutputTypeExe => { - // If OutputTypeObject is already in the list, then - // `crate.o` will be handled by the OutputTypeObject case. + copy_if_one_unit("0.bc", config::OutputTypeBitcode, true); + } + config::OutputTypeLlvmAssembly => { + copy_if_one_unit("0.ll", config::OutputTypeLlvmAssembly, false); + } + config::OutputTypeAssembly => { + copy_if_one_unit("0.s", config::OutputTypeAssembly, false); + } + config::OutputTypeObject => { + link_obj(&crate_output.path(config::OutputTypeObject)); + } + config::OutputTypeExe => { + // If config::OutputTypeObject is already in the list, then + // `crate.o` will be handled by the config::OutputTypeObject case. // Otherwise, we need to create the temporary object so we // can run the linker. - if !sess.opts.output_types.contains(&OutputTypeObject) { - link_obj(&crate_output.temp_path(OutputTypeObject)); + if !sess.opts.output_types.contains(&config::OutputTypeObject) { + link_obj(&crate_output.temp_path(config::OutputTypeObject)); } - }, + } } } let user_wants_bitcode = user_wants_bitcode; @@ -922,8 +917,8 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) { let pname = get_cc_prog(sess); let mut cmd = Command::new(pname.as_slice()); - cmd.arg("-c").arg("-o").arg(outputs.path(OutputTypeObject)) - .arg(outputs.temp_path(OutputTypeAssembly)); + cmd.arg("-c").arg("-o").arg(outputs.path(config::OutputTypeObject)) + .arg(outputs.temp_path(config::OutputTypeAssembly)); debug!("{}", &cmd); match cmd.output() { diff --git a/src/librustc/driver/driver.rs b/src/librustc_trans/driver/driver.rs similarity index 95% rename from src/librustc/driver/driver.rs rename to src/librustc_trans/driver/driver.rs index 498e676474c..ca70a37bf3d 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc_trans/driver/driver.rs @@ -12,18 +12,19 @@ pub use self::Input::*; use back::link; use back::write; -use driver::session::Session; -use driver::config; +use session::Session; +use session::config; use lint; use llvm::{ContextRef, ModuleRef}; use metadata::common::LinkMeta; use metadata::creader; -use middle::{trans, stability, ty, typeck, reachable}; +use middle::{stability, ty, typeck, reachable}; use middle::dependency_format; use middle; use plugin::load::Plugins; use plugin::registry::Registry; use plugin; +use trans; use util::common::time; use util::nodemap::{NodeSet}; @@ -34,6 +35,7 @@ use std::io; use std::io::fs; use std::os; use arena::TypedArena; +use save; use syntax::ast; use syntax::ast_map; use syntax::attr; @@ -43,19 +45,6 @@ use syntax::parse; use syntax::parse::token; use syntax; -pub fn host_triple() -> &'static str { - // Get the host triple out of the build environment. This ensures that our - // idea of the host triple is the same as for the set of libraries we've - // actually built. We can't just take LLVM's host triple because they - // normalize all ix86 architectures to i386. - // - // Instead of grabbing the host triple (for the current host), we grab (at - // compile time) the target triple that this rustc is built with and - // calling that (at runtime) the host triple. - (option_env!("CFG_COMPILER_HOST_TRIPLE")). - expect("CFG_COMPILER_HOST_TRIPLE") -} - pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input, @@ -503,7 +492,7 @@ pub fn phase_save_analysis(sess: &Session, return; } time(sess.time_passes(), "save analysis", krate, |krate| - middle::save::process_crate(sess, krate, analysis, odir)); + save::process_crate(sess, krate, analysis, odir)); } pub struct ModuleTranslation { @@ -541,7 +530,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session, trans: &CrateTranslation, outputs: &OutputFilenames) { if sess.opts.cg.no_integrated_as { - let output_type = write::OutputTypeAssembly; + let output_type = config::OutputTypeAssembly; time(sess.time_passes(), "LLVM passes", (), |_| write::run_passes(sess, trans, &[output_type], outputs)); @@ -550,7 +539,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session, // Remove assembly source, unless --save-temps was specified if !sess.opts.cg.save_temps { - fs::unlink(&outputs.temp_path(write::OutputTypeAssembly)).unwrap(); + fs::unlink(&outputs.temp_path(config::OutputTypeAssembly)).unwrap(); } } else { time(sess.time_passes(), "LLVM passes", (), |_| @@ -610,7 +599,7 @@ pub fn stop_after_phase_2(sess: &Session) -> bool { } pub fn stop_after_phase_5(sess: &Session) -> bool { - if !sess.opts.output_types.iter().any(|&i| i == write::OutputTypeExe) { + if !sess.opts.output_types.iter().any(|&i| i == config::OutputTypeExe) { debug!("not building executable, returning early from compile_input"); return true; } @@ -632,7 +621,7 @@ fn write_out_deps(sess: &Session, for output_type in sess.opts.output_types.iter() { let file = outputs.path(*output_type); match *output_type { - write::OutputTypeExe => { + config::OutputTypeExe => { for output in sess.crate_types.borrow().iter() { let p = link::filename_for_input(sess, *output, id, &file); @@ -772,7 +761,7 @@ pub struct OutputFilenames { } impl OutputFilenames { - pub fn path(&self, flavor: write::OutputType) -> Path { + pub fn path(&self, flavor: config::OutputType) -> Path { match self.single_output_file { Some(ref path) => return path.clone(), None => {} @@ -780,14 +769,14 @@ impl OutputFilenames { self.temp_path(flavor) } - pub fn temp_path(&self, flavor: write::OutputType) -> Path { + pub fn temp_path(&self, flavor: config::OutputType) -> Path { let base = self.out_directory.join(self.filestem()); match flavor { - write::OutputTypeBitcode => base.with_extension("bc"), - write::OutputTypeAssembly => base.with_extension("s"), - write::OutputTypeLlvmAssembly => base.with_extension("ll"), - write::OutputTypeObject => base.with_extension("o"), - write::OutputTypeExe => base, + config::OutputTypeBitcode => base.with_extension("bc"), + config::OutputTypeAssembly => base.with_extension("s"), + config::OutputTypeLlvmAssembly => base.with_extension("ll"), + config::OutputTypeObject => base.with_extension("o"), + config::OutputTypeExe => base, } } diff --git a/src/librustc/driver/mod.rs b/src/librustc_trans/driver/mod.rs similarity index 96% rename from src/librustc/driver/mod.rs rename to src/librustc_trans/driver/mod.rs index 2087434ccd9..8985d05b6ca 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc_trans/driver/mod.rs @@ -12,16 +12,20 @@ pub use syntax::diagnostic; use back::link; use driver::driver::{Input, FileInput, StrInput}; -use driver::session::{Session, build_session}; +use session::{config, Session, build_session}; use lint::Lint; use lint; use metadata; +use rustc::DIAGNOSTICS; + use std::any::AnyRefExt; use std::io; use std::os; use std::task::TaskBuilder; +use session::early_error; + use syntax::ast; use syntax::parse; use syntax::diagnostic::Emitter; @@ -30,8 +34,6 @@ use syntax::diagnostics; use getopts; pub mod driver; -pub mod session; -pub mod config; pub mod pretty; pub fn run(args: Vec) -> int { @@ -48,7 +50,7 @@ fn run_compiler(args: &[String]) { None => return }; - let descriptions = diagnostics::registry::Registry::new(&super::DIAGNOSTICS); + let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS); match matches.opt_str("explain") { Some(ref code) => { match descriptions.find_description(code.as_slice()) { @@ -155,7 +157,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) -> Option { println!("binary: {}", binary); println!("commit-hash: {}", unw(commit_hash_str())); println!("commit-date: {}", unw(commit_date_str())); - println!("host: {}", driver::host_triple()); + println!("host: {}", config::host_triple()); println!("release: {}", unw(release_str())); } None @@ -418,17 +420,6 @@ fn parse_crate_attrs(sess: &Session, input: &Input) -> result.into_iter().collect() } -pub fn early_error(msg: &str) -> ! { - let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); - emitter.emit(None, msg, None, diagnostic::Fatal); - panic!(diagnostic::FatalError); -} - -pub fn early_warn(msg: &str) { - let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); - emitter.emit(None, msg, None, diagnostic::Warning); -} - pub fn list_metadata(sess: &Session, path: &Path, out: &mut io::Writer) -> io::IoResult<()> { metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, out) @@ -508,3 +499,4 @@ pub fn monitor(f: proc():Send) { } } } + diff --git a/src/librustc/driver/pretty.rs b/src/librustc_trans/driver/pretty.rs similarity index 99% rename from src/librustc/driver/pretty.rs rename to src/librustc_trans/driver/pretty.rs index 8099bf314c2..c20f2e097f3 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc_trans/driver/pretty.rs @@ -17,9 +17,8 @@ use self::NodesMatchingUII::*; use back::link; -use driver::config; +use session::{config, Session}; use driver::driver::{mod, CrateAnalysis}; -use driver::session::Session; use middle::ty; use middle::borrowck::{mod, FnPartsWithCFG}; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs new file mode 100644 index 00000000000..ad9333e5794 --- /dev/null +++ b/src/librustc_trans/lib.rs @@ -0,0 +1,87 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! + +The Rust compiler. + +# Note + +This API is completely unstable and subject to change. + +*/ + +#![crate_name = "rustc_trans"] +#![experimental] +#![comment = "The Rust compiler back end and driver"] +#![license = "MIT/ASL2"] +#![crate_type = "dylib"] +#![crate_type = "rlib"] +#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://doc.rust-lang.org/nightly/")] + +#![feature(default_type_params, globs, if_let, import_shadowing, macro_rules, phase, quote)] +#![feature(slicing_syntax, struct_variant, unsafe_destructor)] +#![feature(rustc_diagnostic_macros)] + +extern crate arena; +extern crate flate; +extern crate getopts; +extern crate graphviz; +extern crate libc; +extern crate rustc; +extern crate rustc_back; +#[phase(plugin, link)] extern crate log; +#[phase(plugin, link)] extern crate syntax; +extern crate serialize; +extern crate "rustc_llvm" as llvm; + +pub use rustc::session; +pub use rustc::metadata; +pub use rustc::middle; +pub use rustc::lint; +pub use rustc::plugin; +pub use rustc::util; + +pub mod back { + pub use rustc_back::abi; + pub use rustc_back::archive; + pub use rustc_back::arm; + pub use rustc_back::mips; + pub use rustc_back::mipsel; + pub use rustc_back::rpath; + pub use rustc_back::svh; + pub use rustc_back::target_strs; + pub use rustc_back::x86; + pub use rustc_back::x86_64; + + pub mod link; + pub mod lto; + pub mod write; + +} + +pub mod trans; +pub mod save; +pub mod driver; + +pub mod lib { + pub use llvm; +} + +pub fn main() { + let args = std::os::args(); + let result = driver::run(args); + std::os::set_exit_status(result); +} + +#[cfg(test)] +pub mod test; diff --git a/src/librustc/middle/save/mod.rs b/src/librustc_trans/save/mod.rs similarity index 99% rename from src/librustc/middle/save/mod.rs rename to src/librustc_trans/save/mod.rs index 367fe2845dd..38bc8c99c0f 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -28,7 +28,7 @@ //! DxrVisitor walks the AST and processes it. use driver::driver::CrateAnalysis; -use driver::session::Session; +use session::Session; use middle::def; use middle::ty; @@ -55,9 +55,9 @@ use syntax::visit::Visitor; use syntax::print::pprust::{path_to_string,ty_to_string}; use syntax::ptr::P; -use middle::save::span_utils::SpanUtils; -use middle::save::recorder::Recorder; -use middle::save::recorder::FmtStrs; +use self::span_utils::SpanUtils; +use self::recorder::Recorder; +use self::recorder::FmtStrs; use util::ppaux; diff --git a/src/librustc/middle/save/recorder.rs b/src/librustc_trans/save/recorder.rs similarity index 99% rename from src/librustc/middle/save/recorder.rs rename to src/librustc_trans/save/recorder.rs index b8d495bd495..120e4b203e0 100644 --- a/src/librustc/middle/save/recorder.rs +++ b/src/librustc_trans/save/recorder.rs @@ -10,8 +10,8 @@ pub use self::Row::*; -use middle::save::escape; -use middle::save::span_utils::SpanUtils; +use super::escape; +use super::span_utils::SpanUtils; use std::vec::Vec; diff --git a/src/librustc/middle/save/span_utils.rs b/src/librustc_trans/save/span_utils.rs similarity index 99% rename from src/librustc/middle/save/span_utils.rs rename to src/librustc_trans/save/span_utils.rs index 14d8bf0cfed..e01081d8422 100644 --- a/src/librustc/middle/save/span_utils.rs +++ b/src/librustc_trans/save/span_utils.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use driver::session::Session; +use rustc::session::Session; -use middle::save::generated_code; +use save::generated_code; use std::cell::Cell; diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc_trans/test.rs similarity index 98% rename from src/librustc/middle/typeck/infer/test.rs rename to src/librustc_trans/test.rs index 769fdef0625..4648021cc5f 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc_trans/test.rs @@ -17,11 +17,9 @@ // This is only used by tests, hence allow dead code. #![allow(dead_code)] -use driver::config; use driver::diagnostic; use driver::diagnostic::Emitter; use driver::driver; -use driver::session; use middle::lang_items; use middle::region; use middle::resolve; @@ -32,6 +30,7 @@ use middle::typeck::infer::combine::Combine; use middle::typeck::infer; use middle::typeck::infer::lub::Lub; use middle::typeck::infer::glb::Glb; +use session::{mod, config}; use syntax::codemap; use syntax::codemap::{Span, CodeMap, DUMMY_SP}; use syntax::diagnostic::{Level, RenderSpan, Bug, Fatal, Error, Warning, Note, Help}; @@ -289,13 +288,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { } pub fn dummy_type_trace(&self) -> infer::TypeTrace { - infer::TypeTrace { - origin: infer::Misc(DUMMY_SP), - values: infer::Types(ty::expected_found { - expected: ty::mk_err(), - found: ty::mk_err(), - }) - } + infer::TypeTrace::dummy() } pub fn lub(&self) -> Lub<'a, 'tcx> { diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc_trans/trans/_match.rs similarity index 99% rename from src/librustc/middle/trans/_match.rs rename to src/librustc_trans/trans/_match.rs index d7a2e7429f9..001a3a4dca0 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -193,7 +193,6 @@ use self::Opt::*; use self::FailureHandler::*; use back::abi; -use driver::config::FullDebugInfo; use llvm::{ValueRef, BasicBlockRef}; use middle::check_match::StaticInliner; use middle::check_match; @@ -204,21 +203,22 @@ use middle::lang_items::StrEqFnLangItem; use middle::mem_categorization as mc; use middle::pat_util::*; use middle::resolve::DefMap; -use middle::trans::adt; -use middle::trans::base::*; -use middle::trans::build::{AddCase, And, BitCast, Br, CondBr, GEPi, InBoundsGEP, Load}; -use middle::trans::build::{Mul, Not, Store, Sub, add_comment}; -use middle::trans::build; -use middle::trans::callee; -use middle::trans::cleanup::{mod, CleanupMethods}; -use middle::trans::common::*; -use middle::trans::consts; -use middle::trans::datum::*; -use middle::trans::expr::{mod, Dest}; -use middle::trans::tvec; -use middle::trans::type_of; -use middle::trans::debuginfo; +use trans::adt; +use trans::base::*; +use trans::build::{AddCase, And, BitCast, Br, CondBr, GEPi, InBoundsGEP, Load}; +use trans::build::{Mul, Not, Store, Sub, add_comment}; +use trans::build; +use trans::callee; +use trans::cleanup::{mod, CleanupMethods}; +use trans::common::*; +use trans::consts; +use trans::datum::*; +use trans::expr::{mod, Dest}; +use trans::tvec; +use trans::type_of; +use trans::debuginfo; use middle::ty; +use session::config::FullDebugInfo; use util::common::indenter; use util::nodemap::FnvHashMap; use util::ppaux::{Repr, vec_map_to_string}; diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc_trans/trans/adt.rs similarity index 99% rename from src/librustc/middle/trans/adt.rs rename to src/librustc_trans/trans/adt.rs index d48868c2889..806c4a68ba2 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -55,15 +55,15 @@ use llvm::{ValueRef, True, IntEQ, IntNE}; use back::abi::slice_elt_base; use middle::subst; use middle::subst::Subst; -use middle::trans::_match; -use middle::trans::build::*; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::common::*; -use middle::trans::datum; -use middle::trans::machine; -use middle::trans::type_::Type; -use middle::trans::type_of; +use trans::_match; +use trans::build::*; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::common::*; +use trans::datum; +use trans::machine; +use trans::type_::Type; +use trans::type_of; use middle::ty; use middle::ty::Disr; use syntax::ast; diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc_trans/trans/asm.rs similarity index 95% rename from src/librustc/middle/trans/asm.rs rename to src/librustc_trans/trans/asm.rs index 04237a2d449..9b499b6d1a1 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc_trans/trans/asm.rs @@ -13,14 +13,14 @@ */ use llvm; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::common::*; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::expr; -use middle::trans::type_of; -use middle::trans::type_::Type; +use trans::build::*; +use trans::callee; +use trans::common::*; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::expr; +use trans::type_of; +use trans::type_::Type; use std::c_str::ToCStr; use std::string::String; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc_trans/trans/base.rs similarity index 98% rename from src/librustc/middle/trans/base.rs rename to src/librustc_trans/trans/base.rs index c05e61023ed..39474a99f6d 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -31,10 +31,7 @@ pub use self::scalar_type::*; use back::link::{mangle_exported_name}; use back::{link, abi}; -use driver::config; -use driver::config::{NoDebugInfo, FullDebugInfo}; use driver::driver::{CrateAnalysis, CrateTranslation, ModuleTranslation}; -use driver::session::Session; use lint; use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param}; use llvm; @@ -44,41 +41,43 @@ use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem}; use middle::subst; use middle::weak_lang_items; use middle::subst::Subst; -use middle::trans::_match; -use middle::trans::adt; -use middle::trans::build::*; -use middle::trans::builder::{Builder, noname}; -use middle::trans::callee; -use middle::trans::cleanup::{CleanupMethods, ScopeId}; -use middle::trans::cleanup; -use middle::trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral}; -use middle::trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef}; -use middle::trans::common::{CrateContext, ExternMap, FunctionContext}; -use middle::trans::common::{NodeInfo, Result, SubstP}; -use middle::trans::common::{node_id_type, param_substs, return_type_is_void}; -use middle::trans::common::{tydesc_info, type_is_immediate}; -use middle::trans::common::{type_is_zero_size, val_ty}; -use middle::trans::common; -use middle::trans::consts; -use middle::trans::context::SharedCrateContext; -use middle::trans::controlflow; -use middle::trans::datum; -use middle::trans::debuginfo; -use middle::trans::expr; -use middle::trans::foreign; -use middle::trans::glue; -use middle::trans::inline; -use middle::trans::intrinsic; -use middle::trans::machine; -use middle::trans::machine::{llsize_of, llsize_of_real, llalign_of_min}; -use middle::trans::meth; -use middle::trans::monomorphize; -use middle::trans::tvec; -use middle::trans::type_::Type; -use middle::trans::type_of; -use middle::trans::type_of::*; -use middle::trans::value::Value; use middle::ty; +use session::config::{mod, NoDebugInfo, FullDebugInfo}; +use session::Session; +use trans::_match; +use trans::adt; +use trans::build::*; +use trans::builder::{Builder, noname}; +use trans::callee; +use trans::cleanup::{CleanupMethods, ScopeId}; +use trans::cleanup; +use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral}; +use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef}; +use trans::common::{CrateContext, ExternMap, FunctionContext}; +use trans::common::{NodeInfo, Result, SubstP}; +use trans::common::{node_id_type, param_substs, return_type_is_void}; +use trans::common::{tydesc_info, type_is_immediate}; +use trans::common::{type_is_zero_size, val_ty}; +use trans::common; +use trans::consts; +use trans::context::SharedCrateContext; +use trans::controlflow; +use trans::datum; +use trans::debuginfo; +use trans::expr; +use trans::foreign; +use trans::glue; +use trans::inline; +use trans::intrinsic; +use trans::machine; +use trans::machine::{llsize_of, llsize_of_real, llalign_of_min}; +use trans::meth; +use trans::monomorphize; +use trans::tvec; +use trans::type_::Type; +use trans::type_of; +use trans::type_of::*; +use trans::value::Value; use util::common::indenter; use util::ppaux::{Repr, ty_to_string}; use util::sha2::Sha256; @@ -1500,7 +1499,7 @@ pub fn init_function<'a, 'tcx>(fcx: &'a FunctionContext<'a, 'tcx>, // - trans_args pub fn arg_kind(cx: &FunctionContext, t: ty::t) -> datum::Rvalue { - use middle::trans::datum::{ByRef, ByValue}; + use trans::datum::{ByRef, ByValue}; datum::Rvalue { mode: if arg_is_indirect(cx.ccx, t) { ByRef } else { ByValue } diff --git a/src/librustc/middle/trans/basic_block.rs b/src/librustc_trans/trans/basic_block.rs similarity index 97% rename from src/librustc/middle/trans/basic_block.rs rename to src/librustc_trans/trans/basic_block.rs index 01335071717..35afe7ac55e 100644 --- a/src/librustc/middle/trans/basic_block.rs +++ b/src/librustc_trans/trans/basic_block.rs @@ -10,7 +10,7 @@ use llvm; use llvm::{BasicBlockRef}; -use middle::trans::value::{Users, Value}; +use trans::value::{Users, Value}; use std::iter::{Filter, Map}; pub struct BasicBlock(pub BasicBlockRef); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc_trans/trans/build.rs similarity index 99% rename from src/librustc/middle/trans/build.rs rename to src/librustc_trans/trans/build.rs index 3ae4fdf0838..1f77f625c9d 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc_trans/trans/build.rs @@ -15,11 +15,11 @@ use llvm; use llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect, AttrBuilder}; use llvm::{Opcode, IntPredicate, RealPredicate}; use llvm::{ValueRef, BasicBlockRef}; -use middle::trans::common::*; +use trans::common::*; use syntax::codemap::Span; -use middle::trans::builder::Builder; -use middle::trans::type_::Type; +use trans::builder::Builder; +use trans::type_::Type; use libc::{c_uint, c_char}; diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc_trans/trans/builder.rs similarity index 99% rename from src/librustc/middle/trans/builder.rs rename to src/librustc_trans/trans/builder.rs index 36d156d70e5..526592181ae 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc_trans/trans/builder.rs @@ -14,10 +14,10 @@ use llvm; use llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect, AttrBuilder}; use llvm::{Opcode, IntPredicate, RealPredicate, False}; use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef}; -use middle::trans::base; -use middle::trans::common::*; -use middle::trans::machine::llalign_of_pref; -use middle::trans::type_::Type; +use trans::base; +use trans::common::*; +use trans::machine::llalign_of_pref; +use trans::type_::Type; use util::nodemap::FnvHashMap; use libc::{c_uint, c_char}; use std::string::String; diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc_trans/trans/cabi.rs similarity index 93% rename from src/librustc/middle/trans/cabi.rs rename to src/librustc_trans/trans/cabi.rs index d69238ae92e..0214bf29eee 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc_trans/trans/cabi.rs @@ -12,13 +12,13 @@ pub use self::ArgKind::*; use llvm::Attribute; use std::option; -use middle::trans::context::CrateContext; -use middle::trans::cabi_x86; -use middle::trans::cabi_x86_64; -use middle::trans::cabi_x86_win64; -use middle::trans::cabi_arm; -use middle::trans::cabi_mips; -use middle::trans::type_::Type; +use trans::context::CrateContext; +use trans::cabi_x86; +use trans::cabi_x86_64; +use trans::cabi_x86_win64; +use trans::cabi_arm; +use trans::cabi_mips; +use trans::type_::Type; #[deriving(Clone, PartialEq)] pub enum ArgKind { diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc_trans/trans/cabi_arm.rs similarity index 97% rename from src/librustc/middle/trans/cabi_arm.rs rename to src/librustc_trans/trans/cabi_arm.rs index 2782970b975..46440fcf1a1 100644 --- a/src/librustc/middle/trans/cabi_arm.rs +++ b/src/librustc_trans/trans/cabi_arm.rs @@ -13,9 +13,9 @@ use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array}; use llvm::{StructRetAttribute, ZExtAttribute}; -use middle::trans::cabi::{FnType, ArgType}; -use middle::trans::context::CrateContext; -use middle::trans::type_::Type; +use trans::cabi::{FnType, ArgType}; +use trans::context::CrateContext; +use trans::type_::Type; use std::cmp; diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc_trans/trans/cabi_mips.rs similarity index 97% rename from src/librustc/middle/trans/cabi_mips.rs rename to src/librustc_trans/trans/cabi_mips.rs index 5fe10d2d8e7..4dfe8daf339 100644 --- a/src/librustc/middle/trans/cabi_mips.rs +++ b/src/librustc_trans/trans/cabi_mips.rs @@ -15,9 +15,9 @@ use std::cmp; use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array}; use llvm::{StructRetAttribute, ZExtAttribute}; -use middle::trans::cabi::{ArgType, FnType}; -use middle::trans::context::CrateContext; -use middle::trans::type_::Type; +use trans::cabi::{ArgType, FnType}; +use trans::context::CrateContext; +use trans::type_::Type; fn align_up_to(off: uint, a: uint) -> uint { return (off + a - 1u) / a * a; diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc_trans/trans/cabi_x86.rs similarity index 97% rename from src/librustc/middle/trans/cabi_x86.rs rename to src/librustc_trans/trans/cabi_x86.rs index f779ef3d311..32f6eb060c0 100644 --- a/src/librustc/middle/trans/cabi_x86.rs +++ b/src/librustc_trans/trans/cabi_x86.rs @@ -10,8 +10,8 @@ use self::Strategy::*; use llvm::*; -use middle::trans::cabi::{ArgType, FnType}; -use middle::trans::type_::Type; +use trans::cabi::{ArgType, FnType}; +use trans::type_::Type; use super::common::*; use super::machine::*; diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc_trans/trans/cabi_x86_64.rs similarity index 98% rename from src/librustc/middle/trans/cabi_x86_64.rs rename to src/librustc_trans/trans/cabi_x86_64.rs index cb235c015ff..69ee5301d18 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc_trans/trans/cabi_x86_64.rs @@ -18,9 +18,9 @@ use llvm; use llvm::{Integer, Pointer, Float, Double}; use llvm::{Struct, Array, Attribute}; use llvm::{StructRetAttribute, ByValAttribute, ZExtAttribute}; -use middle::trans::cabi::{ArgType, FnType}; -use middle::trans::context::CrateContext; -use middle::trans::type_::Type; +use trans::cabi::{ArgType, FnType}; +use trans::context::CrateContext; +use trans::type_::Type; use std::cmp; diff --git a/src/librustc/middle/trans/cabi_x86_win64.rs b/src/librustc_trans/trans/cabi_x86_win64.rs similarity index 96% rename from src/librustc/middle/trans/cabi_x86_win64.rs rename to src/librustc_trans/trans/cabi_x86_win64.rs index 6bcd9aefcc6..79e309dacaa 100644 --- a/src/librustc/middle/trans/cabi_x86_win64.rs +++ b/src/librustc_trans/trans/cabi_x86_win64.rs @@ -11,8 +11,8 @@ use llvm::*; use super::common::*; use super::machine::*; -use middle::trans::cabi::{ArgType, FnType}; -use middle::trans::type_::Type; +use trans::cabi::{ArgType, FnType}; +use trans::type_::Type; // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc_trans/trans/callee.rs similarity index 98% rename from src/librustc/middle/trans/callee.rs rename to src/librustc_trans/trans/callee.rs index 956942068d9..0544c9d43a8 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -23,33 +23,33 @@ pub use self::CallArgs::*; use arena::TypedArena; use back::abi; use back::link; -use driver::session; +use session; use llvm::{ValueRef, get_param}; use llvm; use metadata::csearch; use middle::def; use middle::subst; use middle::subst::{Subst}; -use middle::trans::adt; -use middle::trans::base; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::closure; -use middle::trans::common; -use middle::trans::common::*; -use middle::trans::datum::*; -use middle::trans::expr; -use middle::trans::glue; -use middle::trans::inline; -use middle::trans::foreign; -use middle::trans::intrinsic; -use middle::trans::meth; -use middle::trans::monomorphize; -use middle::trans::type_::Type; -use middle::trans::type_of; +use trans::adt; +use trans::base; +use trans::base::*; +use trans::build::*; +use trans::callee; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::closure; +use trans::common; +use trans::common::*; +use trans::datum::*; +use trans::expr; +use trans::glue; +use trans::inline; +use trans::foreign; +use trans::intrinsic; +use trans::meth; +use trans::monomorphize; +use trans::type_::Type; +use trans::type_of; use middle::ty; use middle::typeck::coherence::make_substs_for_receiver_types; use middle::typeck::MethodCall; diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs similarity index 99% rename from src/librustc/middle/trans/cleanup.rs rename to src/librustc_trans/trans/cleanup.rs index 1207c995998..02909b0e3a9 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -19,14 +19,14 @@ pub use self::EarlyExitLabel::*; pub use self::Heap::*; use llvm::{BasicBlockRef, ValueRef}; -use middle::trans::base; -use middle::trans::build; -use middle::trans::callee; -use middle::trans::common; -use middle::trans::common::{Block, FunctionContext, ExprId, NodeInfo}; -use middle::trans::debuginfo; -use middle::trans::glue; -use middle::trans::type_::Type; +use trans::base; +use trans::build; +use trans::callee; +use trans::common; +use trans::common::{Block, FunctionContext, ExprId, NodeInfo}; +use trans::debuginfo; +use trans::glue; +use trans::type_::Type; use middle::ty; use std::fmt; use syntax::ast; diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc_trans/trans/closure.rs similarity index 98% rename from src/librustc/middle/trans/closure.rs rename to src/librustc_trans/trans/closure.rs index ab7b1aa33e7..139087507ff 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -11,23 +11,23 @@ use back::abi; use back::link::mangle_internal_name_by_path_and_seq; -use driver::config::FullDebugInfo; use llvm::ValueRef; use middle::def; use middle::mem_categorization::Typer; -use middle::trans::adt; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::cleanup::{CleanupMethods, ScopeId}; -use middle::trans::common::*; -use middle::trans::datum::{Datum, DatumBlock, Expr, Lvalue, rvalue_scratch_datum}; -use middle::trans::debuginfo; -use middle::trans::expr; -use middle::trans::monomorphize::MonoId; -use middle::trans::type_of::*; -use middle::trans::type_::Type; +use trans::adt; +use trans::base::*; +use trans::build::*; +use trans::cleanup::{CleanupMethods, ScopeId}; +use trans::common::*; +use trans::datum::{Datum, DatumBlock, Expr, Lvalue, rvalue_scratch_datum}; +use trans::debuginfo; +use trans::expr; +use trans::monomorphize::MonoId; +use trans::type_of::*; +use trans::type_::Type; use middle::ty; use middle::subst::{Subst, Substs}; +use session::config::FullDebugInfo; use util::ppaux::Repr; use util::ppaux::ty_to_string; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc_trans/trans/common.rs similarity index 98% rename from src/librustc/middle/trans/common.rs rename to src/librustc_trans/trans/common.rs index e4bfdf74d85..d06cfa4a027 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -14,7 +14,7 @@ pub use self::ExprOrMethodCall::*; -use driver::session::Session; +use session::Session; use llvm; use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef}; use llvm::{True, False, Bool}; @@ -23,14 +23,14 @@ use middle::lang_items::LangItem; use middle::mem_categorization as mc; use middle::subst; use middle::subst::Subst; -use middle::trans::base; -use middle::trans::build; -use middle::trans::cleanup; -use middle::trans::datum; -use middle::trans::debuginfo; -use middle::trans::machine; -use middle::trans::type_::Type; -use middle::trans::type_of; +use trans::base; +use trans::build; +use trans::cleanup; +use trans::datum; +use trans::debuginfo; +use trans::machine; +use trans::type_::Type; +use trans::type_of; use middle::traits; use middle::ty; use middle::ty_fold; @@ -53,7 +53,7 @@ use syntax::codemap::Span; use syntax::parse::token::InternedString; use syntax::parse::token; -pub use middle::trans::context::CrateContext; +pub use trans::context::CrateContext; fn type_is_newtype_immediate(ccx: &CrateContext, ty: ty::t) -> bool { match ty::get(ty).sty { @@ -69,8 +69,8 @@ fn type_is_newtype_immediate(ccx: &CrateContext, ty: ty::t) -> bool { } pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool { - use middle::trans::machine::llsize_of_alloc; - use middle::trans::type_of::sizing_type_of; + use trans::machine::llsize_of_alloc; + use trans::type_of::sizing_type_of; let tcx = ccx.tcx(); let simple = ty::type_is_scalar(ty) || @@ -98,8 +98,8 @@ pub fn type_is_zero_size(ccx: &CrateContext, ty: ty::t) -> bool { * Identify types which have size zero at runtime. */ - use middle::trans::machine::llsize_of_alloc; - use middle::trans::type_of::sizing_type_of; + use trans::machine::llsize_of_alloc; + use trans::type_of::sizing_type_of; let llty = sizing_type_of(ccx, ty); llsize_of_alloc(ccx, llty) == 0 } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc_trans/trans/consts.rs similarity index 98% rename from src/librustc/middle/trans/consts.rs rename to src/librustc_trans/trans/consts.rs index 18c9ef98244..545b12d2267 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -17,18 +17,18 @@ use llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, use metadata::csearch; use middle::const_eval; use middle::def; -use middle::trans::adt; -use middle::trans::base; -use middle::trans::base::push_ctxt; -use middle::trans::closure; -use middle::trans::common::*; -use middle::trans::consts; -use middle::trans::expr; -use middle::trans::inline; -use middle::trans::machine; -use middle::trans::type_::Type; -use middle::trans::type_of; -use middle::trans::debuginfo; +use trans::adt; +use trans::base; +use trans::base::push_ctxt; +use trans::closure; +use trans::common::*; +use trans::consts; +use trans::expr; +use trans::inline; +use trans::machine; +use trans::type_::Type; +use trans::type_of; +use trans::debuginfo; use middle::ty; use util::ppaux::{Repr, ty_to_string}; diff --git a/src/librustc/middle/trans/context.rs b/src/librustc_trans/trans/context.rs similarity index 98% rename from src/librustc/middle/trans/context.rs rename to src/librustc_trans/trans/context.rs index ded41e56a16..c2c1f8bb5f5 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use driver::config::NoDebugInfo; -use driver::session::Session; use llvm; use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef}; use llvm::{TargetData}; @@ -17,14 +15,16 @@ use llvm::mk_target_data; use metadata::common::LinkMeta; use middle::resolve; use middle::traits; -use middle::trans::adt; -use middle::trans::base; -use middle::trans::builder::Builder; -use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res}; -use middle::trans::debuginfo; -use middle::trans::monomorphize::MonoId; -use middle::trans::type_::{Type, TypeNames}; +use trans::adt; +use trans::base; +use trans::builder::Builder; +use trans::common::{ExternMap,tydesc_info,BuilderRef_res}; +use trans::debuginfo; +use trans::monomorphize::MonoId; +use trans::type_::{Type, TypeNames}; use middle::ty; +use session::config::NoDebugInfo; +use session::Session; use util::ppaux::Repr; use util::sha2::Sha256; use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap, FnvHashSet}; diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs similarity index 97% rename from src/librustc/middle/trans/controlflow.rs rename to src/librustc_trans/trans/controlflow.rs index d1908eb62f8..10a73033b64 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -9,26 +9,26 @@ // except according to those terms. use llvm::*; -use driver::config::FullDebugInfo; use middle::def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; -use middle::trans::_match; -use middle::trans::adt; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::cleanup; -use middle::trans::common::*; -use middle::trans::consts; -use middle::trans::datum; -use middle::trans::debuginfo; -use middle::trans::expr; -use middle::trans::meth; -use middle::trans::type_::Type; -use middle::trans; +use trans::_match; +use trans::adt; +use trans::base::*; +use trans::build::*; +use trans::callee; +use trans::cleanup::CleanupMethods; +use trans::cleanup; +use trans::common::*; +use trans::consts; +use trans::datum; +use trans::debuginfo; +use trans::expr; +use trans::meth; +use trans::type_::Type; +use trans; use middle::ty; use middle::typeck::MethodCall; +use session::config::FullDebugInfo; use util::ppaux::Repr; use util::ppaux; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc_trans/trans/datum.rs similarity index 98% rename from src/librustc/middle/trans/datum.rs rename to src/librustc_trans/trans/datum.rs index 4fba0e40510..c4be6bf27b8 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -17,14 +17,14 @@ pub use self::Expr::*; pub use self::RvalueMode::*; use llvm::ValueRef; -use middle::trans::base::*; -use middle::trans::build::Load; -use middle::trans::common::*; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::expr; -use middle::trans::tvec; -use middle::trans::type_of; +use trans::base::*; +use trans::build::Load; +use trans::common::*; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::expr; +use trans::tvec; +use trans::type_of; use middle::ty; use util::ppaux::{ty_to_string}; diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc_trans/trans/debuginfo.rs similarity index 99% rename from src/librustc/middle/trans/debuginfo.rs rename to src/librustc_trans/trans/debuginfo.rs index de8e80b0275..e3e36ee53fd 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc_trans/trans/debuginfo.rs @@ -192,22 +192,21 @@ use self::RecursiveTypeDescription::*; use self::EnumDiscriminantInfo::*; use self::DebugLocation::*; -use driver::config; -use driver::config::{FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use llvm; use llvm::{ModuleRef, ContextRef, ValueRef}; use llvm::debuginfo::*; use metadata::csearch; use middle::subst::{mod, Subst}; -use middle::trans::adt; -use middle::trans::common::*; -use middle::trans::machine; -use middle::trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef}; -use middle::trans::type_of; -use middle::trans::type_::Type; -use middle::trans; +use trans::adt; +use trans::common::*; +use trans::machine; +use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef}; +use trans::type_of; +use trans::type_::Type; +use trans; use middle::ty; use middle::pat_util; +use session::config::{mod, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet}; use util::ppaux; diff --git a/src/librustc/middle/trans/doc.rs b/src/librustc_trans/trans/doc.rs similarity index 100% rename from src/librustc/middle/trans/doc.rs rename to src/librustc_trans/trans/doc.rs diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc_trans/trans/expr.rs similarity index 99% rename from src/librustc/middle/trans/expr.rs rename to src/librustc_trans/trans/expr.rs index 4a2ea9c5f63..2b7c3d0c24f 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -44,27 +44,27 @@ use middle::def; use middle::mem_categorization::Typer; use middle::subst; use middle::subst::Subst; -use middle::trans::_match; -use middle::trans::adt; -use middle::trans::asm; -use middle::trans::base::*; -use middle::trans::base; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::closure; -use middle::trans::common::*; -use middle::trans::consts; -use middle::trans::controlflow; -use middle::trans::datum::*; -use middle::trans::debuginfo; -use middle::trans::glue; -use middle::trans::machine; -use middle::trans::meth; -use middle::trans::inline; -use middle::trans::tvec; -use middle::trans::type_of; +use trans::_match; +use trans::adt; +use trans::asm; +use trans::base::*; +use trans::base; +use trans::build::*; +use trans::callee; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::closure; +use trans::common::*; +use trans::consts; +use trans::controlflow; +use trans::datum::*; +use trans::debuginfo; +use trans::glue; +use trans::machine; +use trans::meth; +use trans::inline; +use trans::tvec; +use trans::type_of; use middle::ty::{struct_fields, tup_fields}; use middle::ty::{AdjustDerefRef, AdjustAddEnv, AutoUnsafe}; use middle::ty::{AutoPtr}; @@ -73,8 +73,8 @@ use middle::typeck; use middle::typeck::MethodCall; use util::common::indenter; use util::ppaux::Repr; -use middle::trans::machine::{llsize_of, llsize_of_alloc}; -use middle::trans::type_::Type; +use trans::machine::{llsize_of, llsize_of_alloc}; +use trans::type_::Type; use syntax::ast; use syntax::codemap; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs similarity index 99% rename from src/librustc/middle/trans/foreign.rs rename to src/librustc_trans/trans/foreign.rs index 940319d050b..3ca37f9e355 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -13,15 +13,15 @@ use back::{link}; use llvm::{ValueRef, CallConv, get_param}; use llvm; use middle::weak_lang_items; -use middle::trans::base::{llvm_linkage_by_name, push_ctxt}; -use middle::trans::base; -use middle::trans::build::*; -use middle::trans::cabi; -use middle::trans::common::*; -use middle::trans::machine; -use middle::trans::type_::Type; -use middle::trans::type_of::*; -use middle::trans::type_of; +use trans::base::{llvm_linkage_by_name, push_ctxt}; +use trans::base; +use trans::build::*; +use trans::cabi; +use trans::common::*; +use trans::machine; +use trans::type_::Type; +use trans::type_of::*; +use trans::type_of; use middle::ty::FnSig; use middle::ty; use middle::subst::Subst; diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc_trans/trans/glue.rs similarity index 98% rename from src/librustc/middle/trans/glue.rs rename to src/librustc_trans/trans/glue.rs index 6c3e3f4364e..cceea96d4c1 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -20,20 +20,20 @@ use llvm; use middle::lang_items::ExchangeFreeFnLangItem; use middle::subst; use middle::subst::Subst; -use middle::trans::adt; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::common::*; -use middle::trans::datum; -use middle::trans::debuginfo; -use middle::trans::expr; -use middle::trans::machine::*; -use middle::trans::tvec; -use middle::trans::type_::Type; -use middle::trans::type_of::{type_of, sizing_type_of, align_of}; +use trans::adt; +use trans::base::*; +use trans::build::*; +use trans::callee; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::common::*; +use trans::datum; +use trans::debuginfo; +use trans::expr; +use trans::machine::*; +use trans::tvec; +use trans::type_::Type; +use trans::type_of::{type_of, sizing_type_of, align_of}; use middle::ty; use util::ppaux::{ty_to_short_str, Repr}; use util::ppaux; diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc_trans/trans/inline.rs similarity index 98% rename from src/librustc/middle/trans/inline.rs rename to src/librustc_trans/trans/inline.rs index 2b54ac68ffa..51d839c3bee 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -11,8 +11,8 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use metadata::csearch; use middle::astencode; -use middle::trans::base::{push_ctxt, trans_item, get_item_val, trans_fn}; -use middle::trans::common::*; +use trans::base::{push_ctxt, trans_item, get_item_val, trans_fn}; +use trans::common::*; use middle::ty; use syntax::ast; diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs similarity index 98% rename from src/librustc/middle/trans/intrinsic.rs rename to src/librustc_trans/trans/intrinsic.rs index 13a10258f80..3bc6c30f8d6 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -14,20 +14,20 @@ use llvm; use llvm::{SequentiallyConsistent, Acquire, Release, AtomicXchg, ValueRef}; use middle::subst; use middle::subst::FnSpace; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::common::*; -use middle::trans::datum::*; -use middle::trans::expr; -use middle::trans::glue; -use middle::trans::type_of::*; -use middle::trans::type_of; -use middle::trans::machine; -use middle::trans::machine::llsize_of; -use middle::trans::type_::Type; +use trans::base::*; +use trans::build::*; +use trans::callee; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::common::*; +use trans::datum::*; +use trans::expr; +use trans::glue; +use trans::type_of::*; +use trans::type_of; +use trans::machine; +use trans::machine::llsize_of; +use trans::type_::Type; use middle::ty; use syntax::abi::RustIntrinsic; use syntax::ast; diff --git a/src/librustc/middle/trans/llrepr.rs b/src/librustc_trans/trans/llrepr.rs similarity index 93% rename from src/librustc/middle/trans/llrepr.rs rename to src/librustc_trans/trans/llrepr.rs index 28e97e0f658..dcf3a532157 100644 --- a/src/librustc/middle/trans/llrepr.rs +++ b/src/librustc_trans/trans/llrepr.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::trans::context::CrateContext; -use middle::trans::type_::Type; +use trans::context::CrateContext; +use trans::type_::Type; use llvm::ValueRef; pub trait LlvmRepr for Sized? { diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc_trans/trans/machine.rs similarity index 98% rename from src/librustc/middle/trans/machine.rs rename to src/librustc_trans/trans/machine.rs index f576dcc60c0..41738f1e58f 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc_trans/trans/machine.rs @@ -15,9 +15,9 @@ use llvm; use llvm::{ValueRef}; use llvm::False; -use middle::trans::common::*; +use trans::common::*; -use middle::trans::type_::Type; +use trans::type_::Type; pub type llbits = u64; pub type llsize = u64; diff --git a/src/librustc/middle/trans/macros.rs b/src/librustc_trans/trans/macros.rs similarity index 100% rename from src/librustc/middle/trans/macros.rs rename to src/librustc_trans/trans/macros.rs diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc_trans/trans/meth.rs similarity index 98% rename from src/librustc/middle/trans/meth.rs rename to src/librustc_trans/trans/meth.rs index 3cd16d3b018..55ecd8a6554 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -17,19 +17,19 @@ use middle::subst::{Subst,Substs}; use middle::subst::VecPerParamSpace; use middle::subst; use middle::traits; -use middle::trans::base::*; -use middle::trans::build::*; -use middle::trans::callee::*; -use middle::trans::callee; -use middle::trans::cleanup; -use middle::trans::common::*; -use middle::trans::datum::*; -use middle::trans::expr::{SaveIn, Ignore}; -use middle::trans::expr; -use middle::trans::glue; -use middle::trans::machine; -use middle::trans::type_::Type; -use middle::trans::type_of::*; +use trans::base::*; +use trans::build::*; +use trans::callee::*; +use trans::callee; +use trans::cleanup; +use trans::common::*; +use trans::datum::*; +use trans::expr::{SaveIn, Ignore}; +use trans::expr; +use trans::glue; +use trans::machine; +use trans::type_::Type; +use trans::type_of::*; use middle::ty; use middle::typeck; use middle::typeck::MethodCall; diff --git a/src/librustc/middle/trans/mod.rs b/src/librustc_trans/trans/mod.rs similarity index 100% rename from src/librustc/middle/trans/mod.rs rename to src/librustc_trans/trans/mod.rs diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs similarity index 97% rename from src/librustc/middle/trans/monomorphize.rs rename to src/librustc_trans/trans/monomorphize.rs index 1e8d54b249f..077c1337a44 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -9,17 +9,17 @@ // except according to those terms. use back::link::exported_name; -use driver::session; +use session; use llvm::ValueRef; use llvm; use middle::subst; use middle::subst::Subst; -use middle::trans::base::{set_llvm_fn_attrs, set_inline_hint}; -use middle::trans::base::{trans_enum_variant, push_ctxt, get_item_val}; -use middle::trans::base::{trans_fn, decl_internal_rust_fn}; -use middle::trans::base; -use middle::trans::common::*; -use middle::trans::foreign; +use trans::base::{set_llvm_fn_attrs, set_inline_hint}; +use trans::base::{trans_enum_variant, push_ctxt, get_item_val}; +use trans::base::{trans_fn, decl_internal_rust_fn}; +use trans::base; +use trans::common::*; +use trans::foreign; use middle::ty; use util::ppaux::Repr; diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs similarity index 97% rename from src/librustc/middle/trans/tvec.rs rename to src/librustc_trans/trans/tvec.rs index cf1aeca7916..0590d7c785a 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -13,20 +13,20 @@ use back::abi; use llvm; use llvm::{ValueRef}; -use middle::trans::base::*; -use middle::trans::base; -use middle::trans::build::*; -use middle::trans::cleanup; -use middle::trans::cleanup::CleanupMethods; -use middle::trans::common::*; -use middle::trans::datum::*; -use middle::trans::expr::{Dest, Ignore, SaveIn}; -use middle::trans::expr; -use middle::trans::glue; -use middle::trans::machine; -use middle::trans::machine::{nonzero_llsize_of, llsize_of_alloc}; -use middle::trans::type_::Type; -use middle::trans::type_of; +use trans::base::*; +use trans::base; +use trans::build::*; +use trans::cleanup; +use trans::cleanup::CleanupMethods; +use trans::common::*; +use trans::datum::*; +use trans::expr::{Dest, Ignore, SaveIn}; +use trans::expr; +use trans::glue; +use trans::machine; +use trans::machine::{nonzero_llsize_of, llsize_of_alloc}; +use trans::type_::Type; +use trans::type_of; use middle::ty; use util::ppaux::ty_to_string; diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc_trans/trans/type_.rs similarity index 99% rename from src/librustc/middle/trans/type_.rs rename to src/librustc_trans/trans/type_.rs index 69861290b8d..0662909e40f 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -14,7 +14,7 @@ use llvm; use llvm::{TypeRef, Bool, False, True, TypeKind, ValueRef}; use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128}; -use middle::trans::context::CrateContext; +use trans::context::CrateContext; use util::nodemap::FnvHashMap; use syntax::ast; diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs similarity index 99% rename from src/librustc/middle/trans/type_of.rs rename to src/librustc_trans/trans/type_of.rs index 1fff29255da..5fa21984637 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -13,15 +13,15 @@ pub use self::named_ty::*; use middle::subst; -use middle::trans::adt; -use middle::trans::common::*; -use middle::trans::foreign; -use middle::trans::machine; +use trans::adt; +use trans::common::*; +use trans::foreign; +use trans::machine; use middle::ty; use util::ppaux; use util::ppaux::Repr; -use middle::trans::type_::Type; +use trans::type_::Type; use std::num::Int; use syntax::abi; diff --git a/src/librustc/middle/trans/value.rs b/src/librustc_trans/trans/value.rs similarity index 98% rename from src/librustc/middle/trans/value.rs rename to src/librustc_trans/trans/value.rs index dfa4ae6b285..8d74275c92a 100644 --- a/src/librustc/middle/trans/value.rs +++ b/src/librustc_trans/trans/value.rs @@ -10,8 +10,8 @@ use llvm; use llvm::{UseRef, ValueRef}; -use middle::trans::basic_block::BasicBlock; -use middle::trans::common::Block; +use trans::basic_block::BasicBlock; +use trans::common::Block; use libc::c_uint; pub struct Value(pub ValueRef); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 98eeada6f5d..d622965dac7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -38,8 +38,8 @@ use syntax::parse::token::InternedString; use syntax::parse::token; use syntax::ptr::P; -use rustc::back::link; -use rustc::driver::driver; +use rustc_trans::back::link; +use rustc_trans::driver::driver; use rustc::metadata::cstore; use rustc::metadata::csearch; use rustc::metadata::decoder; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 0a748f7e798..21242e6f1e4 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -9,10 +9,11 @@ // except according to those terms. pub use self::MaybeTyped::*; -use rustc::driver::{config, driver, session}; +use rustc_trans::driver::driver; +use rustc::session::{mod, config}; use rustc::middle::{privacy, ty}; use rustc::lint; -use rustc::back::link; +use rustc_trans::back::link; use syntax::{ast, ast_map, codemap, diagnostic}; @@ -93,7 +94,7 @@ pub fn run_core(libs: Vec, cfgs: Vec, externs: Externs, crate_types: vec!(config::CrateTypeRlib), lint_opts: vec!((warning_lint, lint::Allow)), externs: externs, - target_triple: triple.unwrap_or(driver::host_triple().to_string()), + target_triple: triple.unwrap_or(config::host_triple().to_string()), cfg: config::parse_cfgspecs(cfgs), ..config::basic_options().clone() }; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 7343d674972..69da6285b6d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -22,6 +22,7 @@ extern crate arena; extern crate getopts; extern crate libc; extern crate rustc; +extern crate rustc_trans; extern crate serialize; extern crate syntax; extern crate "test" as testing; @@ -155,7 +156,7 @@ pub fn main_args(args: &[String]) -> int { usage(args[0].as_slice()); return 0; } else if matches.opt_present("version") { - match rustc::driver::version("rustdoc", &matches) { + match rustc_trans::driver::version("rustdoc", &matches) { Some(err) => { println!("{}", err); return 1 diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 93662b3b63e..2dc1bcf776e 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -19,10 +19,8 @@ use std::string::String; use std::collections::{HashSet, HashMap}; use testing; -use rustc::back::write; -use rustc::driver::config; -use rustc::driver::driver; -use rustc::driver::session; +use rustc::session::{mod, config}; +use rustc_trans::driver::driver; use syntax::ast; use syntax::codemap::{CodeMap, dummy_spanned}; use syntax::diagnostic; @@ -119,7 +117,7 @@ fn runtest(test: &str, cratename: &str, libs: Vec, externs: core::Externs, maybe_sysroot: Some(os::self_exe_path().unwrap().dir_path()), addl_lib_search_paths: RefCell::new(libs), crate_types: vec!(config::CrateTypeExecutable), - output_types: vec!(write::OutputTypeExe), + output_types: vec!(config::OutputTypeExe), no_trans: no_run, externs: externs, cg: config::CodegenOptions {