Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the core MIR datastructures to librustc. #29929

Merged
merged 2 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ pub mod middle {
pub mod weak_lang_items;
}

pub mod mir {
pub mod repr;
pub mod tcx;
pub mod visit;
}

pub mod session;

pub mod lint;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/repr.rs → src/librustc/mir/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use rustc::middle::const_eval::ConstVal;
use rustc::middle::def_id::DefId;
use rustc::middle::subst::Substs;
use rustc::middle::ty::{AdtDef, ClosureSubsts, FnOutput, Region, Ty};
use middle::const_eval::ConstVal;
use middle::def_id::DefId;
use middle::subst::Substs;
use middle::ty::{AdtDef, ClosureSubsts, FnOutput, Region, Ty};
use rustc_back::slice;
use rustc_front::hir::InlineAsm;
use syntax::ast::Name;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/tcx/mod.rs → src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* building is complete.
*/

use repr::*;
use rustc::middle::subst::Substs;
use rustc::middle::ty::{self, AdtDef, Ty};
use mir::repr::*;
use middle::subst::Substs;
use middle::ty::{self, AdtDef, Ty};
use rustc_front::hir;

#[derive(Copy, Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/visit.rs → src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use rustc::middle::ty::Region;
use repr::*;
use middle::ty::Region;
use mir::repr::*;

pub trait Visitor<'tcx> {
// Override these, and call `self.super_xxx` to revert back to the
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use build::{BlockAnd, Builder};
use hair::*;
use repr::*;
use rustc::mir::repr::*;
use rustc_front::hir;

impl<'a,'tcx> Builder<'a,'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! Routines for manipulating the control-flow graph.

use build::CFG;
use repr::*;
use rustc::mir::repr::*;
use syntax::codemap::Span;

impl<'tcx> CFG<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use build::Builder;
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr`, yielding a compile-time constant. Assumes that
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/as_lvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

//! See docs in build/expr/mod.rs

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::expr::category::Category;
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr`, yielding an lvalue that we can move from etc.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/as_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

//! See docs in build/expr/mod.rs

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::expr::category::Category;
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr` into a value that can be used as an operand.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

use rustc_data_structures::fnv::FnvHashMap;

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::expr::category::{Category, RvalueFunc};
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr`, yielding an rvalue.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/as_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

//! See docs in build/expr/mod.rs

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::expr::category::Category;
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
/// Compile `expr` into a fresh temporary. This is used when building
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

//! See docs in build/expr/mod.rs

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::expr::category::{Category, RvalueFunc};
use build::scope::LoopScope;
use hair::*;
use repr::*;
use rustc::middle::region::CodeExtent;
use rustc::mir::repr::*;
use syntax::codemap::Span;

impl<'a,'tcx> Builder<'a,'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
//! wrapped up as expressions (e.g. blocks). To make this ergonomic, we use this
//! latter `EvalInto` trait.

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use hair::*;
use repr::*;
use rustc::mir::repr::*;

pub trait EvalInto<'tcx> {
fn eval_into<'a>(self,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
//! includes the high-level algorithm, the submodules contain the
//! details.

use build::{BlockAnd, Builder};
use repr::*;
use build::{BlockAnd, BlockAndExtension, Builder};
use rustc_data_structures::fnv::FnvHashMap;
use rustc::middle::const_eval::ConstVal;
use rustc::middle::region::CodeExtent;
use rustc::middle::ty::{AdtDef, Ty};
use rustc::mir::repr::*;
use hair::*;
use syntax::ast::{Name, NodeId};
use syntax::codemap::Span;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/matches/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
//! sort of test: for example, testing which variant an enum is, or
//! testing a value against a constant.

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::matches::{Binding, MatchPair, Candidate};
use hair::*;
use repr::*;
use rustc::mir::repr::*;

use std::mem;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use build::Builder;
use build::matches::{Candidate, MatchPair, Test, TestKind};
use hair::*;
use repr::*;
use rustc_data_structures::fnv::FnvHashMap;
use rustc::middle::const_eval::ConstVal;
use rustc::middle::ty::{self, Ty};
use rustc::mir::repr::*;
use syntax::codemap::Span;

impl<'a,'tcx> Builder<'a,'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/matches/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use build::matches::MatchPair;
use hair::*;
use repr::*;
use rustc::mir::repr::*;
use std::u32;

impl<'a,'tcx> Builder<'a,'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use build::Builder;
use hair::*;
use repr::*;
use rustc::middle::ty::Ty;
use rustc::mir::repr::*;
use std::u32;
use syntax::codemap::Span;

