Move trans, back, driver, and back into a new crate, rustc_trans. Reduces memory usage significantly and opens opportunities for more parallel compilation.

This commit is contained in:
Niko Matsakis 2014-11-15 20:30:33 -05:00
parent f637f1c5a2
commit dc6e414e6f
80 changed files with 640 additions and 532 deletions

View File

@ -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.

View File

@ -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() }

View File

@ -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.

View File

@ -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);
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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};

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<back::write::OutputType> ,
pub output_types: Vec<OutputType> ,
// 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<String>
}
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;

View File

@ -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<T>(sess: &Session, opt: Option<T>, 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);
}

View File

@ -0,0 +1 @@
See the README.txt in ../librustc.

View File

@ -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;

View File

@ -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;

View File

@ -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() {

View File

@ -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,
}
}

View File

@ -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<String>) -> 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<String> {
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) {
}
}
}

View File

@ -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};

87
src/librustc_trans/lib.rs Normal file
View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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> {

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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 }

View File

@ -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);

View File

@ -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};

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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::*;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
}

View File

@ -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};

View File

@ -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};

View File

@ -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;

View File

@ -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};

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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? {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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<Path>, cfgs: Vec<String>, 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()
};

View File

@ -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

View File

@ -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<Path>, 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 {