From 40e0989b8b822b3e3d22d41171e84b49dc4d0bfd Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 12 Aug 2016 16:11:38 -0700 Subject: [PATCH] Re-export common types in the cretonne::ir module. Clients should not have to navigate the ir sub-modules to find commonly used types. --- src/libcretonne/cfg.rs | 3 +-- src/libcretonne/dominator_tree.rs | 2 +- src/libcretonne/ir/dfg.rs | 9 +++++---- src/libcretonne/ir/instructions.rs | 7 ++++--- src/libcretonne/ir/jumptable.rs | 2 +- src/libcretonne/ir/layout.rs | 2 +- src/libcretonne/ir/mod.rs | 12 +++++++----- src/libcretonne/isa/mod.rs | 3 +-- src/libcretonne/isa/riscv/mod.rs | 3 +-- src/libcretonne/test_utils/make_inst.rs | 6 +++--- src/libcretonne/write.rs | 4 +--- src/libreader/lexer.rs | 4 ++-- src/libreader/parser.rs | 11 ++++++----- src/tools/tests/cfg_traversal.rs | 2 +- src/tools/tests/dominator_tree.rs | 2 +- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/libcretonne/cfg.rs b/src/libcretonne/cfg.rs index 022c3372e4..8397ca5166 100644 --- a/src/libcretonne/cfg.rs +++ b/src/libcretonne/cfg.rs @@ -22,8 +22,7 @@ //! Here Ebb1 and Ebb2 would each have a single predecessor denoted as (Ebb0, `brz vx, Ebb1`) //! and (Ebb0, `jmp Ebb2`) respectively. -use ir::Function; -use ir::entities::{Inst, Ebb}; +use ir::{Function, Inst, Ebb}; use ir::instructions::BranchInfo; use entity_map::{EntityMap, Keys}; use std::collections::HashSet; diff --git a/src/libcretonne/dominator_tree.rs b/src/libcretonne/dominator_tree.rs index 8420bcf541..5909f68745 100644 --- a/src/libcretonne/dominator_tree.rs +++ b/src/libcretonne/dominator_tree.rs @@ -1,7 +1,7 @@ /// ! A Dominator Tree represented as mappings of Ebbs to their immediate dominator. use cfg::*; -use ir::entities::Ebb; +use ir::Ebb; use entity_map::{EntityMap, Keys}; pub struct DominatorTree { diff --git a/src/libcretonne/ir/dfg.rs b/src/libcretonne/ir/dfg.rs index 4776220a6f..3fc4d596eb 100644 --- a/src/libcretonne/ir/dfg.rs +++ b/src/libcretonne/ir/dfg.rs @@ -1,9 +1,10 @@ //! Data flow graph tracking Instructions, Values, and EBBs. -use entity_map::{EntityMap, PrimaryEntityData}; -use ir::entities::{Ebb, Inst, Value, NO_VALUE, ExpandedValue}; +use ir::{Ebb, Inst, Value, Type}; +use ir::entities::{NO_VALUE, ExpandedValue}; use ir::instructions::InstructionData; -use ir::types::Type; +use entity_map::{EntityMap, PrimaryEntityData}; + use std::ops::{Index, IndexMut}; use std::u16; @@ -359,7 +360,7 @@ impl EbbData { mod tests { use super::*; use ir::types; - use ir::instructions::{Opcode, InstructionData}; + use ir::{Opcode, InstructionData}; #[test] fn make_inst() { diff --git a/src/libcretonne/ir/instructions.rs b/src/libcretonne/ir/instructions.rs index 9d5c59eb7d..eee47b8d66 100644 --- a/src/libcretonne/ir/instructions.rs +++ b/src/libcretonne/ir/instructions.rs @@ -10,10 +10,11 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use std::ops::{Deref, DerefMut}; -use ir::entities::*; -use ir::immediates::*; +use ir::{Value, Type, Ebb, JumpTable}; +use ir::entities::NO_VALUE; +use ir::immediates::{Imm64, Ieee32, Ieee64}; use ir::condcodes::*; -use ir::types::{self, Type}; +use ir::types; // Include code generated by `meta/gen_instr.py`. This file contains: // diff --git a/src/libcretonne/ir/jumptable.rs b/src/libcretonne/ir/jumptable.rs index 31ea86f643..8a2308fbe1 100644 --- a/src/libcretonne/ir/jumptable.rs +++ b/src/libcretonne/ir/jumptable.rs @@ -120,7 +120,7 @@ impl Display for JumpTableData { #[cfg(test)] mod tests { use super::JumpTableData; - use ir::entities::Ebb; + use ir::Ebb; use entity_map::EntityRef; #[test] diff --git a/src/libcretonne/ir/layout.rs b/src/libcretonne/ir/layout.rs index af21ee5234..a983ca178f 100644 --- a/src/libcretonne/ir/layout.rs +++ b/src/libcretonne/ir/layout.rs @@ -248,7 +248,7 @@ impl<'a> Iterator for Insts<'a> { mod tests { use super::Layout; use entity_map::EntityRef; - use ir::entities::{Ebb, Inst}; + use ir::{Ebb, Inst}; #[test] fn append_ebb() { diff --git a/src/libcretonne/ir/mod.rs b/src/libcretonne/ir/mod.rs index f0e8eda741..30fb4d9323 100644 --- a/src/libcretonne/ir/mod.rs +++ b/src/libcretonne/ir/mod.rs @@ -9,14 +9,16 @@ pub mod jumptable; pub mod dfg; pub mod layout; -use ir::types::{FunctionName, Signature}; -use entity_map::{EntityRef, EntityMap, PrimaryEntityData}; -use ir::entities::{StackSlot, JumpTable}; +pub use ir::types::{Type, FunctionName, Signature}; +pub use ir::entities::{Ebb, Inst, Value, StackSlot, JumpTable}; +pub use ir::instructions::{Opcode, InstructionData}; +pub use ir::dfg::DataFlowGraph; +pub use ir::layout::Layout; + use ir::jumptable::JumpTableData; -use ir::dfg::DataFlowGraph; -use ir::layout::Layout; use std::fmt::{self, Debug, Display, Formatter}; use std::ops::Index; +use entity_map::{EntityRef, EntityMap, PrimaryEntityData}; /// A function. pub struct Function { diff --git a/src/libcretonne/isa/mod.rs b/src/libcretonne/isa/mod.rs index 43834be3ef..a84efdbc52 100644 --- a/src/libcretonne/isa/mod.rs +++ b/src/libcretonne/isa/mod.rs @@ -43,8 +43,7 @@ pub mod riscv; use settings; -use ir::dfg::DataFlowGraph; -use ir::entities::Inst; +use ir::{Inst, DataFlowGraph}; /// Look for a supported ISA with the given `name`. /// Return a builder that can create a corresponding `TargetIsa`. diff --git a/src/libcretonne/isa/riscv/mod.rs b/src/libcretonne/isa/riscv/mod.rs index 4938a7ad28..b9ffa4925c 100644 --- a/src/libcretonne/isa/riscv/mod.rs +++ b/src/libcretonne/isa/riscv/mod.rs @@ -5,8 +5,7 @@ pub mod settings; use super::super::settings as shared_settings; use super::Builder as IsaBuilder; use super::{TargetIsa, Encoding}; -use ir::dfg::DataFlowGraph; -use ir::entities::Inst; +use ir::{Inst, DataFlowGraph}; #[allow(dead_code)] struct Isa { diff --git a/src/libcretonne/test_utils/make_inst.rs b/src/libcretonne/test_utils/make_inst.rs index adc45cdb67..eb75b2fab3 100644 --- a/src/libcretonne/test_utils/make_inst.rs +++ b/src/libcretonne/test_utils/make_inst.rs @@ -1,8 +1,8 @@ //! Helper functions for generating dummy instructions. -use ir::Function; -use ir::entities::{Ebb, Inst, NO_VALUE}; -use ir::instructions::{InstructionData, Opcode, VariableArgs, JumpData, BranchData}; +use ir::{Function, Ebb, Inst, Opcode}; +use ir::entities::NO_VALUE; +use ir::instructions::{InstructionData, VariableArgs, JumpData, BranchData}; use ir::types; pub fn jump(func: &mut Function, dest: Ebb) -> Inst { diff --git a/src/libcretonne/write.rs b/src/libcretonne/write.rs index e7b35e806a..e21c93c554 100644 --- a/src/libcretonne/write.rs +++ b/src/libcretonne/write.rs @@ -4,10 +4,8 @@ //! equivalent textual representation. This textual representation can be read back by the //! `cretonne-reader` crate. +use ir::{Function, Ebb, Inst, Value, Type}; use std::io::{self, Write}; -use ir::Function; -use ir::entities::{Inst, Ebb, Value}; -use ir::types::Type; pub type Result = io::Result<()>; diff --git a/src/libreader/lexer.rs b/src/libreader/lexer.rs index a19c14adfd..150c38da19 100644 --- a/src/libreader/lexer.rs +++ b/src/libreader/lexer.rs @@ -7,7 +7,7 @@ use std::str::CharIndices; use cretonne::ir::types; -use cretonne::ir::entities::{Value, Ebb}; +use cretonne::ir::{Value, Ebb}; /// The location of a `Token` or `Error`. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -374,7 +374,7 @@ impl<'a> Lexer<'a> { mod tests { use super::*; use cretonne::ir::types; - use cretonne::ir::entities::{Value, Ebb}; + use cretonne::ir::{Value, Ebb}; fn token<'a>(token: Token<'a>, line: usize) -> Option, LocatedError>> { Some(super::token(token, Location { line_number: line })) diff --git a/src/libreader/parser.rs b/src/libreader/parser.rs index 41742b54e7..0fc0ff6ab4 100644 --- a/src/libreader/parser.rs +++ b/src/libreader/parser.rs @@ -11,12 +11,13 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use std::u32; use lexer::{self, Lexer, Token}; -use cretonne::ir::types::{Type, VOID, FunctionName, Signature, ArgumentType, ArgumentExtension}; +use cretonne::ir::{Function, Ebb, Inst, Opcode, Value, Type, FunctionName, StackSlotData, + JumpTable, StackSlot}; +use cretonne::ir::types::{VOID, Signature, ArgumentType, ArgumentExtension}; use cretonne::ir::immediates::{Imm64, Ieee32, Ieee64}; -use cretonne::ir::entities::*; -use cretonne::ir::instructions::{Opcode, InstructionFormat, InstructionData, VariableArgs, - JumpData, BranchData, ReturnData}; -use cretonne::ir::{Function, StackSlotData}; +use cretonne::ir::entities::{NO_EBB, NO_VALUE}; +use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs, JumpData, + BranchData, ReturnData}; use cretonne::ir::jumptable::JumpTableData; pub use lexer::Location; diff --git a/src/tools/tests/cfg_traversal.rs b/src/tools/tests/cfg_traversal.rs index 8908b279d8..03ed5bd148 100644 --- a/src/tools/tests/cfg_traversal.rs +++ b/src/tools/tests/cfg_traversal.rs @@ -2,7 +2,7 @@ extern crate cretonne; extern crate cton_reader; use self::cton_reader::parser::Parser; -use self::cretonne::ir::entities::Ebb; +use self::cretonne::ir::Ebb; use self::cretonne::cfg::ControlFlowGraph; use self::cretonne::entity_map::EntityMap; diff --git a/src/tools/tests/dominator_tree.rs b/src/tools/tests/dominator_tree.rs index 8e10307a21..494414b4a9 100644 --- a/src/tools/tests/dominator_tree.rs +++ b/src/tools/tests/dominator_tree.rs @@ -2,7 +2,7 @@ extern crate cretonne; extern crate cton_reader; use self::cton_reader::parser::Parser; -use self::cretonne::ir::entities::Ebb; +use self::cretonne::ir::Ebb; use self::cretonne::cfg::ControlFlowGraph; use self::cretonne::dominator_tree::DominatorTree;