Expand Down
10 changes: 8 additions & 2 deletions src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
use hair::cx::Cx;
use rustc::middle::region::CodeExtent;
use rustc::middle::ty::{FnOutput, Ty};
use rustc::mir::repr::*;
use rustc_data_structures::fnv::FnvHashMap;
use rustc_front::hir;
use repr::*;

use syntax::ast;
use syntax::codemap::Span;

Expand Down Expand Up @@ -41,7 +42,12 @@ struct CFG<'tcx> {
#[must_use] // if you don't use one of these results, you're leaving a dangling edge
struct BlockAnd<T>(BasicBlock, T);

impl BasicBlock {
trait BlockAndExtension {
fn and<T>(self, v: T) -> BlockAnd<T>;
fn unit(self) -> BlockAnd<()>;
}

impl BlockAndExtension for BasicBlock {
fn and<T>(self, v: T) -> BlockAnd<T> {
BlockAnd(self, v)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ should go to.

*/

use build::{BlockAnd, Builder, CFG};
use repr::*;
use build::{BlockAnd, BlockAndExtension, Builder, CFG};
use rustc::middle::region::CodeExtent;
use rustc::middle::ty::Ty;
use rustc::mir::repr::*;
use syntax::codemap::Span;

pub struct Scope<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use build::{BlockAnd, Builder};
use build::{BlockAnd, BlockAndExtension, Builder};
use hair::*;
use repr::*;
use rustc::mir::repr::*;

impl<'a,'tcx> Builder<'a,'tcx> {
pub fn stmts(&mut self, mut block: BasicBlock, stmts: Vec<StmtRef<'tcx>>) -> BlockAnd<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/graphviz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use dot;
use repr::*;
use rustc::mir::repr::*;
use std::borrow::IntoCow;

#[derive(Copy, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use hair::*;
use repr::*;
use rustc_data_structures::fnv::FnvHashMap;
use hair::cx::Cx;
use hair::cx::block;
Expand All @@ -19,6 +18,7 @@ use rustc::middle::def;
use rustc::middle::region::CodeExtent;
use rustc::middle::pat_util;
use rustc::middle::ty::{self, VariantDef, Ty};
use rustc::mir::repr::*;
use rustc_front::hir;
use rustc_front::util as hir_util;
use syntax::ext::mtwt;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

use hair::*;
use repr::*;
use rustc::mir::repr::*;

use rustc::middle::const_eval::{self, ConstVal};
use rustc::middle::def_id::DefId;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

use hair::*;
use hair::cx::Cx;
use repr::*;
use rustc_data_structures::fnv::FnvHashMap;
use rustc::middle::const_eval;
use rustc::middle::def;
use rustc::middle::pat_util::{pat_is_resolved_const, pat_is_binding};
use rustc::middle::subst::Substs;
use rustc::middle::ty::{self, Ty};
use rustc::mir::repr::*;
use rustc_front::hir;
use syntax::ast;
use syntax::ext::mtwt;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! unit-tested and separated from the Rust source and compiler data
//! structures.

use repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp};
use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp};
use rustc::middle::def_id::DefId;
use rustc::middle::region::CodeExtent;
use rustc::middle::subst::Substs;
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ extern crate syntax;
pub mod build;
pub mod mir_map;
mod hair;
pub mod repr;
mod graphviz;
pub mod transform;
pub mod tcx;
pub mod visit;

2 changes: 1 addition & 1 deletion src/librustc_mir/mir_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern crate rustc_front;
use build;
use dot;
use transform::*;
use repr::Mir;
use rustc::mir::repr::Mir;
use hair::cx::Cx;
use std::fs::File;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//! We want to do this once just before trans, so trans does not have to take
//! care erasing regions all over the place.

use repr::*;
use rustc::middle::ty;
use rustc::mir::repr::*;
use transform::MirPass;
use mir_map::MirMap;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod simplify_cfg;
pub mod erase_regions;
mod util;

use repr::Mir;
use rustc::mir::repr::Mir;

pub trait MirPass<'tcx> {
fn run_on_mir(&mut self, mir: &mut Mir<'tcx>);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/simplify_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use repr::*;
use rustc::middle::const_eval::ConstVal;
use rustc::mir::repr::*;
use std::mem;
use transform::util;
use transform::MirPass;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use repr::*;
use rustc::mir::repr::*;

/// Update basic block ids in all terminators using the given replacements,
/// useful e.g. after removal of several basic blocks to update all terminators
Expand Down
Loading