diff --git a/cranelift/src/compile.rs b/cranelift/src/compile.rs index ccc049fa70..f2272494cf 100644 --- a/cranelift/src/compile.rs +++ b/cranelift/src/compile.rs @@ -7,7 +7,7 @@ use cretonne::settings::FlagsOrIsa; use cretonne::{binemit, ir}; use cretonne::print_errors::pretty_error; use std::path::Path; -use utils::{read_to_string, parse_sets_and_isa}; +use utils::{parse_sets_and_isa, read_to_string}; struct PrintRelocs { flag_print: bool, diff --git a/cranelift/src/cton-util.rs b/cranelift/src/cton-util.rs index 4dd9865d3d..42887640df 100644 --- a/cranelift/src/cton-util.rs +++ b/cranelift/src/cton-util.rs @@ -1,15 +1,15 @@ extern crate cretonne; +extern crate cton_filetests; extern crate cton_reader; extern crate cton_wasm; -extern crate cton_filetests; extern crate docopt; +extern crate filecheck; #[macro_use] extern crate serde_derive; -extern crate filecheck; extern crate tempdir; extern crate term; -use cretonne::{VERSION, timing}; +use cretonne::{timing, VERSION}; use docopt::Docopt; use std::io::{self, Write}; use std::process; diff --git a/cranelift/src/rsfilecheck.rs b/cranelift/src/rsfilecheck.rs index 58b9cb9e53..f71571b513 100644 --- a/cranelift/src/rsfilecheck.rs +++ b/cranelift/src/rsfilecheck.rs @@ -4,7 +4,7 @@ use CommandResult; use utils::read_to_string; -use filecheck::{CheckerBuilder, Checker, NO_VARIABLES}; +use filecheck::{Checker, CheckerBuilder, NO_VARIABLES}; use std::io::{self, Read}; pub fn run(files: &[String], verbose: bool) -> CommandResult { diff --git a/lib/cretonne/build.rs b/lib/cretonne/build.rs index 69be14de94..e13e9349a5 100644 --- a/lib/cretonne/build.rs +++ b/lib/cretonne/build.rs @@ -18,7 +18,6 @@ // The build script expects to be run from the directory where this build.rs file lives. The // current directory is used to find the sources. - use std::env; use std::process; diff --git a/lib/cretonne/src/abi.rs b/lib/cretonne/src/abi.rs index b69821e657..2ba3f7b7a1 100644 --- a/lib/cretonne/src/abi.rs +++ b/lib/cretonne/src/abi.rs @@ -3,7 +3,7 @@ //! This module provides functions and data structures that are useful for implementing the //! `TargetIsa::legalize_signature()` method. -use ir::{ArgumentLoc, AbiParam, ArgumentExtension, Type}; +use ir::{AbiParam, ArgumentExtension, ArgumentLoc, Type}; use std::cmp::Ordering; use std::vec::Vec; diff --git a/lib/cretonne/src/bforest/map.rs b/lib/cretonne/src/bforest/map.rs index edf301aa4c..23b4625555 100644 --- a/lib/cretonne/src/bforest/map.rs +++ b/lib/cretonne/src/bforest/map.rs @@ -2,7 +2,7 @@ use packed_option::PackedOption; use std::marker::PhantomData; -use super::{INNER_SIZE, Comparator, Forest, NodePool, Node, NodeData, Path}; +use super::{Comparator, Forest, Node, NodeData, NodePool, Path, INNER_SIZE}; /// Tag type defining forest types for a map. struct MapTypes(PhantomData<(K, V, C)>); diff --git a/lib/cretonne/src/bforest/mod.rs b/lib/cretonne/src/bforest/mod.rs index ff1b94cc0f..bc22cf88c0 100644 --- a/lib/cretonne/src/bforest/mod.rs +++ b/lib/cretonne/src/bforest/mod.rs @@ -22,8 +22,8 @@ mod path; mod pool; mod set; -pub use self::map::{MapForest, Map, MapCursor, MapIter}; -pub use self::set::{SetForest, Set, SetCursor, SetIter}; +pub use self::map::{Map, MapCursor, MapForest, MapIter}; +pub use self::set::{Set, SetCursor, SetForest, SetIter}; use self::node::NodeData; use self::path::Path; diff --git a/lib/cretonne/src/bforest/node.rs b/lib/cretonne/src/bforest/node.rs index d5c46f54bd..61fb6e994d 100644 --- a/lib/cretonne/src/bforest/node.rs +++ b/lib/cretonne/src/bforest/node.rs @@ -2,7 +2,7 @@ use std::borrow::{Borrow, BorrowMut}; use std::fmt; -use super::{Forest, Node, INNER_SIZE, SetValue, slice_insert, slice_shift}; +use super::{slice_insert, slice_shift, Forest, Node, SetValue, INNER_SIZE}; /// B+-tree node. /// diff --git a/lib/cretonne/src/bforest/path.rs b/lib/cretonne/src/bforest/path.rs index 34f165d86c..a2d15173a3 100644 --- a/lib/cretonne/src/bforest/path.rs +++ b/lib/cretonne/src/bforest/path.rs @@ -2,7 +2,7 @@ use std::borrow::Borrow; use std::marker::PhantomData; -use super::{Forest, Node, NodeData, NodePool, MAX_PATH, Comparator, slice_insert, slice_shift}; +use super::{slice_insert, slice_shift, Comparator, Forest, Node, NodeData, NodePool, MAX_PATH}; use super::node::Removed; #[cfg(test)] @@ -414,7 +414,6 @@ impl Path { } } - /// Given that the current leaf node is in an unhealthy (underflowed or even empty) status, /// balance it with sibling nodes. /// @@ -529,7 +528,6 @@ impl Path { // current entry[level] was one off the end of the node, it will now point at a proper // entry. debug_assert!(usize::from(self.entry[level]) < pool[self.node[level]].entries()); - } else if usize::from(self.entry[level]) >= pool[self.node[level]].entries() { // There's no right sibling at this level, so the node can't be rebalanced. // Check if we are in an off-the-end position. @@ -703,7 +701,7 @@ impl fmt::Display for Path { mod test { use std::cmp::Ordering; use super::*; - use super::super::{Forest, NodePool, NodeData}; + use super::super::{Forest, NodeData, NodePool}; struct TC(); diff --git a/lib/cretonne/src/bforest/set.rs b/lib/cretonne/src/bforest/set.rs index dd7f63ca17..374c26ad2b 100644 --- a/lib/cretonne/src/bforest/set.rs +++ b/lib/cretonne/src/bforest/set.rs @@ -2,7 +2,7 @@ use packed_option::PackedOption; use std::marker::PhantomData; -use super::{INNER_SIZE, Comparator, Forest, NodePool, Node, NodeData, Path, SetValue}; +use super::{Comparator, Forest, Node, NodeData, NodePool, Path, SetValue, INNER_SIZE}; /// Tag type defining forest types for a set. struct SetTypes(PhantomData<(K, C)>); diff --git a/lib/cretonne/src/binemit/memorysink.rs b/lib/cretonne/src/binemit/memorysink.rs index d4b07319ab..5a9fa8a298 100644 --- a/lib/cretonne/src/binemit/memorysink.rs +++ b/lib/cretonne/src/binemit/memorysink.rs @@ -14,8 +14,8 @@ //! relocations to a `RelocSink` trait object. Relocations are less frequent than the //! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe. -use ir::{ExternalName, JumpTable, TrapCode, SourceLoc}; -use super::{CodeSink, CodeOffset, Reloc, Addend}; +use ir::{ExternalName, JumpTable, SourceLoc, TrapCode}; +use super::{Addend, CodeOffset, CodeSink, Reloc}; use std::ptr::write_unaligned; /// A `CodeSink` that writes binary machine code directly into memory. diff --git a/lib/cretonne/src/binemit/mod.rs b/lib/cretonne/src/binemit/mod.rs index 6d2099ceba..20ff429756 100644 --- a/lib/cretonne/src/binemit/mod.rs +++ b/lib/cretonne/src/binemit/mod.rs @@ -10,7 +10,7 @@ pub use regalloc::RegDiversions; pub use self::relaxation::relax_branches; pub use self::memorysink::{MemoryCodeSink, RelocSink, TrapSink}; -use ir::{ExternalName, JumpTable, Function, Inst, TrapCode, SourceLoc}; +use ir::{ExternalName, Function, Inst, JumpTable, SourceLoc, TrapCode}; use std::fmt; /// Offset in bytes from the beginning of the function. diff --git a/lib/cretonne/src/binemit/relaxation.rs b/lib/cretonne/src/binemit/relaxation.rs index 24a78ceebd..8123c5b92f 100644 --- a/lib/cretonne/src/binemit/relaxation.rs +++ b/lib/cretonne/src/binemit/relaxation.rs @@ -30,7 +30,7 @@ use binemit::CodeOffset; use cursor::{Cursor, FuncCursor}; use ir::{Function, InstructionData, Opcode}; -use isa::{TargetIsa, EncInfo}; +use isa::{EncInfo, TargetIsa}; use iterators::IteratorExtras; use result::CtonError; diff --git a/lib/cretonne/src/bitset.rs b/lib/cretonne/src/bitset.rs index f212790be0..f0a7271957 100644 --- a/lib/cretonne/src/bitset.rs +++ b/lib/cretonne/src/bitset.rs @@ -6,8 +6,8 @@ //! If you would like to add support for larger bitsets in the future, you need to change the trait //! bound Into and the u32 in the implementation of `max_bits()`. use std::mem::size_of; -use std::ops::{Shl, BitOr, Sub, Add}; -use std::convert::{Into, From}; +use std::ops::{Add, BitOr, Shl, Sub}; +use std::convert::{From, Into}; /// A small bitset built on a single primitive integer type #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/lib/cretonne/src/cfg_printer.rs b/lib/cretonne/src/cfg_printer.rs index 736d12f0fc..46b8754e3e 100644 --- a/lib/cretonne/src/cfg_printer.rs +++ b/lib/cretonne/src/cfg_printer.rs @@ -1,6 +1,6 @@ //! The `CFGPrinter` utility. -use std::fmt::{Result, Write, Display, Formatter}; +use std::fmt::{Display, Formatter, Result, Write}; use flowgraph::ControlFlowGraph; use ir::Function; diff --git a/lib/cretonne/src/constant_hash.rs b/lib/cretonne/src/constant_hash.rs index d049d8e752..0dd2895ad3 100644 --- a/lib/cretonne/src/constant_hash.rs +++ b/lib/cretonne/src/constant_hash.rs @@ -18,7 +18,6 @@ pub trait Table { fn key(&self, idx: usize) -> Option; } - /// Look for `key` in `table`. /// /// The provided `hash` value must have been computed from `key` using the same hash function that diff --git a/lib/cretonne/src/context.rs b/lib/cretonne/src/context.rs index 5324248142..c7841f9366 100644 --- a/lib/cretonne/src/context.rs +++ b/lib/cretonne/src/context.rs @@ -9,7 +9,7 @@ //! contexts concurrently. Typically, you would have one context per compilation thread and only a //! single ISA instance. -use binemit::{CodeOffset, relax_branches, MemoryCodeSink, RelocSink, TrapSink}; +use binemit::{relax_branches, CodeOffset, MemoryCodeSink, RelocSink, TrapSink}; use dominator_tree::DominatorTree; use flowgraph::ControlFlowGraph; use ir::Function; diff --git a/lib/cretonne/src/cursor.rs b/lib/cretonne/src/cursor.rs index 42f5e1e741..082889a693 100644 --- a/lib/cretonne/src/cursor.rs +++ b/lib/cretonne/src/cursor.rs @@ -637,7 +637,6 @@ impl<'c, 'f> ir::InstInserterBase<'c> for &'c mut FuncCursor<'f> { } } - /// Encoding cursor. /// /// An `EncCursor` can be used to insert instructions that are immediately assigned an encoding. diff --git a/lib/cretonne/src/dce.rs b/lib/cretonne/src/dce.rs index 6e34bad74f..b78d260ecb 100644 --- a/lib/cretonne/src/dce.rs +++ b/lib/cretonne/src/dce.rs @@ -6,7 +6,7 @@ use cursor::{Cursor, FuncCursor}; use dominator_tree::DominatorTree; use entity::EntityRef; -use ir::{Function, Inst, Opcode, DataFlowGraph}; +use ir::{DataFlowGraph, Function, Inst, Opcode}; use ir::instructions::InstructionData; use timing; use std::vec::Vec; diff --git a/lib/cretonne/src/divconst_magic_numbers.rs b/lib/cretonne/src/divconst_magic_numbers.rs index 01b5066b28..80a59aed8b 100644 --- a/lib/cretonne/src/divconst_magic_numbers.rs +++ b/lib/cretonne/src/divconst_magic_numbers.rs @@ -220,8 +220,8 @@ pub fn magicS64(d: i64) -> MS64 { #[cfg(test)] mod tests { - use super::{magicU32, magicU64, magicS32, magicS64}; - use super::{MU32, MU64, MS32, MS64}; + use super::{magicS32, magicS64, magicU32, magicU64}; + use super::{MS32, MS64, MU32, MU64}; fn mkMU32(mulBy: u32, doAdd: bool, shiftBy: i32) -> MU32 { MU32 { diff --git a/lib/cretonne/src/dominator_tree.rs b/lib/cretonne/src/dominator_tree.rs index 57f55781a3..574697c1ba 100644 --- a/lib/cretonne/src/dominator_tree.rs +++ b/lib/cretonne/src/dominator_tree.rs @@ -1,8 +1,8 @@ //! A Dominator Tree represented as mappings of Ebbs to their immediate dominator. use entity::EntityMap; -use flowgraph::{ControlFlowGraph, BasicBlock}; -use ir::{Ebb, Inst, Value, Function, Layout, ProgramOrder, ExpandedProgramPoint}; +use flowgraph::{BasicBlock, ControlFlowGraph}; +use ir::{Ebb, ExpandedProgramPoint, Function, Inst, Layout, ProgramOrder, Value}; use ir::instructions::BranchInfo; use packed_option::PackedOption; use std::cmp; @@ -144,12 +144,12 @@ impl DominatorTree { { let (mut ebb_b, mut inst_b) = match b.into() { ExpandedProgramPoint::Ebb(ebb) => (ebb, None), - ExpandedProgramPoint::Inst(inst) => { - ( - layout.inst_ebb(inst).expect("Instruction not in layout."), - Some(inst), - ) - } + ExpandedProgramPoint::Inst(inst) => ( + layout.inst_ebb(inst).expect( + "Instruction not in layout.", + ), + Some(inst), + ), }; let rpo_a = self.nodes[a].rpo_number; @@ -460,7 +460,6 @@ impl DominatorTree { rpo_number: new_ebb_rpo, idom: Some(split_jump_inst).into(), }; - } // Insert new_ebb just after ebb in the RPO. This function checks diff --git a/lib/cretonne/src/entity/list.rs b/lib/cretonne/src/entity/list.rs index ad03dc6c85..2c743e169b 100644 --- a/lib/cretonne/src/entity/list.rs +++ b/lib/cretonne/src/entity/list.rs @@ -480,7 +480,7 @@ impl EntityList { #[cfg(test)] mod tests { use super::*; - use super::{sclass_size, sclass_for_length}; + use super::{sclass_for_length, sclass_size}; use ir::Inst; use entity::EntityRef; diff --git a/lib/cretonne/src/entity/map.rs b/lib/cretonne/src/entity/map.rs index 3aac22b44f..88b355585b 100644 --- a/lib/cretonne/src/entity/map.rs +++ b/lib/cretonne/src/entity/map.rs @@ -1,6 +1,6 @@ //! Densely numbered entity references as mapping keys. -use entity::{EntityRef, Keys, Iter, IterMut}; +use entity::{EntityRef, Iter, IterMut, Keys}; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::vec::Vec; diff --git a/lib/cretonne/src/entity/mod.rs b/lib/cretonne/src/entity/mod.rs index c4004f126d..9aeab1449d 100644 --- a/lib/cretonne/src/entity/mod.rs +++ b/lib/cretonne/src/entity/mod.rs @@ -43,7 +43,7 @@ pub use self::list::{EntityList, ListPool}; pub use self::map::EntityMap; pub use self::primary::PrimaryMap; pub use self::set::EntitySet; -pub use self::sparse::{SparseSet, SparseMap, SparseMapValue}; +pub use self::sparse::{SparseMap, SparseMapValue, SparseSet}; /// A type wrapping a small integer index should implement `EntityRef` so it can be used as the key /// of an `EntityMap` or `SparseMap`. diff --git a/lib/cretonne/src/entity/primary.rs b/lib/cretonne/src/entity/primary.rs index 8671bdf809..a442928d77 100644 --- a/lib/cretonne/src/entity/primary.rs +++ b/lib/cretonne/src/entity/primary.rs @@ -1,5 +1,5 @@ //! Densely numbered entity references as mapping keys. -use entity::{EntityRef, Keys, Iter, IterMut}; +use entity::{EntityRef, Iter, IterMut, Keys}; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::vec::Vec; diff --git a/lib/cretonne/src/entity/sparse.rs b/lib/cretonne/src/entity/sparse.rs index 488fd55393..6894c89498 100644 --- a/lib/cretonne/src/entity/sparse.rs +++ b/lib/cretonne/src/entity/sparse.rs @@ -7,7 +7,7 @@ //! > Briggs, Torczon, *An efficient representation for sparse sets*, //! ACM Letters on Programming Languages and Systems, Volume 2, Issue 1-4, March-Dec. 1993. -use entity::{EntityRef, EntityMap}; +use entity::{EntityMap, EntityRef}; use std::mem; use std::slice; use std::u32; diff --git a/lib/cretonne/src/flowgraph.rs b/lib/cretonne/src/flowgraph.rs index dce60162a4..3ed295d6f0 100644 --- a/lib/cretonne/src/flowgraph.rs +++ b/lib/cretonne/src/flowgraph.rs @@ -24,7 +24,7 @@ //! and `(Ebb0, jmp Ebb2)` respectively. use bforest; -use ir::{Function, Inst, Ebb}; +use ir::{Ebb, Function, Inst}; use ir::instructions::BranchInfo; use entity::EntityMap; use std::mem; @@ -203,7 +203,7 @@ pub type SuccIter<'a> = bforest::SetIter<'a, Ebb, ()>; mod tests { use super::*; use cursor::{Cursor, FuncCursor}; - use ir::{Function, InstBuilder, types}; + use ir::{types, Function, InstBuilder}; use std::vec::Vec; #[test] diff --git a/lib/cretonne/src/ir/builder.rs b/lib/cretonne/src/ir/builder.rs index 7e1480186d..6308f3e1bd 100644 --- a/lib/cretonne/src/ir/builder.rs +++ b/lib/cretonne/src/ir/builder.rs @@ -5,8 +5,8 @@ use ir; use ir::types; -use ir::{InstructionData, DataFlowGraph}; -use ir::{Opcode, Type, Inst, Value}; +use ir::{DataFlowGraph, InstructionData}; +use ir::{Inst, Opcode, Type, Value}; use isa; /// Base trait for instruction builders. @@ -145,8 +145,9 @@ where } impl<'f, IIB, Array> InstBuilderBase<'f> for InsertReuseBuilder<'f, IIB, Array> - where IIB: InstInserterBase<'f>, - Array: AsRef<[Option]> +where + IIB: InstInserterBase<'f>, + Array: AsRef<[Option]>, { fn data_flow_graph(&self) -> &DataFlowGraph { self.inserter.data_flow_graph() diff --git a/lib/cretonne/src/ir/dfg.rs b/lib/cretonne/src/ir/dfg.rs index d8cb9b2eb1..48faf3b5ac 100644 --- a/lib/cretonne/src/ir/dfg.rs +++ b/lib/cretonne/src/ir/dfg.rs @@ -1,13 +1,13 @@ //! Data flow graph tracking Instructions, Values, and EBBs. -use entity::{PrimaryMap, EntityMap}; -use isa::{TargetIsa, Encoding, Legalize}; +use entity::{EntityMap, PrimaryMap}; +use isa::{Encoding, Legalize, TargetIsa}; use ir; use ir::builder::ReplaceBuilder; use ir::extfunc::ExtFuncData; -use ir::instructions::{InstructionData, CallInfo, BranchInfo}; +use ir::instructions::{BranchInfo, CallInfo, InstructionData}; use ir::types; -use ir::{Ebb, Inst, Value, Type, SigRef, Signature, FuncRef, ValueList, ValueListPool}; +use ir::{Ebb, FuncRef, Inst, SigRef, Signature, Type, Value, ValueList, ValueListPool}; use packed_option::ReservedValue; use write::write_operands; use std::fmt; @@ -775,7 +775,6 @@ impl DataFlowGraph { } } - /// Append an existing value to `ebb`'s parameters. /// /// The appended value can't already be attached to something else. @@ -863,7 +862,6 @@ impl<'a> fmt::Display for DisplayInst<'a> { write!(f, " = ")?; } - let typevar = dfg.ctrl_typevar(inst); if typevar.is_void() { write!(f, "{}", dfg[inst].opcode())?; @@ -1005,7 +1003,7 @@ mod tests { use super::*; use cursor::{Cursor, FuncCursor}; use ir::types; - use ir::{Function, Opcode, InstructionData, TrapCode}; + use ir::{Function, InstructionData, Opcode, TrapCode}; use std::string::ToString; #[test] diff --git a/lib/cretonne/src/ir/extfunc.rs b/lib/cretonne/src/ir/extfunc.rs index 08fa28cf5c..45c44c952a 100644 --- a/lib/cretonne/src/ir/extfunc.rs +++ b/lib/cretonne/src/ir/extfunc.rs @@ -5,7 +5,7 @@ //! //! This module declares the data types used to represent external functions and call signatures. -use ir::{Type, ExternalName, SigRef, ArgumentLoc}; +use ir::{ArgumentLoc, ExternalName, SigRef, Type}; use isa::{RegInfo, RegUnit}; use std::cmp; use std::fmt; @@ -379,7 +379,7 @@ impl FromStr for CallConv { #[cfg(test)] mod tests { use super::*; - use ir::types::{I32, F32, B8}; + use ir::types::{B8, F32, I32}; use std::string::ToString; #[test] diff --git a/lib/cretonne/src/ir/function.rs b/lib/cretonne/src/ir/function.rs index d122e73360..5010e0caae 100644 --- a/lib/cretonne/src/ir/function.rs +++ b/lib/cretonne/src/ir/function.rs @@ -4,13 +4,13 @@ //! instructions. use binemit::CodeOffset; -use entity::{PrimaryMap, EntityMap}; +use entity::{EntityMap, PrimaryMap}; use ir; -use ir::{ExternalName, CallConv, Signature, DataFlowGraph, Layout}; -use ir::{InstEncodings, ValueLocations, JumpTables, StackSlots, EbbOffsets, SourceLocs}; -use ir::{Ebb, JumpTableData, JumpTable, StackSlotData, StackSlot, SigRef, ExtFuncData, FuncRef, - GlobalVarData, GlobalVar, HeapData, Heap}; -use isa::{TargetIsa, EncInfo, Legalize}; +use ir::{CallConv, DataFlowGraph, ExternalName, Layout, Signature}; +use ir::{EbbOffsets, InstEncodings, JumpTables, SourceLocs, StackSlots, ValueLocations}; +use ir::{Ebb, ExtFuncData, FuncRef, GlobalVar, GlobalVarData, Heap, HeapData, JumpTable, + JumpTableData, SigRef, StackSlot, StackSlotData}; +use isa::{EncInfo, Legalize, TargetIsa}; use std::fmt; use write::write_function; diff --git a/lib/cretonne/src/ir/immediates.rs b/lib/cretonne/src/ir/immediates.rs index 6026cecf26..3dd09bd0bd 100644 --- a/lib/cretonne/src/ir/immediates.rs +++ b/lib/cretonne/src/ir/immediates.rs @@ -184,7 +184,6 @@ impl Display for Uimm32 { } else { write_hex(i64::from(self.0), f) } - } } @@ -249,7 +248,6 @@ impl Display for Offset32 { } else { write_hex(val, f) } - } } @@ -461,7 +459,6 @@ fn parse_float(s: &str, w: u8, t: u8) -> Result { None => return Err("Invalid character"), } } - } } diff --git a/lib/cretonne/src/ir/instructions.rs b/lib/cretonne/src/ir/instructions.rs index b25e5a069b..94293b517b 100644 --- a/lib/cretonne/src/ir/instructions.rs +++ b/lib/cretonne/src/ir/instructions.rs @@ -12,7 +12,7 @@ use std::ops::{Deref, DerefMut}; use std::vec::Vec; use ir; -use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef}; +use ir::{Ebb, FuncRef, JumpTable, SigRef, Type, Value}; use ir::types; use isa; @@ -73,7 +73,7 @@ impl FromStr for Opcode { /// Parse an Opcode name from a string. fn from_str(s: &str) -> Result { - use constant_hash::{Table, simple_hash, probe}; + use constant_hash::{probe, simple_hash, Table}; impl<'a> Table<&'a str> for [Option] { fn len(&self) -> usize { @@ -512,16 +512,12 @@ impl OperandConstraint { LaneOf => Bound(ctrl_type.lane_type()), AsBool => Bound(ctrl_type.as_bool()), HalfWidth => Bound(ctrl_type.half_width().expect("invalid type for half_width")), - DoubleWidth => { - Bound(ctrl_type.double_width().expect( - "invalid type for double_width", - )) - } - HalfVector => { - Bound(ctrl_type.half_vector().expect( - "invalid type for half_vector", - )) - } + DoubleWidth => Bound(ctrl_type.double_width().expect( + "invalid type for double_width", + )), + HalfVector => Bound(ctrl_type.half_vector().expect( + "invalid type for half_vector", + )), DoubleVector => Bound(ctrl_type.by(2).expect("invalid type for double_vector")), } } diff --git a/lib/cretonne/src/ir/layout.rs b/lib/cretonne/src/ir/layout.rs index af0c99e0fe..78db62530b 100644 --- a/lib/cretonne/src/ir/layout.rs +++ b/lib/cretonne/src/ir/layout.rs @@ -5,10 +5,10 @@ use entity::EntityMap; use ir::{Ebb, Inst}; -use ir::progpoint::{ProgramOrder, ExpandedProgramPoint}; +use ir::progpoint::{ExpandedProgramPoint, ProgramOrder}; use packed_option::PackedOption; use std::cmp; -use std::iter::{Iterator, IntoIterator}; +use std::iter::{IntoIterator, Iterator}; use timing; /// The `Layout` struct determines the layout of EBBs and instructions in a function. It does not @@ -734,7 +734,6 @@ impl<'f> DoubleEndedIterator for Insts<'f> { } } - #[cfg(test)] mod tests { use cursor::{Cursor, CursorPosition}; diff --git a/lib/cretonne/src/ir/mod.rs b/lib/cretonne/src/ir/mod.rs index 4f4e671f30..0d805cb3de 100644 --- a/lib/cretonne/src/ir/mod.rs +++ b/lib/cretonne/src/ir/mod.rs @@ -22,29 +22,29 @@ mod sourceloc; mod trapcode; mod valueloc; -pub use ir::builder::{InstBuilder, InstBuilderBase, InstInserterBase, InsertBuilder}; +pub use ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase}; pub use ir::dfg::{DataFlowGraph, ValueDef}; -pub use ir::entities::{Ebb, Inst, Value, StackSlot, GlobalVar, JumpTable, FuncRef, SigRef, Heap}; -pub use ir::extfunc::{Signature, CallConv, AbiParam, ArgumentExtension, ArgumentPurpose, - ExtFuncData}; +pub use ir::entities::{Ebb, FuncRef, GlobalVar, Heap, Inst, JumpTable, SigRef, StackSlot, Value}; +pub use ir::extfunc::{AbiParam, ArgumentExtension, ArgumentPurpose, CallConv, ExtFuncData, + Signature}; pub use ir::extname::ExternalName; pub use ir::function::Function; pub use ir::globalvar::GlobalVarData; -pub use ir::heap::{HeapData, HeapStyle, HeapBase}; -pub use ir::instructions::{Opcode, InstructionData, VariableArgs, ValueList, ValueListPool}; +pub use ir::heap::{HeapBase, HeapData, HeapStyle}; +pub use ir::instructions::{InstructionData, Opcode, ValueList, ValueListPool, VariableArgs}; pub use ir::jumptable::JumpTableData; pub use ir::layout::Layout; pub use ir::libcall::LibCall; pub use ir::memflags::MemFlags; -pub use ir::progpoint::{ProgramPoint, ProgramOrder, ExpandedProgramPoint}; +pub use ir::progpoint::{ExpandedProgramPoint, ProgramOrder, ProgramPoint}; pub use ir::sourceloc::SourceLoc; -pub use ir::stackslot::{StackSlots, StackSlotKind, StackSlotData}; +pub use ir::stackslot::{StackSlotData, StackSlotKind, StackSlots}; pub use ir::trapcode::TrapCode; pub use ir::types::Type; -pub use ir::valueloc::{ValueLoc, ArgumentLoc}; +pub use ir::valueloc::{ArgumentLoc, ValueLoc}; use binemit; -use entity::{PrimaryMap, EntityMap}; +use entity::{EntityMap, PrimaryMap}; use isa; /// Map of value locations. diff --git a/lib/cretonne/src/ir/progpoint.rs b/lib/cretonne/src/ir/progpoint.rs index 8fea3193c6..6eab7ec743 100644 --- a/lib/cretonne/src/ir/progpoint.rs +++ b/lib/cretonne/src/ir/progpoint.rs @@ -147,7 +147,7 @@ pub trait ProgramOrder { mod tests { use super::*; use entity::EntityRef; - use ir::{Inst, Ebb}; + use ir::{Ebb, Inst}; use std::string::ToString; #[test] diff --git a/lib/cretonne/src/ir/stackslot.rs b/lib/cretonne/src/ir/stackslot.rs index bc87e11a82..fd484915fd 100644 --- a/lib/cretonne/src/ir/stackslot.rs +++ b/lib/cretonne/src/ir/stackslot.rs @@ -3,8 +3,8 @@ //! The `StackSlotData` struct keeps track of a single stack slot in a function. //! -use entity::{PrimaryMap, Keys, Iter, IterMut}; -use ir::{Type, StackSlot}; +use entity::{Iter, IterMut, Keys, PrimaryMap}; +use ir::{StackSlot, Type}; use packed_option::PackedOption; use std::cmp; use std::fmt; diff --git a/lib/cretonne/src/ir/types.rs b/lib/cretonne/src/ir/types.rs index 29a37f0cbf..496312b1c4 100644 --- a/lib/cretonne/src/ir/types.rs +++ b/lib/cretonne/src/ir/types.rs @@ -1,7 +1,7 @@ //! Common types for the Cretonne code generator. use std::default::Default; -use std::fmt::{self, Display, Debug, Formatter}; +use std::fmt::{self, Debug, Display, Formatter}; /// The type of an SSA value. /// diff --git a/lib/cretonne/src/isa/arm32/abi.rs b/lib/cretonne/src/isa/arm32/abi.rs index 47efbc97bf..020a525ac5 100644 --- a/lib/cretonne/src/isa/arm32/abi.rs +++ b/lib/cretonne/src/isa/arm32/abi.rs @@ -4,7 +4,7 @@ use ir; use isa::RegClass; use regalloc::AllocatableSet; use settings as shared_settings; -use super::registers::{S, D, Q, GPR}; +use super::registers::{D, GPR, Q, S}; /// Legalize `sig`. pub fn legalize_signature( diff --git a/lib/cretonne/src/isa/arm32/binemit.rs b/lib/cretonne/src/isa/arm32/binemit.rs index 78fa2fd657..9f50e63993 100644 --- a/lib/cretonne/src/isa/arm32/binemit.rs +++ b/lib/cretonne/src/isa/arm32/binemit.rs @@ -1,6 +1,6 @@ //! Emitting binary ARM32 machine code. -use binemit::{CodeSink, bad_encoding}; +use binemit::{bad_encoding, CodeSink}; use ir::{Function, Inst}; use regalloc::RegDiversions; diff --git a/lib/cretonne/src/isa/arm32/mod.rs b/lib/cretonne/src/isa/arm32/mod.rs index 02e0d5f1af..11271fe3d9 100644 --- a/lib/cretonne/src/isa/arm32/mod.rs +++ b/lib/cretonne/src/isa/arm32/mod.rs @@ -6,11 +6,11 @@ mod binemit; mod enc_tables; mod registers; -use binemit::{CodeSink, MemoryCodeSink, emit_function}; +use binemit::{emit_function, CodeSink, MemoryCodeSink}; use super::super::settings as shared_settings; use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; use isa::Builder as IsaBuilder; -use isa::{TargetIsa, RegInfo, RegClass, EncInfo}; +use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; use ir; use regalloc; use std::fmt; diff --git a/lib/cretonne/src/isa/arm32/registers.rs b/lib/cretonne/src/isa/arm32/registers.rs index e2c4813bdd..305890b29e 100644 --- a/lib/cretonne/src/isa/arm32/registers.rs +++ b/lib/cretonne/src/isa/arm32/registers.rs @@ -6,7 +6,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs")); #[cfg(test)] mod tests { - use super::{INFO, GPR, S, D}; + use super::{D, GPR, INFO, S}; use isa::RegUnit; use std::string::{String, ToString}; diff --git a/lib/cretonne/src/isa/arm64/abi.rs b/lib/cretonne/src/isa/arm64/abi.rs index 14af59ab18..9dba70c42f 100644 --- a/lib/cretonne/src/isa/arm64/abi.rs +++ b/lib/cretonne/src/isa/arm64/abi.rs @@ -4,7 +4,7 @@ use ir; use isa::RegClass; use regalloc::AllocatableSet; use settings as shared_settings; -use super::registers::{GPR, FPR}; +use super::registers::{FPR, GPR}; /// Legalize `sig`. pub fn legalize_signature( diff --git a/lib/cretonne/src/isa/arm64/binemit.rs b/lib/cretonne/src/isa/arm64/binemit.rs index a4b79cda55..dd0654067e 100644 --- a/lib/cretonne/src/isa/arm64/binemit.rs +++ b/lib/cretonne/src/isa/arm64/binemit.rs @@ -1,6 +1,6 @@ //! Emitting binary ARM64 machine code. -use binemit::{CodeSink, bad_encoding}; +use binemit::{bad_encoding, CodeSink}; use ir::{Function, Inst}; use regalloc::RegDiversions; diff --git a/lib/cretonne/src/isa/arm64/mod.rs b/lib/cretonne/src/isa/arm64/mod.rs index 8239cb01e9..485b008574 100644 --- a/lib/cretonne/src/isa/arm64/mod.rs +++ b/lib/cretonne/src/isa/arm64/mod.rs @@ -6,11 +6,11 @@ mod binemit; mod enc_tables; mod registers; -use binemit::{CodeSink, MemoryCodeSink, emit_function}; +use binemit::{emit_function, CodeSink, MemoryCodeSink}; use super::super::settings as shared_settings; use isa::enc_tables::{lookup_enclist, Encodings}; use isa::Builder as IsaBuilder; -use isa::{TargetIsa, RegInfo, RegClass, EncInfo}; +use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; use ir; use regalloc; use std::fmt; diff --git a/lib/cretonne/src/isa/constraints.rs b/lib/cretonne/src/isa/constraints.rs index f831c0e187..4ab22a6026 100644 --- a/lib/cretonne/src/isa/constraints.rs +++ b/lib/cretonne/src/isa/constraints.rs @@ -9,7 +9,7 @@ use binemit::CodeOffset; use isa::{RegClass, RegUnit}; -use ir::{Function, ValueLoc, Inst}; +use ir::{Function, Inst, ValueLoc}; use regalloc::RegDiversions; /// Register constraint for a single value operand or instruction result. @@ -205,6 +205,5 @@ mod tests { // Backward limit assert!(t1.contains(1000, 748)); assert!(!t1.contains(1000, 746)); - } } diff --git a/lib/cretonne/src/isa/enc_tables.rs b/lib/cretonne/src/isa/enc_tables.rs index 7453b7c044..c987606fa6 100644 --- a/lib/cretonne/src/isa/enc_tables.rs +++ b/lib/cretonne/src/isa/enc_tables.rs @@ -3,8 +3,8 @@ //! This module contains types and functions for working with the encoding tables generated by //! `lib/cretonne/meta/gen_encoding.py`. -use constant_hash::{Table, probe}; -use ir::{Type, Opcode, DataFlowGraph, InstructionData}; +use constant_hash::{probe, Table}; +use ir::{DataFlowGraph, InstructionData, Opcode, Type}; use isa::{Encoding, Legalize}; use settings::PredicateView; use std::ops::Range; diff --git a/lib/cretonne/src/isa/encoding.rs b/lib/cretonne/src/isa/encoding.rs index b82137a6b8..1b850d5c64 100644 --- a/lib/cretonne/src/isa/encoding.rs +++ b/lib/cretonne/src/isa/encoding.rs @@ -1,7 +1,7 @@ //! The `Encoding` struct. use binemit::CodeOffset; -use isa::constraints::{RecipeConstraints, BranchRange}; +use isa::constraints::{BranchRange, RecipeConstraints}; use std::fmt; /// Bits needed to encode an instruction as binary machine code. diff --git a/lib/cretonne/src/isa/intel/abi.rs b/lib/cretonne/src/isa/intel/abi.rs index e2c79e0377..46ad7679e6 100644 --- a/lib/cretonne/src/isa/intel/abi.rs +++ b/lib/cretonne/src/isa/intel/abi.rs @@ -4,17 +4,16 @@ use ir; use isa::{RegClass, RegUnit, TargetIsa}; use regalloc::AllocatableSet; use settings as shared_settings; -use super::registers::{GPR, FPR, RU}; -use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args}; -use ir::{AbiParam, ArgumentPurpose, ArgumentLoc, ArgumentExtension, CallConv, InstBuilder}; -use ir::stackslot::{StackSize, StackOffset}; +use super::registers::{FPR, GPR, RU}; +use abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; +use ir::{AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, CallConv, InstBuilder}; +use ir::stackslot::{StackOffset, StackSize}; use ir::immediates::Imm64; use stack_layout::layout_stack; use std::i32; -use cursor::{Cursor, EncCursor, CursorPosition}; +use cursor::{Cursor, CursorPosition, EncCursor}; use result; - /// Argument registers for x86-64 static ARG_GPRS: [RU; 6] = [RU::rdi, RU::rsi, RU::rdx, RU::rcx, RU::r8, RU::r9]; diff --git a/lib/cretonne/src/isa/intel/binemit.rs b/lib/cretonne/src/isa/intel/binemit.rs index 5f2f9512ce..5ec1d7175f 100644 --- a/lib/cretonne/src/isa/intel/binemit.rs +++ b/lib/cretonne/src/isa/intel/binemit.rs @@ -1,9 +1,9 @@ //! Emitting binary Intel machine code. -use binemit::{CodeSink, Reloc, bad_encoding}; -use ir::{Function, Inst, Ebb, InstructionData, Opcode, TrapCode}; -use ir::condcodes::{CondCode, IntCC, FloatCC}; -use isa::{RegUnit, StackRef, StackBase, StackBaseMask}; +use binemit::{bad_encoding, CodeSink, Reloc}; +use ir::{Ebb, Function, Inst, InstructionData, Opcode, TrapCode}; +use ir::condcodes::{CondCode, FloatCC, IntCC}; +use isa::{RegUnit, StackBase, StackBaseMask, StackRef}; use regalloc::RegDiversions; use super::registers::RU; diff --git a/lib/cretonne/src/isa/intel/enc_tables.rs b/lib/cretonne/src/isa/intel/enc_tables.rs index d3f62adf7c..b8461c0008 100644 --- a/lib/cretonne/src/isa/intel/enc_tables.rs +++ b/lib/cretonne/src/isa/intel/enc_tables.rs @@ -22,7 +22,6 @@ fn expand_sdivrem( cfg: &mut ControlFlowGraph, isa: &isa::TargetIsa, ) { - let (x, y, is_srem) = match func.dfg[inst] { ir::InstructionData::Binary { opcode: ir::Opcode::Sdiv, @@ -113,7 +112,6 @@ fn expand_udivrem( _cfg: &mut ControlFlowGraph, isa: &isa::TargetIsa, ) { - let (x, y, is_urem) = match func.dfg[inst] { ir::InstructionData::Binary { opcode: ir::Opcode::Udiv, @@ -324,7 +322,7 @@ fn expand_fcvt_to_sint( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{IntCC, FloatCC}; + use ir::condcodes::{FloatCC, IntCC}; use ir::immediates::{Ieee32, Ieee64}; let x; @@ -423,7 +421,7 @@ fn expand_fcvt_to_uint( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{IntCC, FloatCC}; + use ir::condcodes::{FloatCC, IntCC}; use ir::immediates::{Ieee32, Ieee64}; let x; diff --git a/lib/cretonne/src/isa/intel/mod.rs b/lib/cretonne/src/isa/intel/mod.rs index 04ff149654..aa6f2a0a01 100644 --- a/lib/cretonne/src/isa/intel/mod.rs +++ b/lib/cretonne/src/isa/intel/mod.rs @@ -6,11 +6,11 @@ mod binemit; mod enc_tables; mod registers; -use binemit::{CodeSink, MemoryCodeSink, emit_function}; +use binemit::{emit_function, CodeSink, MemoryCodeSink}; use super::super::settings as shared_settings; use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; use isa::Builder as IsaBuilder; -use isa::{TargetIsa, RegInfo, RegClass, EncInfo}; +use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; use ir; use regalloc; use result; diff --git a/lib/cretonne/src/isa/mod.rs b/lib/cretonne/src/isa/mod.rs index 1a7714fc76..8c141126af 100644 --- a/lib/cretonne/src/isa/mod.rs +++ b/lib/cretonne/src/isa/mod.rs @@ -40,9 +40,9 @@ //! The configured target ISA trait object is a `Box` which can be used for multiple //! concurrent function compilations. -pub use isa::constraints::{RecipeConstraints, OperandConstraint, ConstraintKind, BranchRange}; -pub use isa::encoding::{Encoding, EncInfo}; -pub use isa::registers::{RegInfo, RegUnit, RegClass, RegClassIndex, regs_overlap}; +pub use isa::constraints::{BranchRange, ConstraintKind, OperandConstraint, RecipeConstraints}; +pub use isa::encoding::{EncInfo, Encoding}; +pub use isa::registers::{regs_overlap, RegClass, RegClassIndex, RegInfo, RegUnit}; pub use isa::stack::{StackBase, StackBaseMask, StackRef}; use binemit; @@ -249,7 +249,7 @@ pub trait TargetIsa: fmt::Display { let _tt = timing::prologue_epilogue(); // This default implementation is unlikely to be good enough. use stack_layout::layout_stack; - use ir::stackslot::{StackSize, StackOffset}; + use ir::stackslot::{StackOffset, StackSize}; let word_size = if self.flags().is_64bit() { 8 } else { 4 }; diff --git a/lib/cretonne/src/isa/riscv/abi.rs b/lib/cretonne/src/isa/riscv/abi.rs index 1db377b0ef..4eff90c954 100644 --- a/lib/cretonne/src/isa/riscv/abi.rs +++ b/lib/cretonne/src/isa/riscv/abi.rs @@ -5,12 +5,12 @@ //! //! This doesn't support the soft-float ABI at the moment. -use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args}; -use ir::{self, Type, AbiParam, ArgumentLoc, ArgumentExtension, ArgumentPurpose}; +use abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; +use ir::{self, AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, Type}; use isa::RegClass; use regalloc::AllocatableSet; use settings as shared_settings; -use super::registers::{GPR, FPR}; +use super::registers::{FPR, GPR}; use super::settings; use std::i32; diff --git a/lib/cretonne/src/isa/riscv/binemit.rs b/lib/cretonne/src/isa/riscv/binemit.rs index 8cc1ef17d1..120324d1be 100644 --- a/lib/cretonne/src/isa/riscv/binemit.rs +++ b/lib/cretonne/src/isa/riscv/binemit.rs @@ -1,8 +1,8 @@ //! Emitting binary RISC-V machine code. -use binemit::{CodeSink, Reloc, bad_encoding}; +use binemit::{bad_encoding, CodeSink, Reloc}; use ir::{Function, Inst, InstructionData}; -use isa::{RegUnit, StackRef, StackBaseMask}; +use isa::{RegUnit, StackBaseMask, StackRef}; use predicates::is_signed_int; use regalloc::RegDiversions; use std::u32; diff --git a/lib/cretonne/src/isa/riscv/mod.rs b/lib/cretonne/src/isa/riscv/mod.rs index 6fc976686b..63a3c01088 100644 --- a/lib/cretonne/src/isa/riscv/mod.rs +++ b/lib/cretonne/src/isa/riscv/mod.rs @@ -7,10 +7,10 @@ mod enc_tables; mod registers; use super::super::settings as shared_settings; -use binemit::{CodeSink, MemoryCodeSink, emit_function}; +use binemit::{emit_function, CodeSink, MemoryCodeSink}; use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; use isa::Builder as IsaBuilder; -use isa::{TargetIsa, RegInfo, RegClass, EncInfo}; +use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; use ir; use regalloc; use std::fmt; @@ -116,7 +116,7 @@ mod tests { use settings::{self, Configurable}; use isa; use ir::{DataFlowGraph, InstructionData, Opcode}; - use ir::{types, immediates}; + use ir::{immediates, types}; use std::string::{String, ToString}; fn encstr(isa: &isa::TargetIsa, enc: Result) -> String { diff --git a/lib/cretonne/src/isa/riscv/registers.rs b/lib/cretonne/src/isa/riscv/registers.rs index e2073899b6..d6254fe38e 100644 --- a/lib/cretonne/src/isa/riscv/registers.rs +++ b/lib/cretonne/src/isa/riscv/registers.rs @@ -6,7 +6,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs")); #[cfg(test)] mod tests { - use super::{INFO, GPR, FPR}; + use super::{FPR, GPR, INFO}; use isa::RegUnit; use std::string::{String, ToString}; diff --git a/lib/cretonne/src/isa/riscv/settings.rs b/lib/cretonne/src/isa/riscv/settings.rs index 2f0f6822a9..27cba43f2f 100644 --- a/lib/cretonne/src/isa/riscv/settings.rs +++ b/lib/cretonne/src/isa/riscv/settings.rs @@ -22,12 +22,12 @@ mod tests { assert_eq!( f.to_string(), "[riscv]\n\ - supports_m = false\n\ - supports_a = false\n\ - supports_f = false\n\ - supports_d = false\n\ - enable_m = true\n\ - enable_e = false\n" + supports_m = false\n\ + supports_a = false\n\ + supports_f = false\n\ + supports_d = false\n\ + enable_m = true\n\ + enable_e = false\n" ); // Predicates are not part of the Display output. assert_eq!(f.full_float(), false); diff --git a/lib/cretonne/src/isa/stack.rs b/lib/cretonne/src/isa/stack.rs index 9e09a52808..7eac43b62c 100644 --- a/lib/cretonne/src/isa/stack.rs +++ b/lib/cretonne/src/isa/stack.rs @@ -4,7 +4,7 @@ //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. -use ir::stackslot::{StackSlots, StackOffset, StackSlotKind}; +use ir::stackslot::{StackOffset, StackSlotKind, StackSlots}; use ir::StackSlot; /// A method for referencing a stack slot in the current stack frame. diff --git a/lib/cretonne/src/legalizer/boundary.rs b/lib/cretonne/src/legalizer/boundary.rs index e1e4a17956..6cad2775e5 100644 --- a/lib/cretonne/src/legalizer/boundary.rs +++ b/lib/cretonne/src/legalizer/boundary.rs @@ -20,8 +20,8 @@ use abi::{legalize_abi_value, ValueConversion}; use cursor::{Cursor, FuncCursor}; use flowgraph::ControlFlowGraph; -use ir::{Function, DataFlowGraph, Inst, InstBuilder, Ebb, Type, Value, Signature, SigRef, - AbiParam, ArgumentPurpose, ArgumentLoc, ValueLoc}; +use ir::{AbiParam, ArgumentLoc, ArgumentPurpose, DataFlowGraph, Ebb, Function, Inst, InstBuilder, + SigRef, Signature, Type, Value, ValueLoc}; use ir::instructions::CallInfo; use isa::TargetIsa; use legalizer::split::{isplit, vsplit}; diff --git a/lib/cretonne/src/legalizer/mod.rs b/lib/cretonne/src/legalizer/mod.rs index 68f24ee0da..d434d6b6e5 100644 --- a/lib/cretonne/src/legalizer/mod.rs +++ b/lib/cretonne/src/legalizer/mod.rs @@ -235,7 +235,6 @@ fn expand_select( cfg.recompute_ebb(pos.func, old_ebb); } - /// Expand illegal `f32const` and `f64const` instructions. fn expand_fconst( inst: ir::Inst, diff --git a/lib/cretonne/src/legalizer/split.rs b/lib/cretonne/src/legalizer/split.rs index cdc60974e0..8f82166db8 100644 --- a/lib/cretonne/src/legalizer/split.rs +++ b/lib/cretonne/src/legalizer/split.rs @@ -66,7 +66,7 @@ use cursor::{Cursor, CursorPosition, FuncCursor}; use flowgraph::ControlFlowGraph; -use ir::{self, Ebb, Inst, Value, Type, Opcode, ValueDef, InstructionData, InstBuilder}; +use ir::{self, Ebb, Inst, InstBuilder, InstructionData, Opcode, Type, Value, ValueDef}; use std::iter; use std::vec::Vec; @@ -229,7 +229,6 @@ fn split_value( let hi = pos.func.dfg.append_ebb_param(ebb, split_type); reuse = Some((lo, hi)); - // Now the original value is dangling. Insert a concatenation instruction that can // compute it from the two new parameters. This also serves as a record of what we // did so a future call to this function doesn't have to redo the work. diff --git a/lib/cretonne/src/lib.rs b/lib/cretonne/src/lib.rs index cde427df9f..99246defe3 100644 --- a/lib/cretonne/src/lib.rs +++ b/lib/cretonne/src/lib.rs @@ -1,12 +1,7 @@ //! Cretonne code generation library. -#![deny(missing_docs, - trivial_numeric_casts, - unused_extern_crates)] - -#![cfg_attr(feature="clippy", - plugin(clippy(conf_file="../../clippy.toml")))] - +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] +#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr(feature="cargo-clippy", allow( // Rustfmt 0.9.0 is at odds with this lint: block_in_if_condition_stmt, diff --git a/lib/cretonne/src/licm.rs b/lib/cretonne/src/licm.rs index f0327296a1..546fc01bd8 100644 --- a/lib/cretonne/src/licm.rs +++ b/lib/cretonne/src/licm.rs @@ -1,7 +1,7 @@ //! A Loop Invariant Code Motion optimization pass use cursor::{Cursor, FuncCursor}; -use ir::{Function, Ebb, Inst, Value, Type, InstBuilder, Layout, Opcode, DataFlowGraph}; +use ir::{DataFlowGraph, Ebb, Function, Inst, InstBuilder, Layout, Opcode, Type, Value}; use flowgraph::ControlFlowGraph; use std::collections::HashSet; use dominator_tree::DominatorTree; @@ -121,7 +121,6 @@ fn has_pre_header( result } - // Change the destination of a jump or branch instruction. Does nothing if called with a non-jump // or non-branch instruction. fn change_branch_jump_destination(inst: Inst, new_ebb: Ebb, func: &mut Function) { diff --git a/lib/cretonne/src/loop_analysis.rs b/lib/cretonne/src/loop_analysis.rs index 431496b6e4..89d2939ac9 100644 --- a/lib/cretonne/src/loop_analysis.rs +++ b/lib/cretonne/src/loop_analysis.rs @@ -2,10 +2,10 @@ //! and parent in the loop tree. use dominator_tree::DominatorTree; -use entity::{PrimaryMap, Keys}; +use entity::{Keys, PrimaryMap}; use entity::EntityMap; use flowgraph::ControlFlowGraph; -use ir::{Function, Ebb, Layout}; +use ir::{Ebb, Function, Layout}; use packed_option::PackedOption; use timing; use std::vec::Vec; @@ -218,7 +218,6 @@ impl LoopAnalysis { } } } - } } } @@ -227,7 +226,7 @@ impl LoopAnalysis { mod test { use cursor::{Cursor, FuncCursor}; - use ir::{Function, InstBuilder, types}; + use ir::{types, Function, InstBuilder}; use loop_analysis::{Loop, LoopAnalysis}; use flowgraph::ControlFlowGraph; use dominator_tree::DominatorTree; @@ -257,7 +256,6 @@ mod test { cur.insert_ebb(ebb3); cur.ins().brnz(cond, ebb0, &[]); - } let mut loop_analysis = LoopAnalysis::new(); @@ -317,7 +315,6 @@ mod test { cur.insert_ebb(ebb5); cur.ins().brnz(cond, ebb0, &[]); - } let mut loop_analysis = LoopAnalysis::new(); diff --git a/lib/cretonne/src/postopt.rs b/lib/cretonne/src/postopt.rs index a95baefd3a..efe85d40d7 100644 --- a/lib/cretonne/src/postopt.rs +++ b/lib/cretonne/src/postopt.rs @@ -4,8 +4,8 @@ use cursor::{Cursor, EncCursor}; use ir::dfg::ValueDef; -use ir::{Function, InstructionData, Value, InstBuilder, Ebb, Inst}; -use ir::condcodes::{CondCode, IntCC, FloatCC}; +use ir::{Ebb, Function, Inst, InstBuilder, InstructionData, Value}; +use ir::condcodes::{CondCode, FloatCC, IntCC}; use ir::instructions::{Opcode, ValueList}; use ir::immediates::Imm64; use isa::TargetIsa; @@ -67,54 +67,48 @@ fn optimize_cpu_flags( cond, args: cmp_args, .. - } => { - CmpBrInfo { - br_inst: inst, - cmp_inst: cond_inst, - destination, - args: args.clone(), - cmp_arg: cmp_args[0], - invert_branch_cond, - kind: CmpBrKind::Icmp { - cond, - arg: cmp_args[1], - }, - } - } + } => CmpBrInfo { + br_inst: inst, + cmp_inst: cond_inst, + destination, + args: args.clone(), + cmp_arg: cmp_args[0], + invert_branch_cond, + kind: CmpBrKind::Icmp { + cond, + arg: cmp_args[1], + }, + }, InstructionData::IntCompareImm { cond, arg: cmp_arg, imm: cmp_imm, .. - } => { - CmpBrInfo { - br_inst: inst, - cmp_inst: cond_inst, - destination, - args: args.clone(), - cmp_arg, - invert_branch_cond, - kind: CmpBrKind::IcmpImm { cond, imm: cmp_imm }, - } - } + } => CmpBrInfo { + br_inst: inst, + cmp_inst: cond_inst, + destination, + args: args.clone(), + cmp_arg, + invert_branch_cond, + kind: CmpBrKind::IcmpImm { cond, imm: cmp_imm }, + }, InstructionData::FloatCompare { cond, args: cmp_args, .. - } => { - CmpBrInfo { - br_inst: inst, - cmp_inst: cond_inst, - destination, - args: args.clone(), - cmp_arg: cmp_args[0], - invert_branch_cond, - kind: CmpBrKind::Fcmp { - cond, - arg: cmp_args[1], - }, - } - } + } => CmpBrInfo { + br_inst: inst, + cmp_inst: cond_inst, + destination, + args: args.clone(), + cmp_arg: cmp_args[0], + invert_branch_cond, + kind: CmpBrKind::Fcmp { + cond, + arg: cmp_args[1], + }, + }, _ => return, } } else { @@ -179,7 +173,6 @@ fn optimize_cpu_flags( pos.func.update_encoding(info.br_inst, isa).is_ok(); } - //---------------------------------------------------------------------- // // The main post-opt pass. @@ -204,7 +197,6 @@ pub fn do_postopt(func: &mut Function, isa: &TargetIsa) { last_flags_clobber = Some(inst) } } - } } } diff --git a/lib/cretonne/src/preopt.rs b/lib/cretonne/src/preopt.rs index 34dab71c4a..81e798e987 100644 --- a/lib/cretonne/src/preopt.rs +++ b/lib/cretonne/src/preopt.rs @@ -4,15 +4,14 @@ use cursor::{Cursor, FuncCursor}; use ir::dfg::ValueDef; -use ir::{Function, InstructionData, Value, DataFlowGraph, InstBuilder, Type}; +use ir::{DataFlowGraph, Function, InstBuilder, InstructionData, Type, Value}; use ir::Inst; use ir::types::{I32, I64}; use ir::instructions::Opcode; -use divconst_magic_numbers::{MU32, MU64, MS32, MS64}; -use divconst_magic_numbers::{magicU32, magicU64, magicS32, magicS64}; +use divconst_magic_numbers::{MS32, MS64, MU32, MU64}; +use divconst_magic_numbers::{magicS32, magicS64, magicU32, magicU64}; use timing; - //---------------------------------------------------------------------- // // Pattern-match helpers and transformation for div and rem by constants. @@ -149,7 +148,6 @@ fn do_divrem_transformation(divrem_info: &DivRemByConstInfo, pos: &mut FuncCurso }; match *divrem_info { - // -------------------- U32 -------------------- // U32 div, rem by zero: ignore @@ -447,7 +445,6 @@ fn do_divrem_transformation(divrem_info: &DivRemByConstInfo, pos: &mut FuncCurso } } } - } } @@ -554,13 +551,11 @@ fn simplify(pos: &mut FuncCursor, inst: Inst) { } } - /// The main pre-opt pass. pub fn do_preopt(func: &mut Function) { let _tt = timing::preopt(); let mut pos = FuncCursor::new(func); while let Some(_ebb) = pos.next_ebb() { - while let Some(inst) = pos.next_inst() { // Apply basic simplifications. simplify(&mut pos, inst); diff --git a/lib/cretonne/src/regalloc/affinity.rs b/lib/cretonne/src/regalloc/affinity.rs index 7d85ae8721..0e49ac5f0b 100644 --- a/lib/cretonne/src/regalloc/affinity.rs +++ b/lib/cretonne/src/regalloc/affinity.rs @@ -10,7 +10,7 @@ use std::fmt; use ir::{AbiParam, ArgumentLoc}; -use isa::{TargetIsa, RegInfo, RegClassIndex, OperandConstraint, ConstraintKind}; +use isa::{ConstraintKind, OperandConstraint, RegClassIndex, RegInfo, TargetIsa}; /// Preferred register allocation for an SSA value. #[derive(Clone, Copy, Debug)] diff --git a/lib/cretonne/src/regalloc/allocatable_set.rs b/lib/cretonne/src/regalloc/allocatable_set.rs index 8c40809310..63b7a297d7 100644 --- a/lib/cretonne/src/regalloc/allocatable_set.rs +++ b/lib/cretonne/src/regalloc/allocatable_set.rs @@ -5,7 +5,7 @@ //! "register unit" abstraction. Every register contains one or more register units. Registers that //! share a register unit can't be in use at the same time. -use isa::registers::{RegInfo, RegUnit, RegUnitMask, RegClass}; +use isa::registers::{RegClass, RegInfo, RegUnit, RegUnitMask}; use std::char; use std::fmt; use std::iter::ExactSizeIterator; diff --git a/lib/cretonne/src/regalloc/coalescing.rs b/lib/cretonne/src/regalloc/coalescing.rs index f23d55433e..b8a7270d59 100644 --- a/lib/cretonne/src/regalloc/coalescing.rs +++ b/lib/cretonne/src/regalloc/coalescing.rs @@ -10,7 +10,7 @@ use dbg::DisplayList; use dominator_tree::{DominatorTree, DominatorTreePreorder}; use flowgraph::ControlFlowGraph; use ir::{self, InstBuilder, ProgramOrder}; -use ir::{Function, Ebb, Inst, Value, ExpandedProgramPoint}; +use ir::{Ebb, ExpandedProgramPoint, Function, Inst, Value}; use regalloc::affinity::Affinity; use regalloc::liveness::Liveness; use regalloc::virtregs::{VirtReg, VirtRegs}; @@ -19,7 +19,7 @@ use std::iter; use std::fmt; use std::slice; use std::vec::Vec; -use isa::{TargetIsa, EncInfo}; +use isa::{EncInfo, TargetIsa}; use timing; // # Implementation @@ -92,7 +92,6 @@ impl Coalescing { predecessors: Vec::new(), backedges: Vec::new(), } - } /// Clear all data structures in this coalescing pass. diff --git a/lib/cretonne/src/regalloc/coloring.rs b/lib/cretonne/src/regalloc/coloring.rs index d7ab5dd0f3..ad5952885d 100644 --- a/lib/cretonne/src/regalloc/coloring.rs +++ b/lib/cretonne/src/regalloc/coloring.rs @@ -44,10 +44,10 @@ use cursor::{Cursor, EncCursor}; use dominator_tree::DominatorTree; -use ir::{Ebb, Inst, Value, Function, Layout, ValueLoc, SigRef}; -use ir::{InstBuilder, AbiParam, ArgumentLoc, ValueDef}; -use isa::{RegUnit, RegClass, RegInfo, regs_overlap}; -use isa::{TargetIsa, EncInfo, RecipeConstraints, OperandConstraint, ConstraintKind}; +use ir::{Ebb, Function, Inst, Layout, SigRef, Value, ValueLoc}; +use ir::{AbiParam, ArgumentLoc, InstBuilder, ValueDef}; +use isa::{regs_overlap, RegClass, RegInfo, RegUnit}; +use isa::{ConstraintKind, EncInfo, OperandConstraint, RecipeConstraints, TargetIsa}; use packed_option::PackedOption; use regalloc::RegDiversions; use regalloc::affinity::Affinity; @@ -59,7 +59,6 @@ use regalloc::solver::{Solver, SolverError}; use std::mem; use timing; - /// Data structures for the coloring pass. /// /// These are scratch space data structures that can be reused between invocations. @@ -268,7 +267,6 @@ impl<'a> Context<'a> { abi.display(&self.reginfo) ); } - } // The spiller will have assigned an incoming stack slot already. Affinity::Stack => debug_assert!(abi.location.is_stack()), @@ -426,7 +424,6 @@ impl<'a> Context<'a> { self.iterate_solution(throughs, ®s.global, &mut replace_global_defines) }); - // The solution and/or fixed input constraints may require us to shuffle the set of live // registers around. self.shuffle_inputs(&mut regs.input); @@ -722,7 +719,6 @@ impl<'a> Context<'a> { ConstraintKind::Reg | ConstraintKind::Tied(_) | ConstraintKind::Stack => {} - } } } @@ -869,7 +865,6 @@ impl<'a> Context<'a> { self.solver.clear_all_global_flags(); } }; - } } diff --git a/lib/cretonne/src/regalloc/context.rs b/lib/cretonne/src/regalloc/context.rs index a8284a9579..cb29963e89 100644 --- a/lib/cretonne/src/regalloc/context.rs +++ b/lib/cretonne/src/regalloc/context.rs @@ -18,7 +18,7 @@ use regalloc::virtregs::VirtRegs; use result::CtonResult; use timing; use topo_order::TopoOrder; -use verifier::{verify_context, verify_liveness, verify_cssa, verify_locations}; +use verifier::{verify_context, verify_cssa, verify_liveness, verify_locations}; /// Persistent memory allocations for register allocation. pub struct Context { @@ -106,7 +106,6 @@ impl Context { verify_cssa(func, cfg, domtree, &self.liveness, &self.virtregs)?; } - // Pass: Spilling. self.spilling.run( isa, diff --git a/lib/cretonne/src/regalloc/diversion.rs b/lib/cretonne/src/regalloc/diversion.rs index 68fd04754e..d0b7e4db91 100644 --- a/lib/cretonne/src/regalloc/diversion.rs +++ b/lib/cretonne/src/regalloc/diversion.rs @@ -7,9 +7,9 @@ //! These register diversions are local to an EBB. No values can be diverted when entering a new //! EBB. -use ir::{Value, ValueLoc, ValueLocations, StackSlot}; +use ir::{StackSlot, Value, ValueLoc, ValueLocations}; use ir::{InstructionData, Opcode}; -use isa::{RegUnit, RegInfo}; +use isa::{RegInfo, RegUnit}; use std::fmt; use std::vec::Vec; diff --git a/lib/cretonne/src/regalloc/live_value_tracker.rs b/lib/cretonne/src/regalloc/live_value_tracker.rs index ee1f58944b..27a76deb5c 100644 --- a/lib/cretonne/src/regalloc/live_value_tracker.rs +++ b/lib/cretonne/src/regalloc/live_value_tracker.rs @@ -6,7 +6,7 @@ use dominator_tree::DominatorTree; use entity::{EntityList, ListPool}; -use ir::{Inst, Ebb, Value, DataFlowGraph, Layout, ExpandedProgramPoint}; +use ir::{DataFlowGraph, Ebb, ExpandedProgramPoint, Inst, Layout, Value}; use partition_slice::partition_slice; use regalloc::affinity::Affinity; use regalloc::liveness::Liveness; diff --git a/lib/cretonne/src/regalloc/liveness.rs b/lib/cretonne/src/regalloc/liveness.rs index 9a76cb5899..1b82d98bf8 100644 --- a/lib/cretonne/src/regalloc/liveness.rs +++ b/lib/cretonne/src/regalloc/liveness.rs @@ -178,10 +178,10 @@ use entity::SparseMap; use flowgraph::ControlFlowGraph; use ir::dfg::ValueDef; -use ir::{Function, Value, Inst, Ebb, Layout, ProgramPoint}; -use isa::{TargetIsa, EncInfo}; +use ir::{Ebb, Function, Inst, Layout, ProgramPoint, Value}; +use isa::{EncInfo, TargetIsa}; use regalloc::affinity::Affinity; -use regalloc::liverange::{LiveRange, LiveRangeForest, LiveRangeContext}; +use regalloc::liverange::{LiveRange, LiveRangeContext, LiveRangeForest}; use std::mem; use std::ops::Index; use std::vec::Vec; @@ -378,7 +378,6 @@ impl Liveness { mem::replace(&mut lr.affinity, Affinity::Stack) } - /// Compute the live ranges of all SSA values used in `func`. /// This clears out any existing analysis stored in this data structure. pub fn compute(&mut self, isa: &TargetIsa, func: &mut Function, cfg: &ControlFlowGraph) { diff --git a/lib/cretonne/src/regalloc/liverange.rs b/lib/cretonne/src/regalloc/liverange.rs index 2d66b010f7..79526c613d 100644 --- a/lib/cretonne/src/regalloc/liverange.rs +++ b/lib/cretonne/src/regalloc/liverange.rs @@ -109,7 +109,7 @@ use bforest; use entity::SparseMapValue; -use ir::{Inst, Ebb, Value, Layout, ProgramPoint, ExpandedProgramPoint, ProgramOrder}; +use ir::{Ebb, ExpandedProgramPoint, Inst, Layout, ProgramOrder, ProgramPoint, Value}; use regalloc::affinity::Affinity; use std::cmp::Ordering; @@ -457,9 +457,9 @@ impl SparseMapValue for GenLiveRange { mod tests { use super::{GenLiveRange, LiveRangeContext}; use bforest; - use ir::{Inst, Ebb, Value}; + use ir::{Ebb, Inst, Value}; use entity::EntityRef; - use ir::{ProgramOrder, ExpandedProgramPoint}; + use ir::{ExpandedProgramPoint, ProgramOrder}; use std::cmp::Ordering; use std::vec::Vec; @@ -543,7 +543,6 @@ mod tests { // Save for next round. prev_end = Some(end); } - } } diff --git a/lib/cretonne/src/regalloc/pressure.rs b/lib/cretonne/src/regalloc/pressure.rs index 67e0e99b70..6bbe2b75a5 100644 --- a/lib/cretonne/src/regalloc/pressure.rs +++ b/lib/cretonne/src/regalloc/pressure.rs @@ -36,7 +36,7 @@ // Remove once we're using the pressure tracker. #![allow(dead_code)] -use isa::registers::{RegInfo, MAX_TRACKED_TOPRCS, RegClass, RegClassMask}; +use isa::registers::{RegClass, RegClassMask, RegInfo, MAX_TRACKED_TOPRCS}; use regalloc::AllocatableSet; use std::cmp::min; use std::fmt; @@ -135,7 +135,7 @@ impl Pressure { /// `can_take()` to check again. fn check_avail(&self, rc: RegClass) -> RegClassMask { let entry = match self.toprc.get(rc.toprc as usize) { - None => return 0, // Not a pressure tracked bank. + None => return 0, // Not a pressure tracked bank. Some(e) => e, }; let mask = 1 << rc.toprc; @@ -269,7 +269,7 @@ impl fmt::Display for Pressure { #[cfg(test)] #[cfg(build_arm32)] mod tests { - use isa::{TargetIsa, RegClass}; + use isa::{RegClass, TargetIsa}; use regalloc::AllocatableSet; use std::borrow::Borrow; use super::Pressure; diff --git a/lib/cretonne/src/regalloc/reload.rs b/lib/cretonne/src/regalloc/reload.rs index 106830bc19..2ce9a04f75 100644 --- a/lib/cretonne/src/regalloc/reload.rs +++ b/lib/cretonne/src/regalloc/reload.rs @@ -12,10 +12,10 @@ use cursor::{Cursor, EncCursor}; use dominator_tree::DominatorTree; use entity::{SparseMap, SparseMapValue}; -use ir::{Ebb, Inst, Value, Function}; -use ir::{InstBuilder, AbiParam, ArgumentLoc}; +use ir::{Ebb, Function, Inst, Value}; +use ir::{AbiParam, ArgumentLoc, InstBuilder}; use isa::RegClass; -use isa::{TargetIsa, Encoding, EncInfo, RecipeConstraints, ConstraintKind}; +use isa::{ConstraintKind, EncInfo, Encoding, RecipeConstraints, TargetIsa}; use regalloc::affinity::Affinity; use regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; use regalloc::liveness::Liveness; diff --git a/lib/cretonne/src/regalloc/solver.rs b/lib/cretonne/src/regalloc/solver.rs index 3559623ae4..92b7a62679 100644 --- a/lib/cretonne/src/regalloc/solver.rs +++ b/lib/cretonne/src/regalloc/solver.rs @@ -350,7 +350,6 @@ impl Move { } } - /// Get the value being moved. fn value(&self) -> Value { match *self { @@ -1161,9 +1160,9 @@ impl fmt::Display for Solver { mod tests { use entity::EntityRef; use ir::Value; - use isa::{TargetIsa, RegClass, RegUnit, RegInfo}; + use isa::{RegClass, RegInfo, RegUnit, TargetIsa}; use regalloc::AllocatableSet; - use super::{Solver, Move}; + use super::{Move, Solver}; use std::boxed::Box; // Make an arm32 `TargetIsa`, if possible. @@ -1396,7 +1395,7 @@ mod tests { mov(v15, gpr, r5, r3), mov(v14, gpr, r4, r5), mov(v13, gpr, r1, r4), - fill(v10, gpr, 0, r1), // Finally complete cycle 1. + fill(v10, gpr, 0, r1) // Finally complete cycle 1. ] ); } diff --git a/lib/cretonne/src/regalloc/spilling.rs b/lib/cretonne/src/regalloc/spilling.rs index f616ea3b74..5a695eeb8b 100644 --- a/lib/cretonne/src/regalloc/spilling.rs +++ b/lib/cretonne/src/regalloc/spilling.rs @@ -17,9 +17,9 @@ use cursor::{Cursor, EncCursor}; use dominator_tree::DominatorTree; -use ir::{InstBuilder, Function, Ebb, Inst, Value, ValueLoc, SigRef}; -use isa::registers::{RegClassMask, RegClassIndex}; -use isa::{TargetIsa, RegInfo, EncInfo, RecipeConstraints, ConstraintKind}; +use ir::{Ebb, Function, Inst, InstBuilder, SigRef, Value, ValueLoc}; +use isa::registers::{RegClassIndex, RegClassMask}; +use isa::{ConstraintKind, EncInfo, RecipeConstraints, RegInfo, TargetIsa}; use regalloc::affinity::Affinity; use regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; use regalloc::liveness::Liveness; @@ -359,12 +359,10 @@ impl<'a> Context<'a> { if abi.location.is_reg() { let (rci, spilled) = match self.liveness[arg].affinity { Affinity::Reg(rci) => (rci, false), - Affinity::Stack => { - ( - self.cur.isa.regclass_for_abi_type(abi.value_type).into(), - true, - ) - } + Affinity::Stack => ( + self.cur.isa.regclass_for_abi_type(abi.value_type).into(), + true, + ), Affinity::None => panic!("Missing affinity for {}", arg), }; let mut reguse = RegUse::new(arg, fixed_args + idx, rci); diff --git a/lib/cretonne/src/regalloc/virtregs.rs b/lib/cretonne/src/regalloc/virtregs.rs index 8069a0b69b..4583effe4f 100644 --- a/lib/cretonne/src/regalloc/virtregs.rs +++ b/lib/cretonne/src/regalloc/virtregs.rs @@ -14,9 +14,9 @@ use dbg::DisplayList; use dominator_tree::DominatorTreePreorder; use entity::{EntityList, ListPool}; -use entity::{PrimaryMap, EntityMap, Keys}; +use entity::{EntityMap, Keys, PrimaryMap}; use entity::EntityRef; -use ir::{Value, Function}; +use ir::{Function, Value}; use packed_option::PackedOption; use ref_slice::ref_slice; use std::cmp::Ordering; diff --git a/lib/cretonne/src/scoped_hash_map.rs b/lib/cretonne/src/scoped_hash_map.rs index ded42672ab..4acc7087f0 100644 --- a/lib/cretonne/src/scoped_hash_map.rs +++ b/lib/cretonne/src/scoped_hash_map.rs @@ -4,7 +4,7 @@ //! container that has a concept of scopes that can be entered and exited, such that //! values inserted while inside a scope aren't visible outside the scope. -use std::collections::{HashMap, hash_map}; +use std::collections::{hash_map, HashMap}; use std::hash::Hash; use std::mem; diff --git a/lib/cretonne/src/settings.rs b/lib/cretonne/src/settings.rs index 20ba99e0d9..ed1d8cd168 100644 --- a/lib/cretonne/src/settings.rs +++ b/lib/cretonne/src/settings.rs @@ -357,18 +357,18 @@ mod tests { assert_eq!( f.to_string(), "[shared]\n\ - opt_level = \"default\"\n\ - enable_verifier = true\n\ - is_64bit = false\n\ - is_pic = false\n\ - return_at_end = false\n\ - avoid_div_traps = false\n\ - is_compressed = false\n\ - enable_float = true\n\ - enable_simd = true\n\ - enable_atomics = true\n\ - spiderwasm_prologue_words = 0\n\ - allones_funcaddrs = false\n" + opt_level = \"default\"\n\ + enable_verifier = true\n\ + is_64bit = false\n\ + is_pic = false\n\ + return_at_end = false\n\ + avoid_div_traps = false\n\ + is_compressed = false\n\ + enable_float = true\n\ + enable_simd = true\n\ + enable_atomics = true\n\ + spiderwasm_prologue_words = 0\n\ + allones_funcaddrs = false\n" ); assert_eq!(f.opt_level(), super::OptLevel::Default); assert_eq!(f.enable_simd(), true); diff --git a/lib/cretonne/src/simple_gvn.rs b/lib/cretonne/src/simple_gvn.rs index 1cd82e4b2c..073101cd9c 100644 --- a/lib/cretonne/src/simple_gvn.rs +++ b/lib/cretonne/src/simple_gvn.rs @@ -2,7 +2,7 @@ use cursor::{Cursor, FuncCursor}; use dominator_tree::DominatorTree; -use ir::{InstructionData, Function, Inst, Opcode, Type}; +use ir::{Function, Inst, InstructionData, Opcode, Type}; use scoped_hash_map::ScopedHashMap; use timing; use std::vec::Vec; diff --git a/lib/cretonne/src/stack_layout.rs b/lib/cretonne/src/stack_layout.rs index 0cf6e77527..9d723791d7 100644 --- a/lib/cretonne/src/stack_layout.rs +++ b/lib/cretonne/src/stack_layout.rs @@ -1,9 +1,9 @@ //! Computing stack layout. use ir::StackSlots; -use ir::stackslot::{StackSize, StackOffset, StackSlotKind}; +use ir::stackslot::{StackOffset, StackSize, StackSlotKind}; use result::CtonError; -use std::cmp::{min, max}; +use std::cmp::{max, min}; /// Compute the stack frame layout. /// @@ -110,7 +110,7 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result Verifier<'a> { } fn ebb_integrity(&self, ebb: Ebb, inst: Inst) -> Result { - let is_terminator = self.func.dfg[inst].opcode().is_terminator(); let is_last_inst = self.func.layout.last_inst(ebb) == Some(inst); @@ -1155,7 +1154,7 @@ impl<'a> Verifier<'a> { #[cfg(test)] mod tests { - use super::{Verifier, Error}; + use super::{Error, Verifier}; use ir::Function; use ir::instructions::{InstructionData, Opcode}; use entity::EntityList; diff --git a/lib/cretonne/src/write.rs b/lib/cretonne/src/write.rs index 87316c8ca4..dee3ab0346 100644 --- a/lib/cretonne/src/write.rs +++ b/lib/cretonne/src/write.rs @@ -3,9 +3,9 @@ //! The `write` module provides the `write_function` function which converts an IR `Function` to an //! equivalent textual form. This textual form can be read back by the `cretonne-reader` crate. -use ir::{Function, DataFlowGraph, Ebb, Inst, Value, ValueDef, Type, SigRef}; -use isa::{TargetIsa, RegInfo}; -use std::fmt::{self, Result, Error, Write}; +use ir::{DataFlowGraph, Ebb, Function, Inst, SigRef, Type, Value, ValueDef}; +use isa::{RegInfo, TargetIsa}; +use std::fmt::{self, Error, Result, Write}; use std::result; use packed_option::ReservedValue; use std::string::String; @@ -146,7 +146,6 @@ pub fn write_ebb(w: &mut Write, func: &Function, isa: Option<&TargetIsa>, ebb: E Ok(()) } - //---------------------------------------------------------------------- // // Instructions @@ -452,7 +451,7 @@ impl<'a> fmt::Display for DisplayValues<'a> { #[cfg(test)] mod tests { - use ir::{Function, ExternalName, StackSlotData, StackSlotKind}; + use ir::{ExternalName, Function, StackSlotData, StackSlotKind}; use ir::types; use std::string::ToString; diff --git a/lib/filetests/src/concurrent.rs b/lib/filetests/src/concurrent.rs index 1db5aa6832..a93d39cddf 100644 --- a/lib/filetests/src/concurrent.rs +++ b/lib/filetests/src/concurrent.rs @@ -6,12 +6,12 @@ use cretonne::timing; use std::panic::catch_unwind; use std::path::{Path, PathBuf}; -use std::sync::mpsc::{channel, Sender, Receiver}; +use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use num_cpus; -use {TestResult, runone}; +use {runone, TestResult}; /// Request sent to worker threads contains jobid and path. struct Request(usize, PathBuf); diff --git a/lib/filetests/src/runner.rs b/lib/filetests/src/runner.rs index d2d2db55c7..f9e8fb3638 100644 --- a/lib/filetests/src/runner.rs +++ b/lib/filetests/src/runner.rs @@ -8,7 +8,7 @@ use std::fmt::{self, Display}; use std::ffi::OsStr; use std::path::{Path, PathBuf}; use std::time; -use {TestResult, runone}; +use {runone, TestResult}; use concurrent::{ConcurrentRunner, Reply}; /// Timeout in seconds when we're not making progress. @@ -302,7 +302,6 @@ impl TestRunner { // Inter-quartile range. let iqr = q3 - q1; - // Cut-off for what we consider a 'slow' test: 3 IQR from the 75% quartile. // // Q3 + 1.5 IQR are the data points that would be plotted as outliers outside a box plot, @@ -319,7 +318,6 @@ impl TestRunner { { println!("slow: {}", t) } - } /// Scan pushed directories for tests and run them. diff --git a/lib/filetests/src/runone.rs b/lib/filetests/src/runone.rs index dab44ff920..4b3033ea2e 100644 --- a/lib/filetests/src/runone.rs +++ b/lib/filetests/src/runone.rs @@ -13,8 +13,8 @@ use cretonne::verify_function; use cretonne::print_errors::pretty_verifier_error; use cton_reader::parse_test; use cton_reader::IsaSpec; -use {TestResult, new_subtest}; -use subtest::{SubTest, Context, Result}; +use {new_subtest, TestResult}; +use subtest::{Context, Result, SubTest}; /// Read an entire file into a string. fn read_to_string>(path: P) -> io::Result { @@ -82,7 +82,6 @@ pub fn run(path: &Path) -> TestResult { run_one_test(last_tuple, Cow::Owned(func), &mut context)?; } - Ok(started.elapsed()) } diff --git a/lib/filetests/src/subtest.rs b/lib/filetests/src/subtest.rs index 39812ed228..4395780021 100644 --- a/lib/filetests/src/subtest.rs +++ b/lib/filetests/src/subtest.rs @@ -5,8 +5,8 @@ use std::borrow::Cow; use cretonne::ir::Function; use cretonne::isa::TargetIsa; use cretonne::settings::{Flags, FlagsOrIsa}; -use cton_reader::{Details, Comment}; -use filecheck::{CheckerBuilder, Checker, NO_VARIABLES}; +use cton_reader::{Comment, Details}; +use filecheck::{Checker, CheckerBuilder, NO_VARIABLES}; pub type Result = result::Result; diff --git a/lib/filetests/src/test_binemit.rs b/lib/filetests/src/test_binemit.rs index 81e48f84fe..db3d9be634 100644 --- a/lib/filetests/src/test_binemit.rs +++ b/lib/filetests/src/test_binemit.rs @@ -13,7 +13,7 @@ use cretonne::ir::entities::AnyEntity; use cretonne::binemit::RegDiversions; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result}; +use subtest::{Context, Result, SubTest}; use match_directive::match_directive; struct TestBinEmit; @@ -43,8 +43,6 @@ impl TextSink { } } - - impl binemit::CodeSink for TextSink { fn offset(&self) -> binemit::CodeOffset { self.offset @@ -80,23 +78,11 @@ impl binemit::CodeSink for TextSink { name: &ir::ExternalName, addend: binemit::Addend, ) { - write!( - self.text, - "{}({}", - reloc, - name, - ).unwrap(); + write!(self.text, "{}({}", reloc, name,).unwrap(); if addend != 0 { - write!( - self.text, - "{:+}", - addend, - ).unwrap(); + write!(self.text, "{:+}", addend,).unwrap(); } - write!( - self.text, - ") ", - ).unwrap(); + write!(self.text, ") ",).unwrap(); } fn reloc_jt(&mut self, reloc: binemit::Reloc, jt: ir::JumpTable) { @@ -278,10 +264,10 @@ impl SubTest for TestBinEmit { )); } return Err(format!( - "No matching encodings for {} in {}", - func.dfg.display_inst(inst, isa), - DisplayList(&encodings), - )); + "No matching encodings for {} in {}", + func.dfg.display_inst(inst, isa), + DisplayList(&encodings), + )); } let have = sink.text.trim(); if have != want { diff --git a/lib/filetests/src/test_cat.rs b/lib/filetests/src/test_cat.rs index fbbcbd034b..42b18b3625 100644 --- a/lib/filetests/src/test_cat.rs +++ b/lib/filetests/src/test_cat.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use cretonne::ir::Function; use cton_reader::TestCommand; -use subtest::{self, SubTest, Context, Result as STResult}; +use subtest::{self, Context, Result as STResult, SubTest}; /// Object implementing the `test cat` sub-test. /// diff --git a/lib/filetests/src/test_compile.rs b/lib/filetests/src/test_compile.rs index af2343f765..5217f7ebb6 100644 --- a/lib/filetests/src/test_compile.rs +++ b/lib/filetests/src/test_compile.rs @@ -7,7 +7,7 @@ use cretonne::ir; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_dce.rs b/lib/filetests/src/test_dce.rs index 5a57d83e3e..4e826c9abc 100644 --- a/lib/filetests/src/test_dce.rs +++ b/lib/filetests/src/test_dce.rs @@ -9,7 +9,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_domtree.rs b/lib/filetests/src/test_domtree.rs index 6eae539644..fed38d9d50 100644 --- a/lib/filetests/src/test_domtree.rs +++ b/lib/filetests/src/test_domtree.rs @@ -17,7 +17,7 @@ use cretonne::flowgraph::ControlFlowGraph; use cretonne::ir::Function; use cretonne::ir::entities::AnyEntity; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fmt::{self, Write}; @@ -76,7 +76,7 @@ impl SubTest for TestDomtree { Some(got_inst) if got_inst != inst => { return Err(format!( "mismatching idoms for {}:\n\ - want: {}, got: {}", + want: {}, got: {}", src_ebb, inst, got_inst @@ -85,7 +85,7 @@ impl SubTest for TestDomtree { None => { return Err(format!( "mismatching idoms for {}:\n\ - want: {}, got: unreachable", + want: {}, got: unreachable", src_ebb, inst )); @@ -105,7 +105,7 @@ impl SubTest for TestDomtree { if let Some(got_inst) = domtree.idom(ebb) { return Err(format!( "mismatching idoms for renumbered {}:\n\ - want: unrechable, got: {}", + want: unrechable, got: {}", ebb, got_inst )); diff --git a/lib/filetests/src/test_legalizer.rs b/lib/filetests/src/test_legalizer.rs index 08f6c53ae4..76bd9f491b 100644 --- a/lib/filetests/src/test_legalizer.rs +++ b/lib/filetests/src/test_legalizer.rs @@ -8,7 +8,7 @@ use cretonne; use cretonne::ir::Function; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::fmt::Write; struct TestLegalizer; diff --git a/lib/filetests/src/test_licm.rs b/lib/filetests/src/test_licm.rs index f7d4397b5a..bed36b44c2 100644 --- a/lib/filetests/src/test_licm.rs +++ b/lib/filetests/src/test_licm.rs @@ -9,7 +9,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_postopt.rs b/lib/filetests/src/test_postopt.rs index 34ffb3f462..ad26a06c30 100644 --- a/lib/filetests/src/test_postopt.rs +++ b/lib/filetests/src/test_postopt.rs @@ -6,7 +6,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_preopt.rs b/lib/filetests/src/test_preopt.rs index c141d28480..8a30f0feb3 100644 --- a/lib/filetests/src/test_preopt.rs +++ b/lib/filetests/src/test_preopt.rs @@ -6,7 +6,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_print_cfg.rs b/lib/filetests/src/test_print_cfg.rs index b043dc58b2..4c0b3250d2 100644 --- a/lib/filetests/src/test_print_cfg.rs +++ b/lib/filetests/src/test_print_cfg.rs @@ -8,7 +8,7 @@ use std::borrow::Cow; use cretonne::ir::Function; use cretonne::cfg_printer::CFGPrinter; use cton_reader::TestCommand; -use subtest::{self, SubTest, Context, Result as STResult}; +use subtest::{self, Context, Result as STResult, SubTest}; /// Object implementing the `test print-cfg` sub-test. struct TestPrintCfg; diff --git a/lib/filetests/src/test_regalloc.rs b/lib/filetests/src/test_regalloc.rs index 7cd0788928..e94a142dcc 100644 --- a/lib/filetests/src/test_regalloc.rs +++ b/lib/filetests/src/test_regalloc.rs @@ -9,7 +9,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_simple_gvn.rs b/lib/filetests/src/test_simple_gvn.rs index f967c3fa91..04fcb078dd 100644 --- a/lib/filetests/src/test_simple_gvn.rs +++ b/lib/filetests/src/test_simple_gvn.rs @@ -9,7 +9,7 @@ use cretonne::ir::Function; use cretonne; use cretonne::print_errors::pretty_error; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result, run_filecheck}; +use subtest::{run_filecheck, Context, Result, SubTest}; use std::borrow::Cow; use std::fmt::Write; diff --git a/lib/filetests/src/test_verifier.rs b/lib/filetests/src/test_verifier.rs index 6db9c681ce..906b279408 100644 --- a/lib/filetests/src/test_verifier.rs +++ b/lib/filetests/src/test_verifier.rs @@ -13,7 +13,7 @@ use std::borrow::{Borrow, Cow}; use cretonne::verify_function; use cretonne::ir::Function; use cton_reader::TestCommand; -use subtest::{SubTest, Context, Result}; +use subtest::{Context, Result, SubTest}; use match_directive::match_directive; struct TestVerifier; diff --git a/lib/frontend/src/frontend.rs b/lib/frontend/src/frontend.rs index 37d2fe0206..00e5de53f1 100644 --- a/lib/frontend/src/frontend.rs +++ b/lib/frontend/src/frontend.rs @@ -1,13 +1,13 @@ //! A frontend for building Cretonne IR from other languages. use cretonne::cursor::{Cursor, FuncCursor}; use cretonne::ir; -use cretonne::ir::{Ebb, Type, Value, Function, Inst, JumpTable, StackSlot, JumpTableData, - StackSlotData, DataFlowGraph, InstructionData, ExtFuncData, FuncRef, SigRef, - Signature, InstBuilderBase, GlobalVarData, GlobalVar, HeapData, Heap}; +use cretonne::ir::{DataFlowGraph, Ebb, ExtFuncData, FuncRef, Function, GlobalVar, GlobalVarData, + Heap, HeapData, Inst, InstBuilderBase, InstructionData, JumpTable, + JumpTableData, SigRef, Signature, StackSlot, StackSlotData, Type, Value}; use cretonne::ir::function::DisplayFunction; use cretonne::isa::TargetIsa; -use ssa::{SSABuilder, SideEffects, Block}; -use cretonne::entity::{EntityRef, EntityMap, EntitySet}; +use ssa::{Block, SSABuilder, SideEffects}; +use cretonne::entity::{EntityMap, EntityRef, EntitySet}; use cretonne::packed_option::PackedOption; /// Structure used for translating a series of functions into Cretonne IR. @@ -28,7 +28,6 @@ where types: EntityMap, } - /// Temporary object used to build a single Cretonne IR `Function`. pub struct FunctionBuilder<'a, Variable: 'a> where @@ -125,7 +124,8 @@ where } impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long, Variable> - where Variable: EntityRef +where + Variable: EntityRef, { fn data_flow_graph(&self) -> &DataFlowGraph { &self.builder.func.dfg @@ -165,13 +165,14 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short // multiple times, so we must deduplicate. let mut unique = EntitySet::::new(); for dest_ebb in self.builder - .func - .jump_tables - .get(table) - .expect("you are referencing an undeclared jump table") - .entries() - .map(|(_, ebb)| ebb) - .filter(|dest_ebb| unique.insert(*dest_ebb)) { + .func + .jump_tables + .get(table) + .expect("you are referencing an undeclared jump table") + .entries() + .map(|(_, ebb)| ebb) + .filter(|dest_ebb| unique.insert(*dest_ebb)) + { self.builder.func_ctx.ssa.declare_ebb_predecessor( dest_ebb, self.builder.position.basic_block.unwrap(), @@ -592,9 +593,9 @@ where mod tests { use cretonne::entity::EntityRef; - use cretonne::ir::{ExternalName, Function, CallConv, Signature, AbiParam, InstBuilder}; + use cretonne::ir::{AbiParam, CallConv, ExternalName, Function, InstBuilder, Signature}; use cretonne::ir::types::*; - use frontend::{FunctionBuilderContext, FunctionBuilder}; + use frontend::{FunctionBuilder, FunctionBuilderContext}; use cretonne::verifier::verify_function; use cretonne::settings; use Variable; diff --git a/lib/frontend/src/lib.rs b/lib/frontend/src/lib.rs index 628195428a..329b6afb50 100644 --- a/lib/frontend/src/lib.rs +++ b/lib/frontend/src/lib.rs @@ -127,16 +127,12 @@ //! } //! ``` -#![deny(missing_docs, - trivial_numeric_casts, - unused_extern_crates)] - -#![cfg_attr(feature="cargo-clippy", - allow(new_without_default, redundant_field_names))] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] +#![cfg_attr(feature = "cargo-clippy", allow(new_without_default, redundant_field_names))] extern crate cretonne; -pub use frontend::{FunctionBuilderContext, FunctionBuilder}; +pub use frontend::{FunctionBuilder, FunctionBuilderContext}; pub use variable::Variable; mod frontend; diff --git a/lib/frontend/src/ssa.rs b/lib/frontend/src/ssa.rs index 6fa59e784d..96085c38f8 100644 --- a/lib/frontend/src/ssa.rs +++ b/lib/frontend/src/ssa.rs @@ -6,9 +6,9 @@ //! Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg use cretonne::cursor::{Cursor, FuncCursor}; -use cretonne::ir::{Ebb, Value, Inst, Type, Function, InstBuilder}; +use cretonne::ir::{Ebb, Function, Inst, InstBuilder, Type, Value}; use cretonne::ir::instructions::BranchInfo; -use cretonne::entity::{EntityRef, PrimaryMap, EntityMap}; +use cretonne::entity::{EntityMap, EntityRef, PrimaryMap}; use cretonne::packed_option::PackedOption; use cretonne::packed_option::ReservedValue; use std::u32; @@ -715,7 +715,7 @@ where mod tests { use cretonne::cursor::{Cursor, FuncCursor}; use cretonne::entity::EntityRef; - use cretonne::ir::{Function, InstBuilder, Inst, JumpTableData, Opcode}; + use cretonne::ir::{Function, Inst, InstBuilder, JumpTableData, Opcode}; use cretonne::ir::types::*; use cretonne::verify_function; use cretonne::ir::instructions::BranchInfo; @@ -960,7 +960,6 @@ mod tests { assert_eq!(func.dfg.ebb_params(ebb1)[0], z2); assert_eq!(func.dfg.ebb_params(ebb1)[1], y3); assert_eq!(func.dfg.resolve_aliases(x3), x1); - } #[test] diff --git a/lib/native/src/lib.rs b/lib/native/src/lib.rs index ea828ea252..15f3e69350 100644 --- a/lib/native/src/lib.rs +++ b/lib/native/src/lib.rs @@ -1,9 +1,7 @@ //! Performs autodetection of the host for the purposes of running //! Cretonne to generate code to run on the same machine. -#![deny(missing_docs, - trivial_numeric_casts, - unused_extern_crates)] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] extern crate cretonne; diff --git a/lib/reader/src/isaspec.rs b/lib/reader/src/isaspec.rs index 2b1e8fae6d..6cc29a81a1 100644 --- a/lib/reader/src/isaspec.rs +++ b/lib/reader/src/isaspec.rs @@ -6,9 +6,9 @@ //! If a test case file contains `isa` commands, the tests will only be run against the specified //! ISAs. If the file contains no `isa` commands, the tests will be run against all supported ISAs. -use cretonne::settings::{Flags, Configurable, Error as SetError}; +use cretonne::settings::{Configurable, Error as SetError, Flags}; use cretonne::isa::TargetIsa; -use error::{Result, Location}; +use error::{Location, Result}; use testcommand::TestOption; /// The ISA specifications in a `.cton` file. diff --git a/lib/reader/src/lexer.rs b/lib/reader/src/lexer.rs index 4b1a952d1b..c55bbf1dd4 100644 --- a/lib/reader/src/lexer.rs +++ b/lib/reader/src/lexer.rs @@ -5,7 +5,7 @@ use std::u16; #[allow(unused_imports)] use std::ascii::AsciiExt; use cretonne::ir::types; -use cretonne::ir::{Value, Ebb}; +use cretonne::ir::{Ebb, Value}; use error::Location; /// A Token returned from the `Lexer`. @@ -458,7 +458,7 @@ mod tests { use super::trailing_digits; use super::*; use cretonne::ir::types; - use cretonne::ir::{Value, Ebb}; + use cretonne::ir::{Ebb, Value}; use error::Location; #[test] @@ -556,7 +556,7 @@ mod tests { fn lex_identifiers() { let mut lex = Lexer::new( "v0 v00 vx01 ebb1234567890 ebb5234567890 v1x vx1 vxvx4 \ - function0 function b1 i32x4 f32x5 \ + function0 function b1 i32x4 f32x5 \ iflags fflags iflagss", ); assert_eq!( diff --git a/lib/reader/src/lib.rs b/lib/reader/src/lib.rs index d6c23cfa81..58fe21b5ce 100644 --- a/lib/reader/src/lib.rs +++ b/lib/reader/src/lib.rs @@ -3,17 +3,15 @@ //! The `cton_reader` library supports reading .cton files. This functionality is needed for testing //! Cretonne, but is not essential for a JIT compiler. -#![deny(missing_docs, - trivial_numeric_casts, - unused_extern_crates)] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] extern crate cretonne; -pub use error::{Location, Result, Error}; +pub use error::{Error, Location, Result}; pub use parser::{parse_functions, parse_test}; pub use testcommand::{TestCommand, TestOption}; -pub use testfile::{TestFile, Details, Comment}; -pub use isaspec::{IsaSpec, parse_options}; +pub use testfile::{Comment, Details, TestFile}; +pub use isaspec::{parse_options, IsaSpec}; pub use sourcemap::SourceMap; mod error; diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index c9da49d9ee..48e2e2745b 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -3,22 +3,21 @@ use std::str::FromStr; use std::{u16, u32}; use std::mem; -use cretonne::ir::{Function, Ebb, Opcode, Value, Type, ExternalName, CallConv, StackSlotData, - StackSlotKind, JumpTable, JumpTableData, Signature, AbiParam, - ArgumentExtension, ExtFuncData, SigRef, FuncRef, StackSlot, ValueLoc, - ArgumentLoc, MemFlags, GlobalVar, GlobalVarData, Heap, HeapData, HeapStyle, - HeapBase}; +use cretonne::ir::{AbiParam, ArgumentExtension, ArgumentLoc, CallConv, Ebb, ExtFuncData, + ExternalName, FuncRef, Function, GlobalVar, GlobalVarData, Heap, HeapBase, + HeapData, HeapStyle, JumpTable, JumpTableData, MemFlags, Opcode, SigRef, + Signature, StackSlot, StackSlotData, StackSlotKind, Type, Value, ValueLoc}; use cretonne::ir; use cretonne::ir::types::VOID; -use cretonne::ir::immediates::{Imm64, Uimm32, Offset32, Ieee32, Ieee64}; +use cretonne::ir::immediates::{Ieee32, Ieee64, Imm64, Offset32, Uimm32}; use cretonne::ir::entities::AnyEntity; -use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs}; -use cretonne::isa::{self, TargetIsa, Encoding, RegUnit}; +use cretonne::ir::instructions::{InstructionData, InstructionFormat, VariableArgs}; +use cretonne::isa::{self, Encoding, RegUnit, TargetIsa}; use cretonne::{settings, timing}; use cretonne::entity::EntityRef; use cretonne::packed_option::ReservedValue; -use testfile::{TestFile, Details, Comment}; -use error::{Location, Error, Result}; +use testfile::{Comment, Details, TestFile}; +use error::{Error, Location, Result}; use lexer::{self, Lexer, Token}; use testcommand::TestCommand; use isaspec; @@ -1189,12 +1188,12 @@ impl<'a> Parser<'a> { } "bound" => { data.style = match style_name { - "dynamic" => { - HeapStyle::Dynamic { bound_gv: self.match_gv("expected gv bound")? } - } - "static" => { - HeapStyle::Static { bound: self.match_imm64("expected integer bound")? } - } + "dynamic" => HeapStyle::Dynamic { + bound_gv: self.match_gv("expected gv bound")?, + }, + "static" => HeapStyle::Static { + bound: self.match_imm64("expected integer bound")?, + }, t => return err!(self.loc, "unknown heap style '{}'", t), }; } @@ -1736,7 +1735,7 @@ impl<'a> Parser<'a> { return err!( self.loc, "instruction produces {} result values, but {} locations were \ - specified", + specified", results.len(), result_locations.len() ); @@ -1791,7 +1790,7 @@ impl<'a> Parser<'a> { return err!( self.loc, "type variable required for polymorphic opcode, e.g. '{}.{}'; \ - can't infer from {} which is not yet defined", + can't infer from {} which is not yet defined", opcode, constraints.ctrl_typeset().unwrap().example(), ctrl_src_value @@ -1801,7 +1800,7 @@ impl<'a> Parser<'a> { return err!( self.loc, "type variable required for polymorphic opcode, e.g. '{}.{}'; \ - can't infer from {} which is not yet resolved", + can't infer from {} which is not yet resolved", opcode, constraints.ctrl_typeset().unwrap().example(), ctrl_src_value @@ -1890,36 +1889,26 @@ impl<'a> Parser<'a> { opcode: Opcode, ) -> Result { let idata = match opcode.format() { - InstructionFormat::Unary => { - InstructionData::Unary { - opcode, - arg: self.match_value("expected SSA value operand")?, - } - } - InstructionFormat::UnaryImm => { - InstructionData::UnaryImm { - opcode, - imm: self.match_imm64("expected immediate integer operand")?, - } - } - InstructionFormat::UnaryIeee32 => { - InstructionData::UnaryIeee32 { - opcode, - imm: self.match_ieee32("expected immediate 32-bit float operand")?, - } - } - InstructionFormat::UnaryIeee64 => { - InstructionData::UnaryIeee64 { - opcode, - imm: self.match_ieee64("expected immediate 64-bit float operand")?, - } - } - InstructionFormat::UnaryBool => { - InstructionData::UnaryBool { - opcode, - imm: self.match_bool("expected immediate boolean operand")?, - } - } + InstructionFormat::Unary => InstructionData::Unary { + opcode, + arg: self.match_value("expected SSA value operand")?, + }, + InstructionFormat::UnaryImm => InstructionData::UnaryImm { + opcode, + imm: self.match_imm64("expected immediate integer operand")?, + }, + InstructionFormat::UnaryIeee32 => InstructionData::UnaryIeee32 { + opcode, + imm: self.match_ieee32("expected immediate 32-bit float operand")?, + }, + InstructionFormat::UnaryIeee64 => InstructionData::UnaryIeee64 { + opcode, + imm: self.match_ieee64("expected immediate 64-bit float operand")?, + }, + InstructionFormat::UnaryBool => InstructionData::UnaryBool { + opcode, + imm: self.match_bool("expected immediate boolean operand")?, + }, InstructionFormat::UnaryGlobalVar => { let gv = self.match_gv("expected global variable")?; ctx.check_gv(gv, &self.loc)?; @@ -2406,11 +2395,11 @@ impl<'a> Parser<'a> { #[cfg(test)] mod tests { use super::*; - use cretonne::ir::{CallConv, ArgumentExtension, ArgumentPurpose}; + use cretonne::ir::{ArgumentExtension, ArgumentPurpose, CallConv}; use cretonne::ir::types; use cretonne::ir::StackSlotKind; use cretonne::ir::entities::AnyEntity; - use testfile::{Details, Comment}; + use testfile::{Comment, Details}; use isaspec::IsaSpec; use error::Error; diff --git a/lib/reader/src/sourcemap.rs b/lib/reader/src/sourcemap.rs index 36fb954fd9..b30b172768 100644 --- a/lib/reader/src/sourcemap.rs +++ b/lib/reader/src/sourcemap.rs @@ -7,8 +7,8 @@ //! to parser clients. use cretonne::ir::entities::AnyEntity; -use cretonne::ir::{StackSlot, GlobalVar, Heap, JumpTable, Ebb, Value, SigRef, FuncRef}; -use error::{Result, Location}; +use cretonne::ir::{Ebb, FuncRef, GlobalVar, Heap, JumpTable, SigRef, StackSlot, Value}; +use error::{Location, Result}; use lexer::split_entity_name; use std::collections::HashMap; diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index 97f67d6c48..82fec54e5b 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -22,16 +22,16 @@ //! //! That is why `translate_function_body` takes an object having the `WasmRuntime` trait as //! argument. -use cretonne::ir::{self, InstBuilder, MemFlags, JumpTableData}; +use cretonne::ir::{self, InstBuilder, JumpTableData, MemFlags}; use cretonne::ir::types::*; -use cretonne::ir::condcodes::{IntCC, FloatCC}; +use cretonne::ir::condcodes::{FloatCC, IntCC}; use cretonne::packed_option::ReservedValue; use cton_frontend::{FunctionBuilder, Variable}; -use wasmparser::{Operator, MemoryImmediate}; -use translation_utils::{f32_translation, f64_translation, type_to_type, num_return_values}; -use translation_utils::{TableIndex, SignatureIndex, FunctionIndex, MemoryIndex}; -use state::{TranslationState, ControlStackFrame}; -use std::collections::{HashMap, hash_map}; +use wasmparser::{MemoryImmediate, Operator}; +use translation_utils::{num_return_values, type_to_type, f32_translation, f64_translation}; +use translation_utils::{FunctionIndex, MemoryIndex, SignatureIndex, TableIndex}; +use state::{ControlStackFrame, TranslationState}; +use std::collections::{hash_map, HashMap}; use environ::{FuncEnvironment, GlobalValue}; use std::{i32, u32}; use std::vec::Vec; diff --git a/lib/wasm/src/environ/dummy.rs b/lib/wasm/src/environ/dummy.rs index bb21b7536a..b24499bde0 100644 --- a/lib/wasm/src/environ/dummy.rs +++ b/lib/wasm/src/environ/dummy.rs @@ -1,8 +1,8 @@ //! "Dummy" environment for testing wasm translation. use environ::{FuncEnvironment, GlobalValue, ModuleEnvironment}; -use translation_utils::{Global, Memory, Table, GlobalIndex, TableIndex, SignatureIndex, - FunctionIndex, MemoryIndex}; +use translation_utils::{FunctionIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, + Table, TableIndex}; use func_translator::FuncTranslator; use cretonne::ir::{self, InstBuilder}; use cretonne::ir::types::*; diff --git a/lib/wasm/src/environ/mod.rs b/lib/wasm/src/environ/mod.rs index f45dbd3161..57c9f593b2 100644 --- a/lib/wasm/src/environ/mod.rs +++ b/lib/wasm/src/environ/mod.rs @@ -3,5 +3,5 @@ mod spec; mod dummy; -pub use environ::spec::{ModuleEnvironment, FuncEnvironment, GlobalValue}; +pub use environ::spec::{FuncEnvironment, GlobalValue, ModuleEnvironment}; pub use environ::dummy::DummyEnvironment; diff --git a/lib/wasm/src/environ/spec.rs b/lib/wasm/src/environ/spec.rs index 233188364a..882ca1a30f 100644 --- a/lib/wasm/src/environ/spec.rs +++ b/lib/wasm/src/environ/spec.rs @@ -3,8 +3,8 @@ use cretonne::ir::{self, InstBuilder}; use cretonne::cursor::FuncCursor; use cretonne::settings::Flags; -use translation_utils::{SignatureIndex, FunctionIndex, TableIndex, GlobalIndex, MemoryIndex, - Global, Table, Memory}; +use translation_utils::{FunctionIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, + Table, TableIndex}; use std::vec::Vec; use std::string::String; diff --git a/lib/wasm/src/func_translator.rs b/lib/wasm/src/func_translator.rs index dbb1fc9bcc..159d8120d1 100644 --- a/lib/wasm/src/func_translator.rs +++ b/lib/wasm/src/func_translator.rs @@ -6,10 +6,10 @@ use code_translator::translate_operator; use cretonne::entity::EntityRef; -use cretonne::ir::{self, InstBuilder, Ebb}; -use cretonne::result::{CtonResult, CtonError}; +use cretonne::ir::{self, Ebb, InstBuilder}; +use cretonne::result::{CtonError, CtonResult}; use cretonne::timing; -use cton_frontend::{FunctionBuilderContext, FunctionBuilder, Variable}; +use cton_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; use environ::FuncEnvironment; use state::TranslationState; use wasmparser::{self, BinaryReader}; diff --git a/lib/wasm/src/lib.rs b/lib/wasm/src/lib.rs index cc35a19fbc..6f0ed8fd70 100644 --- a/lib/wasm/src/lib.rs +++ b/lib/wasm/src/lib.rs @@ -9,18 +9,14 @@ //! //! The main function of this module is [`translate_module`](fn.translate_module.html). -#![deny(missing_docs, - trivial_numeric_casts, - unused_extern_crates)] -#![cfg_attr(feature="clippy", - plugin(clippy(conf_file="../../clippy.toml")))] -#![cfg_attr(feature="cargo-clippy", - allow(new_without_default, redundant_field_names))] +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] +#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] +#![cfg_attr(feature = "cargo-clippy", allow(new_without_default, redundant_field_names))] -extern crate wasmparser; -extern crate cton_frontend; #[macro_use(dbg)] extern crate cretonne; +extern crate cton_frontend; +extern crate wasmparser; mod code_translator; mod func_translator; @@ -32,6 +28,6 @@ mod translation_utils; pub use func_translator::FuncTranslator; pub use module_translator::translate_module; -pub use environ::{FuncEnvironment, ModuleEnvironment, DummyEnvironment, GlobalValue}; -pub use translation_utils::{FunctionIndex, GlobalIndex, TableIndex, MemoryIndex, SignatureIndex, - Global, GlobalInit, Table, Memory}; +pub use environ::{DummyEnvironment, FuncEnvironment, GlobalValue, ModuleEnvironment}; +pub use translation_utils::{FunctionIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, + SignatureIndex, Table, TableIndex}; diff --git a/lib/wasm/src/module_translator.rs b/lib/wasm/src/module_translator.rs index 171f720e12..e345e5ef3c 100644 --- a/lib/wasm/src/module_translator.rs +++ b/lib/wasm/src/module_translator.rs @@ -1,11 +1,11 @@ //! Translation skeleton that traverses the whole WebAssembly module and call helper functions //! to deal with each part of it. use cretonne::timing; -use wasmparser::{ParserState, SectionCode, ParserInput, Parser, WasmDecoder, BinaryReaderError}; -use sections_translator::{SectionParsingError, parse_function_signatures, parse_import_section, - parse_function_section, parse_export_section, parse_start_section, - parse_memory_section, parse_global_section, parse_table_section, - parse_elements_section, parse_data_section}; +use wasmparser::{BinaryReaderError, Parser, ParserInput, ParserState, SectionCode, WasmDecoder}; +use sections_translator::{parse_data_section, parse_elements_section, parse_export_section, + parse_function_section, parse_function_signatures, parse_global_section, + parse_import_section, parse_memory_section, parse_start_section, + parse_table_section, SectionParsingError}; use environ::ModuleEnvironment; use std::string::String; diff --git a/lib/wasm/src/sections_translator.rs b/lib/wasm/src/sections_translator.rs index 05f655ba82..4792c3f450 100644 --- a/lib/wasm/src/sections_translator.rs +++ b/lib/wasm/src/sections_translator.rs @@ -7,12 +7,12 @@ //! The special case of the initialize expressions for table elements offsets or global variables //! is handled, according to the semantics of WebAssembly, to only specific expressions that are //! interpreted on the fly. -use translation_utils::{type_to_type, TableIndex, FunctionIndex, GlobalIndex, SignatureIndex, - MemoryIndex, Global, GlobalInit, Table, TableElementType, Memory}; -use cretonne::ir::{Signature, AbiParam, CallConv}; +use translation_utils::{type_to_type, FunctionIndex, Global, GlobalIndex, GlobalInit, Memory, + MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex}; +use cretonne::ir::{AbiParam, CallConv, Signature}; use cretonne; -use wasmparser::{Parser, ParserState, FuncType, ImportSectionEntryType, ExternalKind, WasmDecoder, - MemoryType, Operator}; +use wasmparser::{ExternalKind, FuncType, ImportSectionEntryType, MemoryType, Operator, Parser, + ParserState, WasmDecoder}; use wasmparser; use std::str::from_utf8; use environ::ModuleEnvironment; diff --git a/lib/wasm/src/state.rs b/lib/wasm/src/state.rs index 5ced6d6056..8d1d86fe80 100644 --- a/lib/wasm/src/state.rs +++ b/lib/wasm/src/state.rs @@ -6,7 +6,7 @@ use cretonne::ir::{self, Ebb, Inst, Value}; use environ::{FuncEnvironment, GlobalValue}; use std::collections::HashMap; -use translation_utils::{GlobalIndex, MemoryIndex, SignatureIndex, FunctionIndex}; +use translation_utils::{FunctionIndex, GlobalIndex, MemoryIndex, SignatureIndex}; use std::vec::Vec; /// A control stack frame can be an `if`, a `block` or a `loop`, each one having the following diff --git a/lib/wasm/tests/wasm_testsuite.rs b/lib/wasm/tests/wasm_testsuite.rs index 5d969c9cc2..1bd6ecf3f9 100644 --- a/lib/wasm/tests/wasm_testsuite.rs +++ b/lib/wasm/tests/wasm_testsuite.rs @@ -1,5 +1,5 @@ -extern crate cton_wasm; extern crate cretonne; +extern crate cton_wasm; extern crate tempdir; use cton_wasm::{translate_module, DummyEnvironment};