Add use declarations for std features.

Merge the `use` parts of the `no_std` branch. This reduces the diffs
between master and the `no_std` branch, making it easier to maintain.

Most of these changes are derived from patches by @lachlansneff in
https://github.com/Cretonne/cretonne/tree/no_std.
This commit is contained in:
Dan Gohman
2018-03-20 12:15:59 -07:00
parent da4cf27780
commit 2b3df1a506
66 changed files with 82 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
use ir::{ArgumentLoc, AbiParam, ArgumentExtension, Type};
use std::cmp::Ordering;
use std::vec::Vec;
/// Legalization action to perform on a single argument or return value when converting a
/// signature.

View File

@@ -423,6 +423,7 @@ where
#[cfg(test)]
mod test {
use std::mem;
use std::vec::Vec;
use super::*;
use super::super::NodeData;

View File

@@ -580,6 +580,7 @@ where
#[cfg(test)]
mod test {
use std::mem;
use std::string::ToString;
use super::*;
// Forest impl for a set implementation.

View File

@@ -78,6 +78,7 @@ impl<F: Forest> NodePool<F> {
{
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::vec::Vec;
use super::Comparator;
use entity::SparseSet;

View File

@@ -351,6 +351,7 @@ where
#[cfg(test)]
mod test {
use std::mem;
use std::vec::Vec;
use super::*;
use super::super::NodeData;

View File

@@ -8,8 +8,8 @@ use packed_option::PackedOption;
use std::cmp;
use std::mem;
use timing;
use std::cmp::Ordering;
use std::vec::Vec;
// RPO numbers are not first assigned in a contiguous way but as multiples of STRIDE, to leave
// room for modifications of the dominator tree.

View File

@@ -3,6 +3,7 @@ use entity::EntityRef;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::mem;
use std::vec::Vec;
/// A small list of entity references allocated from a pool.
///

View File

@@ -3,6 +3,7 @@
use entity::{EntityRef, Keys};
use std::marker::PhantomData;
use std::ops::{Index, IndexMut};
use std::vec::Vec;
/// A mapping `K -> V` for densely indexed entity references.
///

View File

@@ -2,6 +2,7 @@
use entity::{EntityRef, Keys};
use std::marker::PhantomData;
use std::ops::{Index, IndexMut};
use std::vec::Vec;
/// A primary mapping `K -> V` allocating dense entity references.
///

View File

@@ -2,6 +2,7 @@
use entity::{EntityRef, Keys};
use std::marker::PhantomData;
use std::vec::Vec;
/// A set of `K` for densely indexed entity references.
///

View File

@@ -11,6 +11,7 @@ use entity::{EntityRef, EntityMap};
use std::mem;
use std::slice;
use std::u32;
use std::vec::Vec;
/// Trait for extracting keys from values stored in a `SparseMap`.
///

View File

@@ -204,6 +204,7 @@ mod tests {
use super::*;
use cursor::{Cursor, FuncCursor};
use ir::{Function, InstBuilder, types};
use std::vec::Vec;
#[test]
fn empty() {

View File

@@ -266,6 +266,7 @@ impl FromStr for FloatCC {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
static INT_ALL: [IntCC; 10] = [
IntCC::Equal,

View File

@@ -944,6 +944,7 @@ mod tests {
use cursor::{Cursor, FuncCursor};
use ir::types;
use ir::{Function, Opcode, InstructionData, TrapCode};
use std::string::ToString;
#[test]
fn make_inst() {

View File

@@ -262,6 +262,7 @@ impl From<Heap> for AnyEntity {
mod tests {
use super::*;
use std::u32;
use std::string::ToString;
#[test]
fn value_with_number() {

View File

@@ -10,6 +10,7 @@ use isa::{RegInfo, RegUnit};
use std::cmp;
use std::fmt;
use std::str::FromStr;
use std::vec::Vec;
/// Function signature.
///
@@ -378,6 +379,7 @@ impl FromStr for CallConv {
mod tests {
use super::*;
use ir::types::{I32, F32, B8};
use std::string::ToString;
#[test]
fn argument_type() {

View File

@@ -122,6 +122,7 @@ impl FromStr for ExternalName {
mod tests {
use super::ExternalName;
use ir::LibCall;
use std::string::ToString;
#[test]
fn display_testcase() {

View File

@@ -652,6 +652,7 @@ mod tests {
use std::{f32, f64};
use std::str::FromStr;
use std::fmt::Display;
use std::string::ToString;
#[test]
fn format_imm64() {

View File

@@ -9,6 +9,7 @@
use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
use std::ops::{Deref, DerefMut};
use std::vec::Vec;
use ir;
use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef};
@@ -537,6 +538,7 @@ pub enum ResolvedConstraint {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
#[test]
fn opcodes() {

View File

@@ -8,6 +8,7 @@ use ir::entities::Ebb;
use std::iter;
use std::slice;
use std::fmt::{self, Display, Formatter};
use std::vec::Vec;
/// Contents of a jump table.
///
@@ -141,6 +142,8 @@ mod tests {
use super::JumpTableData;
use ir::Ebb;
use entity::EntityRef;
use std::vec::Vec;
use std::string::ToString;
#[test]
fn empty() {

View File

@@ -743,6 +743,7 @@ mod tests {
use entity::EntityRef;
use ir::{Ebb, Inst, ProgramOrder, SourceLoc};
use std::cmp::Ordering;
use std::vec::Vec;
struct LayoutCursor<'f> {
/// Borrowed function layout. Public so it can be re-borrowed from this cursor.

View File

@@ -100,6 +100,7 @@ impl LibCall {
#[cfg(test)]
mod test {
use super::*;
use std::string::ToString;
#[test]
fn display() {

View File

@@ -148,6 +148,7 @@ mod tests {
use super::*;
use entity::EntityRef;
use ir::{Inst, Ebb};
use std::string::ToString;
#[test]
fn convert() {

View File

@@ -51,6 +51,7 @@ impl fmt::Display for SourceLoc {
#[cfg(test)]
mod tests {
use ir::SourceLoc;
use std::string::ToString;
#[test]
fn display() {

View File

@@ -10,6 +10,7 @@ use std::cmp;
use std::fmt;
use std::ops::{Index, IndexMut};
use std::str::FromStr;
use std::vec::Vec;
/// The size of an object on the stack, or the size of a stack frame.
///
@@ -319,6 +320,7 @@ mod tests {
use ir::Function;
use ir::types;
use super::*;
use std::string::ToString;
#[test]
fn stack_slot() {

View File

@@ -89,6 +89,7 @@ impl FromStr for TrapCode {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
// Everything but user-defined codes.
const CODES: [TrapCode; 8] = [

View File

@@ -324,6 +324,7 @@ impl Default for Type {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
#[test]
fn basic_scalars() {

View File

@@ -14,6 +14,7 @@ use isa::{TargetIsa, RegInfo, RegClass, EncInfo};
use ir;
use regalloc;
use std::fmt;
use std::boxed::Box;
#[allow(dead_code)]
struct Isa {

View File

@@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs"));
mod tests {
use super::{INFO, GPR, S, D};
use isa::RegUnit;
use std::string::{String, ToString};
#[test]
fn unit_encodings() {

View File

@@ -14,6 +14,7 @@ use isa::{TargetIsa, RegInfo, RegClass, EncInfo};
use ir;
use regalloc;
use std::fmt;
use std::boxed::Box;
#[allow(dead_code)]
struct Isa {

View File

@@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs"));
mod tests {
use super::INFO;
use isa::RegUnit;
use std::string::{String, ToString};
#[test]
fn unit_encodings() {

View File

@@ -16,7 +16,7 @@ use regalloc;
use result;
use timing;
use std::fmt;
use std::boxed::Box;
#[allow(dead_code)]
struct Isa {

View File

@@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-intel.rs"));
mod tests {
use super::*;
use isa::RegUnit;
use std::string::{String, ToString};
#[test]
fn unit_encodings() {

View File

@@ -54,6 +54,7 @@ use result;
use timing;
use isa::enc_tables::Encodings;
use std::fmt;
use std::boxed::Box;
#[cfg(build_riscv)]
mod riscv;

View File

@@ -14,6 +14,7 @@ use isa::{TargetIsa, RegInfo, RegClass, EncInfo};
use ir;
use regalloc;
use std::fmt;
use std::boxed::Box;
#[allow(dead_code)]
struct Isa {
@@ -116,6 +117,7 @@ mod tests {
use isa;
use ir::{DataFlowGraph, InstructionData, Opcode};
use ir::{types, immediates};
use std::string::{String, ToString};
fn encstr(isa: &isa::TargetIsa, enc: Result<isa::Encoding, isa::Legalize>) -> String {
match enc {

View File

@@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs"));
mod tests {
use super::{INFO, GPR, FPR};
use isa::RegUnit;
use std::string::{String, ToString};
#[test]
fn unit_encodings() {

View File

@@ -12,6 +12,7 @@ include!(concat!(env!("OUT_DIR"), "/settings-riscv.rs"));
mod tests {
use super::{builder, Flags};
use settings::{self, Configurable};
use std::string::ToString;
#[test]
fn display_default() {

View File

@@ -48,6 +48,8 @@ where
#[cfg(test)]
mod tests {
use std::vec::Vec;
#[test]
fn adjpairs() {
use super::IteratorExtras;

View File

@@ -25,6 +25,7 @@ use ir::{Function, DataFlowGraph, Inst, InstBuilder, Ebb, Type, Value, Signature
use ir::instructions::CallInfo;
use isa::TargetIsa;
use legalizer::split::{isplit, vsplit};
use std::vec::Vec;
/// Legalize all the function signatures in `func`.
///

View File

@@ -68,6 +68,7 @@ use cursor::{Cursor, CursorPosition, FuncCursor};
use flowgraph::ControlFlowGraph;
use ir::{self, Ebb, Inst, Value, Type, Opcode, ValueDef, InstructionData, InstBuilder};
use std::iter;
use std::vec::Vec;
/// Split `value` into two values using the `isplit` semantics. Do this by reusing existing values
/// if possible.

View File

@@ -8,6 +8,7 @@ use dominator_tree::DominatorTree;
use entity::{EntityList, ListPool};
use loop_analysis::{Loop, LoopAnalysis};
use timing;
use std::vec::Vec;
/// Performs the LICM pass by detecting loops within the CFG and moving
/// loop-invariant instructions out of them.

View File

@@ -8,6 +8,7 @@ use flowgraph::ControlFlowGraph;
use ir::{Function, Ebb, Layout};
use packed_option::PackedOption;
use timing;
use std::vec::Vec;
/// A opaque reference to a code loop.
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
@@ -230,6 +231,7 @@ mod test {
use loop_analysis::{Loop, LoopAnalysis};
use flowgraph::ControlFlowGraph;
use dominator_tree::DominatorTree;
use std::vec::Vec;
#[test]
fn nested_loops_detection() {

View File

@@ -33,6 +33,7 @@ where
#[cfg(test)]
mod tests {
use super::partition_slice;
use std::vec::Vec;
fn check(x: &[u32], want: &[u32]) {
assert_eq!(x.len(), want.len());

View File

@@ -221,6 +221,7 @@ impl fmt::Display for AllocatableSet {
mod tests {
use super::*;
use isa::registers::{RegClass, RegClassData};
use std::vec::Vec;
// Register classes for testing.
const GPR: RegClass = &RegClassData {

View File

@@ -18,6 +18,7 @@ use std::cmp;
use std::iter;
use std::fmt;
use std::slice;
use std::vec::Vec;
use isa::{TargetIsa, EncInfo};
use timing;

View File

@@ -11,6 +11,7 @@ use ir::{Value, ValueLoc, ValueLocations, StackSlot};
use ir::{InstructionData, Opcode};
use isa::{RegUnit, RegInfo};
use std::fmt;
use std::vec::Vec;
/// A diversion of a value from its original location to a new register or stack location.
///

View File

@@ -13,6 +13,7 @@ use regalloc::affinity::Affinity;
use regalloc::liveness::Liveness;
use regalloc::liverange::LiveRange;
use std::collections::HashMap;
use std::vec::Vec;
type ValueList = EntityList<Value>;

View File

@@ -184,6 +184,7 @@ use regalloc::affinity::Affinity;
use regalloc::liverange::{LiveRange, LiveRangeForest, LiveRangeContext};
use std::mem;
use std::ops::Index;
use std::vec::Vec;
use timing;
/// A set of live ranges, indexed by value number.

View File

@@ -463,6 +463,7 @@ mod tests {
use entity::EntityRef;
use ir::{ProgramOrder, ExpandedProgramPoint};
use std::cmp::Ordering;
use std::vec::Vec;
// Dummy program order which simply compares indexes.
// It is assumed that EBBs have indexes that are multiples of 10, and instructions have indexes

View File

@@ -273,6 +273,7 @@ mod tests {
use regalloc::AllocatableSet;
use std::borrow::Borrow;
use super::Pressure;
use std::boxed::Box;
// Make an arm32 `TargetIsa`, if possible.
fn arm32() -> Option<Box<TargetIsa>> {

View File

@@ -21,6 +21,7 @@ use regalloc::live_value_tracker::{LiveValue, LiveValueTracker};
use regalloc::liveness::Liveness;
use timing;
use topo_order::TopoOrder;
use std::vec::Vec;
/// Reusable data structures for the reload pass.
pub struct Reload {

View File

@@ -108,6 +108,7 @@ use std::fmt;
use std::mem;
use super::AllocatableSet;
use std::u16;
use std::vec::Vec;
/// A variable in the constraint problem.
///
@@ -1162,6 +1163,7 @@ mod tests {
use isa::{TargetIsa, RegClass, RegUnit, RegInfo};
use regalloc::AllocatableSet;
use super::{Solver, Move};
use std::boxed::Box;
// Make an arm32 `TargetIsa`, if possible.
fn arm32() -> Option<Box<TargetIsa>> {

View File

@@ -26,6 +26,7 @@ use regalloc::liveness::Liveness;
use regalloc::pressure::Pressure;
use regalloc::virtregs::VirtRegs;
use std::fmt;
use std::vec::Vec;
use timing;
use topo_order::TopoOrder;

View File

@@ -21,6 +21,7 @@ use packed_option::PackedOption;
use ref_slice::ref_slice;
use std::cmp::Ordering;
use std::fmt;
use std::vec::Vec;
/// A virtual register reference.
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]

View File

@@ -24,6 +24,7 @@ use constant_hash::{probe, simple_hash};
use isa::TargetIsa;
use std::fmt;
use std::result;
use std::vec::Vec;
/// A string-based configurator for settings groups.
///
@@ -347,6 +348,7 @@ mod tests {
use super::{builder, Flags};
use super::Error::*;
use super::Configurable;
use std::string::ToString;
#[test]
fn display_default() {

View File

@@ -6,6 +6,7 @@ use dominator_tree::DominatorTree;
use ir::{InstructionData, Function, Inst, Opcode, Type};
use scoped_hash_map::ScopedHashMap;
use timing;
use std::vec::Vec;
/// Test whether the given opcode is unsafe to even consider for GVN.
fn trivially_unsafe_for_gvn(opcode: Opcode) -> bool {

View File

@@ -3,6 +3,7 @@
use entity::SparseSet;
use dominator_tree::DominatorTree;
use ir::{Ebb, Layout};
use std::vec::Vec;
/// Present EBBs in a topological order such that all dominating EBBs are guaranteed to be visited
/// before the current EBB.

View File

@@ -73,6 +73,8 @@ use std::collections::BTreeSet;
use std::error as std_error;
use std::fmt::{self, Display, Formatter, Write};
use std::result;
use std::vec::Vec;
use std::string::String;
use timing;
pub use self::cssa::verify_cssa;

View File

@@ -9,6 +9,7 @@ use isa::{TargetIsa, RegInfo};
use std::fmt::{self, Result, Error, Write};
use std::result;
use packed_option::ReservedValue;
use std::string::String;
/// Write `func` to `w` as equivalent text.
/// Use `isa` to emit ISA-dependent annotations.
@@ -466,6 +467,7 @@ impl<'a> fmt::Display for DisplayValues<'a> {
mod tests {
use ir::{Function, ExternalName, StackSlotData, StackSlotKind};
use ir::types;
use std::string::ToString;
#[test]
fn basic() {

View File

@@ -15,6 +15,7 @@ use std::u32;
use cretonne::ir::types::{F32, F64};
use cretonne::ir::immediates::{Ieee32, Ieee64};
use std::mem;
use std::vec::Vec;
/// Structure containing the data relevant the construction of SSA for a given function.
///

View File

@@ -34,6 +34,7 @@ use state::{TranslationState, ControlStackFrame};
use std::collections::{HashMap, hash_map};
use environ::{FuncEnvironment, GlobalValue};
use std::{i32, u32};
use std::vec::Vec;
/// Translates wasm operators into Cretonne IL instructions. Returns `true` if it inserted
/// a return.

View File

@@ -10,6 +10,8 @@ use cretonne::cursor::FuncCursor;
use cretonne::settings;
use wasmparser;
use std::error::Error;
use std::vec::Vec;
use std::string::String;
/// Compute a `ir::ExternalName` for a given wasm function index.
fn get_func_name(func_index: FunctionIndex) -> ir::ExternalName {

View File

@@ -5,6 +5,8 @@ use cretonne::cursor::FuncCursor;
use cretonne::settings::Flags;
use translation_utils::{SignatureIndex, FunctionIndex, TableIndex, GlobalIndex, MemoryIndex,
Global, Table, Memory};
use std::vec::Vec;
use std::string::String;
/// The value of a WebAssembly global variable.
#[derive(Clone, Copy)]

View File

@@ -8,6 +8,8 @@ use sections_translator::{SectionParsingError, parse_function_signatures, parse_
parse_elements_section, parse_data_section};
use environ::ModuleEnvironment;
use std::string::String;
/// Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cretonne IL
/// [`Function`](../cretonne/ir/function/struct.Function.html).
/// Returns the functions and also the mappings for imported functions and signature between the

View File

@@ -16,6 +16,8 @@ use wasmparser::{Parser, ParserState, FuncType, ImportSectionEntryType, External
use wasmparser;
use std::str::from_utf8;
use environ::ModuleEnvironment;
use std::vec::Vec;
use std::string::String;
pub enum SectionParsingError {
WrongSectionContent(String),

View File

@@ -7,6 +7,7 @@ use cretonne::ir::{self, Ebb, Inst, Value};
use environ::{FuncEnvironment, GlobalValue};
use std::collections::HashMap;
use translation_utils::{GlobalIndex, MemoryIndex, SignatureIndex, FunctionIndex};
use std::vec::Vec;
/// A control stack frame can be an `if`, a `block` or a `loop`, each one having the following
/// fields: