diff --git a/src/libcretonne/cfg.rs b/src/libcretonne/cfg.rs index e9ecd9d982..c2a2b6dcf2 100644 --- a/src/libcretonne/cfg.rs +++ b/src/libcretonne/cfg.rs @@ -21,8 +21,8 @@ //! and (Ebb0, `jmp Ebb2`) respectively. use repr::Function; -use entities::{Inst, Ebb}; -use instructions::InstructionData; +use repr::entities::{Inst, Ebb}; +use repr::instructions::InstructionData; use std::collections::{BTreeSet, BTreeMap, btree_map}; /// A basic block denoted by its enclosing Ebb and last instruction. diff --git a/src/libcretonne/lib.rs b/src/libcretonne/lib.rs index bc2edd9d59..0b1ac8678e 100644 --- a/src/libcretonne/lib.rs +++ b/src/libcretonne/lib.rs @@ -7,14 +7,7 @@ pub const VERSION: &'static str = env!("CARGO_PKG_VERSION"); -pub mod types; -pub mod condcodes; -pub mod immediates; -pub mod entities; -pub mod instructions; pub mod repr; -pub mod dfg; -pub mod layout; pub mod write; pub mod cfg; diff --git a/src/libcretonne/condcodes.rs b/src/libcretonne/repr/condcodes.rs similarity index 100% rename from src/libcretonne/condcodes.rs rename to src/libcretonne/repr/condcodes.rs diff --git a/src/libcretonne/dfg.rs b/src/libcretonne/repr/dfg.rs similarity index 97% rename from src/libcretonne/dfg.rs rename to src/libcretonne/repr/dfg.rs index 7cfdaa7fbf..29a462f73e 100644 --- a/src/libcretonne/dfg.rs +++ b/src/libcretonne/repr/dfg.rs @@ -1,9 +1,9 @@ //! Data flow graph tracking Instructions, Values, and EBBs. use entity_map::EntityMap; -use entities::{Ebb, Inst, Value, NO_VALUE, ExpandedValue}; -use instructions::InstructionData; -use types::Type; +use repr::entities::{Ebb, Inst, Value, NO_VALUE, ExpandedValue}; +use repr::instructions::InstructionData; +use repr::types::Type; use std::ops::{Index, IndexMut}; use std::u16; @@ -57,7 +57,7 @@ impl DataFlowGraph { /// Get the type of a value. pub fn value_type(&self, v: Value) -> Type { - use entities::ExpandedValue::*; + use repr::entities::ExpandedValue::*; match v.expand() { Direct(i) => self.insts[i].first_type(), Table(i) => { @@ -75,7 +75,7 @@ impl DataFlowGraph { /// This is either the instruction that defined it or the Ebb that has the value as an /// argument. pub fn value_def(&self, v: Value) -> ValueDef { - use entities::ExpandedValue::*; + use repr::entities::ExpandedValue::*; match v.expand() { Direct(inst) => ValueDef::Res(inst, 0), Table(idx) => { @@ -339,8 +339,8 @@ impl EbbData { #[cfg(test)] mod tests { use super::*; - use types; - use instructions::{Opcode, InstructionData}; + use repr::types; + use repr::instructions::{Opcode, InstructionData}; #[test] fn make_inst() { diff --git a/src/libcretonne/entities.rs b/src/libcretonne/repr/entities.rs similarity index 100% rename from src/libcretonne/entities.rs rename to src/libcretonne/repr/entities.rs diff --git a/src/libcretonne/immediates.rs b/src/libcretonne/repr/immediates.rs similarity index 100% rename from src/libcretonne/immediates.rs rename to src/libcretonne/repr/immediates.rs diff --git a/src/libcretonne/instructions.rs b/src/libcretonne/repr/instructions.rs similarity index 99% rename from src/libcretonne/instructions.rs rename to src/libcretonne/repr/instructions.rs index 8ebd63d411..7ebb71bbf4 100644 --- a/src/libcretonne/instructions.rs +++ b/src/libcretonne/repr/instructions.rs @@ -10,10 +10,10 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use std::ops::{Deref, DerefMut}; -use entities::*; -use immediates::*; -use condcodes::*; -use types::{self, Type}; +use repr::entities::*; +use repr::immediates::*; +use repr::condcodes::*; +use repr::types::{self, Type}; // Include code generated by `meta/gen_instr.py`. This file contains: // @@ -560,7 +560,7 @@ mod tests { #[test] fn value_set() { - use types::*; + use repr::types::*; let vts = ValueTypeSet { allow_scalars: true, diff --git a/src/libcretonne/layout.rs b/src/libcretonne/repr/layout.rs similarity index 99% rename from src/libcretonne/layout.rs rename to src/libcretonne/repr/layout.rs index 8ae6657dff..36ee2dacf8 100644 --- a/src/libcretonne/layout.rs +++ b/src/libcretonne/repr/layout.rs @@ -5,7 +5,7 @@ use std::iter::{Iterator, IntoIterator}; use entity_map::{EntityMap, EntityRef}; -use entities::{Ebb, NO_EBB, Inst, NO_INST}; +use repr::entities::{Ebb, NO_EBB, Inst, NO_INST}; /// The `Layout` struct determines the layout of EBBs and instructions in a function. It does not /// contain definitions of instructions or EBBs, but depends on `Inst` and `Ebb` entity references @@ -242,7 +242,7 @@ impl<'a> Iterator for Insts<'a> { mod tests { use super::Layout; use entity_map::EntityRef; - use entities::{Ebb, Inst}; + use repr::entities::{Ebb, Inst}; #[test] fn append_ebb() { diff --git a/src/libcretonne/repr/mod.rs b/src/libcretonne/repr/mod.rs index 6f7075ae4d..a62527ccbe 100644 --- a/src/libcretonne/repr/mod.rs +++ b/src/libcretonne/repr/mod.rs @@ -1,10 +1,18 @@ //! Representation of Cretonne IL functions. -use types::{FunctionName, Signature}; +pub mod entities; +pub mod types; +pub mod condcodes; +pub mod immediates; +pub mod instructions; +pub mod dfg; +pub mod layout; + +use repr::types::{FunctionName, Signature}; use entity_map::EntityRef; -use entities::{Ebb, NO_EBB, StackSlot}; -use dfg::DataFlowGraph; -use layout::Layout; +use repr::entities::{Ebb, NO_EBB, StackSlot}; +use repr::dfg::DataFlowGraph; +use repr::layout::Layout; use std::fmt::{self, Debug, Display, Formatter}; use std::ops::Index; diff --git a/src/libcretonne/types.rs b/src/libcretonne/repr/types.rs similarity index 100% rename from src/libcretonne/types.rs rename to src/libcretonne/repr/types.rs diff --git a/src/libcretonne/test_utils/make_inst.rs b/src/libcretonne/test_utils/make_inst.rs index 2f45a09cba..00955a5be5 100644 --- a/src/libcretonne/test_utils/make_inst.rs +++ b/src/libcretonne/test_utils/make_inst.rs @@ -1,9 +1,9 @@ //! Helper functions for generating dummy instructions. use repr::Function; -use entities::{Ebb, Inst, NO_VALUE}; -use instructions::{InstructionData, Opcode, VariableArgs, JumpData, BranchData}; -use types; +use repr::entities::{Ebb, Inst, NO_VALUE}; +use repr::instructions::{InstructionData, Opcode, VariableArgs, JumpData, BranchData}; +use repr::types; pub fn jump(func: &mut Function, dest: Ebb) -> Inst { func.dfg.make_inst(InstructionData::Jump { diff --git a/src/libcretonne/write.rs b/src/libcretonne/write.rs index 10181e0f63..5b66b81065 100644 --- a/src/libcretonne/write.rs +++ b/src/libcretonne/write.rs @@ -6,8 +6,8 @@ use std::io::{self, Write}; use repr::Function; -use entities::{Inst, Ebb, Value}; -use types::Type; +use repr::entities::{Inst, Ebb, Value}; +use repr::types::Type; pub type Result = io::Result<()>; @@ -182,7 +182,7 @@ pub fn write_instruction(w: &mut Write, func: &Function, inst: Inst) -> Result { } // Then the operands, depending on format. - use instructions::InstructionData::*; + use repr::instructions::InstructionData::*; match func.dfg[inst] { Nullary { .. } => writeln!(w, ""), Unary { arg, .. } => writeln!(w, " {}", arg), @@ -218,7 +218,7 @@ mod tests { use super::*; use super::{needs_quotes, escaped}; use repr::{Function, StackSlotData}; - use types; + use repr::types; #[test] fn quoting() { diff --git a/src/libreader/lexer.rs b/src/libreader/lexer.rs index 4d3dfdf7c1..87c7482589 100644 --- a/src/libreader/lexer.rs +++ b/src/libreader/lexer.rs @@ -6,8 +6,8 @@ // ====--------------------------------------------------------------------------------------====// use std::str::CharIndices; -use cretonne::types; -use cretonne::entities::{Value, Ebb}; +use cretonne::repr::types; +use cretonne::repr::entities::{Value, Ebb}; /// The location of a `Token` or `Error`. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -373,8 +373,8 @@ impl<'a> Lexer<'a> { #[cfg(test)] mod tests { use super::*; - use cretonne::types; - use cretonne::entities::{Value, Ebb}; + use cretonne::repr::types; + use cretonne::repr::entities::{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 b79ff16cc3..0c573558c7 100644 --- a/src/libreader/parser.rs +++ b/src/libreader/parser.rs @@ -11,11 +11,11 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; use std::u32; use lexer::{self, Lexer, Token}; -use cretonne::types::{Type, VOID, FunctionName, Signature, ArgumentType, ArgumentExtension}; -use cretonne::immediates::{Imm64, Ieee32, Ieee64}; -use cretonne::entities::*; -use cretonne::instructions::{Opcode, InstructionFormat, InstructionData, VariableArgs, JumpData, - BranchData, ReturnData}; +use cretonne::repr::types::{Type, VOID, FunctionName, Signature, ArgumentType, ArgumentExtension}; +use cretonne::repr::immediates::{Imm64, Ieee32, Ieee64}; +use cretonne::repr::entities::*; +use cretonne::repr::instructions::{Opcode, InstructionFormat, InstructionData, VariableArgs, + JumpData, BranchData, ReturnData}; use cretonne::repr::{Function, StackSlotData}; pub use lexer::Location; @@ -1039,7 +1039,7 @@ impl<'a> Parser<'a> { #[cfg(test)] mod tests { use super::*; - use cretonne::types::{self, ArgumentType, ArgumentExtension}; + use cretonne::repr::types::{self, ArgumentType, ArgumentExtension}; #[test] fn argument_type() { diff --git a/src/tools/print_cfg.rs b/src/tools/print_cfg.rs index 1c7f0e7a19..155de0e4a1 100644 --- a/src/tools/print_cfg.rs +++ b/src/tools/print_cfg.rs @@ -8,7 +8,7 @@ use std::io::{Read, Write, stdout}; use CommandResult; use cretonne::repr::Function; use cretonne::cfg::ControlFlowGraph; -use cretonne::instructions::InstructionData; +use cretonne::repr::instructions::InstructionData; use cton_reader::parser::Parser; pub fn run(files: Vec) -> CommandResult {