From effe6c04e44426444feb3794e534ba53a65b9997 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Wed, 26 Dec 2018 23:49:05 +0600 Subject: [PATCH] Update to Rust 2018 edition (#632) * initial cargo fix run * Upgrade cranelift-entity crate * Upgrade bforest crate * Upgrade the codegen crate * Upgrade the faerie crate * Upgrade the filetests crate * Upgrade the codegen-meta crate * Upgrade the frontend crate * Upgrade the cranelift-module crate * Upgrade the cranelift-native crate * Upgrade the cranelift-preopt crate * Upgrade the cranelift-reader crate * Upgrade the cranelift-serde crate * Upgrade the cranelift-simplejit crate * Upgrade the cranelift or cranelift-umbrella crate * Upgrade the cranelift-wasm crate * Upgrade cranelift-tools crate * Use new import style on remaining files * run format-all.sh * run test-all.sh, update Readme and travis ci configuration fixed an AssertionError also * Remove deprecated functions --- .travis.yml | 2 +- cranelift/Cargo.toml | 1 + cranelift/README.md | 2 +- cranelift/src/cat.rs | 4 +- cranelift/src/clif-util.rs | 17 +------ cranelift/src/compile.rs | 3 +- cranelift/src/print_cfg.rs | 4 +- cranelift/src/wasm.rs | 2 +- cranelift/tests/filetests.rs | 2 - lib/bforest/Cargo.toml | 1 + lib/bforest/src/lib.rs | 4 +- lib/bforest/src/map.rs | 2 +- lib/bforest/src/pool.rs | 4 +- lib/bforest/src/set.rs | 2 +- lib/codegen/Cargo.toml | 1 + lib/codegen/build.rs | 4 +- lib/codegen/meta-python/cdsl/predicates.py | 3 +- lib/codegen/meta-python/cdsl/xform.py | 2 +- lib/codegen/meta-python/gen_encoding.py | 16 +++--- lib/codegen/meta-python/gen_instr.py | 2 +- lib/codegen/meta-python/gen_legalizer.py | 28 ++++++----- lib/codegen/meta-python/gen_settings.py | 6 +-- lib/codegen/meta-python/isa/x86/recipes.py | 8 +-- lib/codegen/meta-python/test_gen_legalizer.py | 4 +- lib/codegen/meta/Cargo.toml | 1 + lib/codegen/meta/src/base/settings.rs | 2 +- lib/codegen/meta/src/cdsl/regs.rs | 1 + lib/codegen/meta/src/cdsl/types.rs | 2 +- lib/codegen/meta/src/gen_registers.rs | 8 +-- lib/codegen/meta/src/gen_settings.rs | 18 ++++--- lib/codegen/meta/src/gen_types.rs | 6 +-- lib/codegen/meta/src/isa/arm32/mod.rs | 6 +-- lib/codegen/meta/src/isa/arm64/mod.rs | 6 +-- lib/codegen/meta/src/isa/mod.rs | 4 +- lib/codegen/meta/src/isa/riscv/mod.rs | 6 +-- lib/codegen/meta/src/isa/x86/mod.rs | 6 +-- lib/codegen/meta/src/lib.rs | 3 -- lib/codegen/meta/src/srcgen.rs | 10 ++-- lib/codegen/src/abi.rs | 6 +-- lib/codegen/src/binemit/memorysink.rs | 10 ++-- lib/codegen/src/binemit/mod.rs | 20 ++++---- lib/codegen/src/binemit/relaxation.rs | 17 ++++--- lib/codegen/src/binemit/shrink.rs | 11 ++-- lib/codegen/src/cfg_printer.rs | 6 +-- lib/codegen/src/context.rs | 38 +++++++------- lib/codegen/src/cursor.rs | 4 +- lib/codegen/src/dce.rs | 12 ++--- lib/codegen/src/dominator_tree.rs | 24 ++++----- lib/codegen/src/flowgraph.rs | 14 +++--- lib/codegen/src/ir/builder.rs | 18 +++---- lib/codegen/src/ir/dfg.rs | 30 +++++------ lib/codegen/src/ir/entities.rs | 3 +- lib/codegen/src/ir/extfunc.rs | 6 +-- lib/codegen/src/ir/extname.rs | 4 +- lib/codegen/src/ir/function.rs | 20 ++++---- lib/codegen/src/ir/globalvalue.rs | 6 +-- lib/codegen/src/ir/heap.rs | 4 +- lib/codegen/src/ir/instructions.rs | 18 +++---- lib/codegen/src/ir/jumptable.rs | 6 +-- lib/codegen/src/ir/layout.rs | 17 ++++--- lib/codegen/src/ir/libcall.rs | 4 +- lib/codegen/src/ir/mod.rs | 50 ++++++++++--------- lib/codegen/src/ir/progpoint.rs | 8 +-- lib/codegen/src/ir/sourceloc.rs | 2 +- lib/codegen/src/ir/stackslot.rs | 10 ++-- lib/codegen/src/ir/table.rs | 4 +- lib/codegen/src/ir/valueloc.rs | 4 +- lib/codegen/src/isa/arm32/abi.rs | 8 +-- lib/codegen/src/isa/arm32/binemit.rs | 6 +-- lib/codegen/src/isa/arm32/enc_tables.rs | 9 ++-- lib/codegen/src/isa/arm32/mod.rs | 14 +++--- lib/codegen/src/isa/arm32/registers.rs | 6 +-- lib/codegen/src/isa/arm32/settings.rs | 2 +- lib/codegen/src/isa/arm64/abi.rs | 8 +-- lib/codegen/src/isa/arm64/binemit.rs | 6 +-- lib/codegen/src/isa/arm64/enc_tables.rs | 9 ++-- lib/codegen/src/isa/arm64/mod.rs | 14 +++--- lib/codegen/src/isa/arm64/registers.rs | 4 +- lib/codegen/src/isa/arm64/settings.rs | 2 +- lib/codegen/src/isa/constraints.rs | 8 +-- lib/codegen/src/isa/enc_tables.rs | 8 +-- lib/codegen/src/isa/encoding.rs | 8 +-- lib/codegen/src/isa/mod.rs | 35 +++++++------ lib/codegen/src/isa/registers.rs | 2 +- lib/codegen/src/isa/riscv/abi.rs | 8 +-- lib/codegen/src/isa/riscv/binemit.rs | 10 ++-- lib/codegen/src/isa/riscv/enc_tables.rs | 10 ++-- lib/codegen/src/isa/riscv/mod.rs | 24 ++++----- lib/codegen/src/isa/riscv/registers.rs | 4 +- lib/codegen/src/isa/riscv/settings.rs | 4 +- lib/codegen/src/isa/stack.rs | 4 +- lib/codegen/src/isa/x86/abi.rs | 22 ++++---- lib/codegen/src/isa/x86/binemit.rs | 14 +++--- lib/codegen/src/isa/x86/enc_tables.rs | 44 ++++++++-------- lib/codegen/src/isa/x86/mod.rs | 18 +++---- lib/codegen/src/isa/x86/registers.rs | 4 +- lib/codegen/src/isa/x86/settings.rs | 4 +- lib/codegen/src/legalizer/boundary.rs | 15 +++--- lib/codegen/src/legalizer/call.rs | 8 +-- lib/codegen/src/legalizer/globalvalue.rs | 8 +-- lib/codegen/src/legalizer/heap.rs | 10 ++-- lib/codegen/src/legalizer/libcall.rs | 8 +-- lib/codegen/src/legalizer/mod.rs | 18 +++---- lib/codegen/src/legalizer/split.rs | 6 +-- lib/codegen/src/legalizer/table.rs | 12 ++--- lib/codegen/src/lib.rs | 25 +++------- lib/codegen/src/licm.rs | 18 +++---- lib/codegen/src/loop_analysis.rs | 25 +++++----- lib/codegen/src/nan_canonicalization.rs | 14 +++--- lib/codegen/src/postopt.rs | 16 +++--- lib/codegen/src/predicates.rs | 4 +- lib/codegen/src/print_errors.rs | 16 +++--- lib/codegen/src/regalloc/affinity.rs | 4 +- lib/codegen/src/regalloc/coalescing.rs | 25 +++++----- lib/codegen/src/regalloc/coloring.rs | 35 ++++++------- lib/codegen/src/regalloc/context.rs | 32 ++++++------ lib/codegen/src/regalloc/diversion.rs | 12 ++--- .../src/regalloc/live_value_tracker.rs | 16 +++--- lib/codegen/src/regalloc/liveness.rs | 16 +++--- lib/codegen/src/regalloc/liverange.rs | 16 +++--- lib/codegen/src/regalloc/pressure.rs | 14 +++--- lib/codegen/src/regalloc/register_set.rs | 4 +- lib/codegen/src/regalloc/reload.rs | 25 +++++----- lib/codegen/src/regalloc/solver.rs | 25 +++++----- lib/codegen/src/regalloc/spilling.rs | 25 +++++----- lib/codegen/src/regalloc/virtregs.rs | 19 +++---- lib/codegen/src/result.rs | 3 +- lib/codegen/src/scoped_hash_map.rs | 2 +- lib/codegen/src/settings.rs | 7 +-- lib/codegen/src/simple_gvn.rs | 12 ++--- lib/codegen/src/simple_preopt.rs | 18 +++---- lib/codegen/src/stack_layout.rs | 14 +++--- lib/codegen/src/timing.rs | 1 + lib/codegen/src/topo_order.rs | 14 +++--- lib/codegen/src/unreachable_code.rs | 11 ++-- lib/codegen/src/verifier/cssa.rs | 16 +++--- lib/codegen/src/verifier/flags.rs | 16 +++--- lib/codegen/src/verifier/liveness.rs | 16 +++--- lib/codegen/src/verifier/locations.rs | 14 +++--- lib/codegen/src/verifier/mod.rs | 39 ++++++++------- lib/codegen/src/write.rs | 20 ++++---- lib/entity/Cargo.toml | 1 + lib/entity/src/boxed_slice.rs | 8 +-- lib/entity/src/iter.rs | 2 +- lib/entity/src/keys.rs | 2 +- lib/entity/src/lib.rs | 2 +- lib/entity/src/list.rs | 4 +- lib/entity/src/map.rs | 6 +-- lib/entity/src/primary.rs | 8 +-- lib/entity/src/set.rs | 4 +- lib/entity/src/sparse.rs | 6 +-- lib/faerie/Cargo.toml | 1 + lib/faerie/src/backend.rs | 4 +- lib/faerie/src/lib.rs | 11 +--- lib/filetests/Cargo.toml | 1 + lib/filetests/src/concurrent.rs | 5 +- lib/filetests/src/lib.rs | 11 +--- lib/filetests/src/match_directive.rs | 2 +- lib/filetests/src/runner.rs | 6 +-- lib/filetests/src/runone.rs | 5 +- lib/filetests/src/test_binemit.rs | 4 +- lib/filetests/src/test_cat.rs | 2 +- lib/filetests/src/test_compile.rs | 3 +- lib/filetests/src/test_dce.rs | 2 +- lib/filetests/src/test_domtree.rs | 4 +- lib/filetests/src/test_legalizer.rs | 2 +- lib/filetests/src/test_licm.rs | 2 +- lib/filetests/src/test_postopt.rs | 2 +- lib/filetests/src/test_preopt.rs | 2 +- lib/filetests/src/test_print_cfg.rs | 2 +- lib/filetests/src/test_regalloc.rs | 2 +- lib/filetests/src/test_shrink.rs | 2 +- lib/filetests/src/test_simple_gvn.rs | 2 +- lib/filetests/src/test_simple_preopt.rs | 2 +- lib/filetests/src/test_verifier.rs | 4 +- lib/frontend/Cargo.toml | 1 + lib/frontend/src/frontend.rs | 8 +-- lib/frontend/src/lib.rs | 11 ++-- lib/frontend/src/ssa.rs | 6 +-- lib/frontend/src/switch.rs | 5 +- lib/module/Cargo.toml | 1 + lib/module/src/backend.rs | 10 ++-- lib/module/src/lib.rs | 14 ++---- lib/module/src/module.rs | 8 +-- lib/native/Cargo.toml | 1 + lib/native/src/lib.rs | 5 -- lib/preopt/Cargo.toml | 1 + lib/preopt/src/lib.rs | 3 -- lib/reader/Cargo.toml | 1 + lib/reader/src/isaspec.rs | 4 +- lib/reader/src/lexer.rs | 4 +- lib/reader/src/lib.rs | 15 +++--- lib/reader/src/parser.rs | 20 ++++---- lib/reader/src/sourcemap.rs | 6 +-- lib/reader/src/testfile.rs | 8 +-- lib/serde/Cargo.toml | 1 + lib/serde/src/clif-json.rs | 7 --- lib/serde/src/serde_clif_json.rs | 1 + lib/simplejit/Cargo.toml | 1 + lib/simplejit/examples/simplejit-minimal.rs | 4 -- lib/simplejit/src/backend.rs | 2 +- lib/simplejit/src/lib.rs | 13 +---- lib/simplejit/tests/basic.rs | 6 --- lib/umbrella/Cargo.toml | 1 + lib/umbrella/src/lib.rs | 22 ++++---- lib/wasm/Cargo.toml | 1 + lib/wasm/src/code_translator.rs | 8 +-- lib/wasm/src/environ/dummy.rs | 12 ++--- lib/wasm/src/environ/mod.rs | 4 +- lib/wasm/src/environ/spec.rs | 7 +-- lib/wasm/src/func_translator.rs | 10 ++-- lib/wasm/src/lib.rs | 24 ++------- lib/wasm/src/module_translator.rs | 6 +-- lib/wasm/src/sections_translator.rs | 12 ++--- lib/wasm/src/state.rs | 4 +- lib/wasm/src/translation_utils.rs | 1 + lib/wasm/tests/wasm_testsuite.rs | 7 +-- 217 files changed, 963 insertions(+), 1021 deletions(-) diff --git a/.travis.yml b/.travis.yml index c80acf071c..bc772c38a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ language: rust rust: # The oldest version we currently support. See # CONTRIBUTING.md#rustc-version-support for details. - - 1.30.1 + - 1.31.1 - beta - nightly matrix: diff --git a/cranelift/Cargo.toml b/cranelift/Cargo.toml index e2afd0799f..bbe81eaaed 100644 --- a/cranelift/Cargo.toml +++ b/cranelift/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0 WITH LLVM-exception" documentation = "https://cranelift.readthedocs.io/" repository = "https://github.com/CraneStation/cranelift" publish = false +edition = "2018" [[bin]] name = "clif-util" diff --git a/cranelift/README.md b/cranelift/README.md index 82ac7912dd..5f579b0eb6 100644 --- a/cranelift/README.md +++ b/cranelift/README.md @@ -10,7 +10,7 @@ into executable machine code. [![Travis Status](https://travis-ci.org/CraneStation/cranelift.svg?branch=master)](https://travis-ci.org/CraneStation/cranelift) [![Appveyor Status](https://ci.appveyor.com/api/projects/status/oub7wrrb59utuv8x?svg=true)](https://ci.appveyor.com/project/CraneStation/cranelift) [![Gitter chat](https://badges.gitter.im/CraneStation/CraneStation.svg)](https://gitter.im/CraneStation/Lobby) -![Minimum rustc 1.30](https://img.shields.io/badge/rustc-1.30+-green.svg) +![Minimum rustc 1.31](https://img.shields.io/badge/rustc-1.31+-green.svg) For more information, see [the documentation](https://cranelift.readthedocs.io/en/latest/?badge=latest). diff --git a/cranelift/src/cat.rs b/cranelift/src/cat.rs index cb824a6eb7..a98e509698 100644 --- a/cranelift/src/cat.rs +++ b/cranelift/src/cat.rs @@ -3,9 +3,9 @@ //! Read a sequence of Cranelift IR files and print them again to stdout. This has the effect of //! normalizing formatting and removing comments. +use crate::utils::read_to_string; +use crate::CommandResult; use cranelift_reader::parse_functions; -use utils::read_to_string; -use CommandResult; pub fn run(files: &[String]) -> CommandResult { for (i, f) in files.into_iter().enumerate() { diff --git a/cranelift/src/clif-util.rs b/cranelift/src/clif-util.rs index 1b9255db4b..4c53cc8828 100755 --- a/cranelift/src/clif-util.rs +++ b/cranelift/src/clif-util.rs @@ -13,28 +13,13 @@ ) )] -extern crate file_per_thread_logger; -#[macro_use] -extern crate cfg_if; -#[cfg(feature = "disas")] -extern crate capstone; -extern crate clap; -extern crate cranelift_codegen; -#[cfg(feature = "wasm")] -extern crate cranelift_entity; -extern crate cranelift_filetests; -extern crate cranelift_reader; -extern crate pretty_env_logger; +use cfg_if::cfg_if; cfg_if! { if #[cfg(feature = "wasm")] { - extern crate cranelift_wasm; - extern crate term; - extern crate wabt; mod wasm; } } -extern crate target_lexicon; use clap::{App, Arg, SubCommand}; use cranelift_codegen::dbg::LOG_FILENAME_PREFIX; diff --git a/cranelift/src/compile.rs b/cranelift/src/compile.rs index 0babf6f83e..50b21faf15 100644 --- a/cranelift/src/compile.rs +++ b/cranelift/src/compile.rs @@ -1,5 +1,7 @@ //! CLI tool to read Cranelift IR files and compile them into native code. +use crate::utils::{parse_sets_and_triple, read_to_string}; +use cfg_if::cfg_if; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::settings::FlagsOrIsa; @@ -9,7 +11,6 @@ use cranelift_codegen::{binemit, ir}; use cranelift_reader::parse_test; use std::path::Path; use std::path::PathBuf; -use utils::{parse_sets_and_triple, read_to_string}; struct PrintRelocs { flag_print: bool, diff --git a/cranelift/src/print_cfg.rs b/cranelift/src/print_cfg.rs index 6d16c77262..30d91b5862 100644 --- a/cranelift/src/print_cfg.rs +++ b/cranelift/src/print_cfg.rs @@ -3,10 +3,10 @@ //! Read a series of Cranelift IR files and print their control flow graphs //! in graphviz format. +use crate::utils::read_to_string; +use crate::CommandResult; use cranelift_codegen::cfg_printer::CFGPrinter; use cranelift_reader::parse_functions; -use utils::read_to_string; -use CommandResult; pub fn run(files: &[String]) -> CommandResult { for (i, f) in files.into_iter().enumerate() { diff --git a/cranelift/src/wasm.rs b/cranelift/src/wasm.rs index 9e22279751..9ffea3adca 100644 --- a/cranelift/src/wasm.rs +++ b/cranelift/src/wasm.rs @@ -18,7 +18,7 @@ use cranelift_wasm::{ use std::path::Path; use std::path::PathBuf; use term; -use utils::{parse_sets_and_triple, read_to_end}; +use crate::utils::{parse_sets_and_triple, read_to_end}; use wabt::wat2wasm; macro_rules! vprintln { diff --git a/cranelift/tests/filetests.rs b/cranelift/tests/filetests.rs index 89646a2d3d..a633461109 100644 --- a/cranelift/tests/filetests.rs +++ b/cranelift/tests/filetests.rs @@ -1,5 +1,3 @@ -extern crate cranelift_filetests; - #[test] fn filetests() { // Run all the filetests in the following directories. diff --git a/lib/bforest/Cargo.toml b/lib/bforest/Cargo.toml index c2da583ccc..0181e32a83 100644 --- a/lib/bforest/Cargo.toml +++ b/lib/bforest/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/CraneStation/cranelift" categories = ["no-std"] readme = "README.md" keywords = ["btree", "forest", "set", "map"] +edition = "2018" [dependencies] cranelift-entity = { path = "../entity", version = "0.26.0", default-features = false } diff --git a/lib/bforest/src/lib.rs b/lib/bforest/src/lib.rs index 4b478f189c..ee9213b00a 100644 --- a/lib/bforest/src/lib.rs +++ b/lib/bforest/src/lib.rs @@ -48,7 +48,7 @@ mod std { #[macro_use] extern crate cranelift_entity as entity; -use entity::packed_option; +use crate::entity::packed_option; use std::borrow::BorrowMut; use std::cmp::Ordering; @@ -157,7 +157,7 @@ fn slice_shift(s: &mut [T], n: usize) { #[cfg(test)] mod tests { use super::*; - use entity::EntityRef; + use crate::entity::EntityRef; /// An opaque reference to an extended basic block in a function. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/lib/bforest/src/map.rs b/lib/bforest/src/map.rs index 9b1c78f906..a809282833 100644 --- a/lib/bforest/src/map.rs +++ b/lib/bforest/src/map.rs @@ -1,7 +1,7 @@ //! Forest of maps. use super::{Comparator, Forest, Node, NodeData, NodePool, Path, INNER_SIZE}; -use packed_option::PackedOption; +use crate::packed_option::PackedOption; #[cfg(test)] use std::fmt; use std::marker::PhantomData; diff --git a/lib/bforest/src/pool.rs b/lib/bforest/src/pool.rs index 9330ee5502..cec5e40a7d 100644 --- a/lib/bforest/src/pool.rs +++ b/lib/bforest/src/pool.rs @@ -3,7 +3,7 @@ #[cfg(test)] use super::Comparator; use super::{Forest, Node, NodeData}; -use entity::PrimaryMap; +use crate::entity::PrimaryMap; #[cfg(test)] use std::fmt; use std::ops::{Index, IndexMut}; @@ -83,7 +83,7 @@ impl NodePool { NodeData: fmt::Display, F::Key: fmt::Display, { - use entity::SparseSet; + use crate::entity::SparseSet; use std::borrow::Borrow; use std::cmp::Ordering; use std::vec::Vec; diff --git a/lib/bforest/src/set.rs b/lib/bforest/src/set.rs index f73a6b06d3..0ca5d92457 100644 --- a/lib/bforest/src/set.rs +++ b/lib/bforest/src/set.rs @@ -1,7 +1,7 @@ //! Forest of sets. use super::{Comparator, Forest, Node, NodeData, NodePool, Path, SetValue, INNER_SIZE}; -use packed_option::PackedOption; +use crate::packed_option::PackedOption; #[cfg(test)] use std::fmt; use std::marker::PhantomData; diff --git a/lib/codegen/Cargo.toml b/lib/codegen/Cargo.toml index 2ab25583cb..cddb573715 100644 --- a/lib/codegen/Cargo.toml +++ b/lib/codegen/Cargo.toml @@ -10,6 +10,7 @@ categories = ["no-std"] readme = "README.md" keywords = ["compile", "compiler", "jit"] build = "build.rs" +edition = "2018" [dependencies] cranelift-entity = { path = "../entity", version = "0.26.0", default-features = false } diff --git a/lib/codegen/build.rs b/lib/codegen/build.rs index 122d441c45..e8a57cfc26 100644 --- a/lib/codegen/build.rs +++ b/lib/codegen/build.rs @@ -18,9 +18,9 @@ // 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. -extern crate cranelift_codegen_meta as meta; +use cranelift_codegen_meta as meta; -use meta::isa::Isa; +use crate::meta::isa::Isa; use std::env; use std::process; use std::time::Instant; diff --git a/lib/codegen/meta-python/cdsl/predicates.py b/lib/codegen/meta-python/cdsl/predicates.py index c81173ad5c..0177c09fff 100644 --- a/lib/codegen/meta-python/cdsl/predicates.py +++ b/lib/codegen/meta-python/cdsl/predicates.py @@ -244,7 +244,8 @@ class FieldPredicate(object): """ # Prepend `field` to the predicate function arguments. args = (self.field.rust_name(),) + tuple(map(str, self.args)) - return '::predicates::{}({})'.format(self.function, ', '.join(args)) + return 'crate::predicates::{}({})'\ + .format(self.function, ', '.join(args)) class IsEqual(FieldPredicate): diff --git a/lib/codegen/meta-python/cdsl/xform.py b/lib/codegen/meta-python/cdsl/xform.py index 0e4deb9910..27aa515f94 100644 --- a/lib/codegen/meta-python/cdsl/xform.py +++ b/lib/codegen/meta-python/cdsl/xform.py @@ -394,7 +394,7 @@ class XFormGroup(object): # table referring to it. return self.name else: - return '::legalizer::{}'.format(self.name) + return 'crate::legalizer::{}'.format(self.name) def legalize(self, src, dst): # type: (Union[Def, Apply], Rtl) -> None diff --git a/lib/codegen/meta-python/gen_encoding.py b/lib/codegen/meta-python/gen_encoding.py index 6c5d7367ed..5f70c97eca 100644 --- a/lib/codegen/meta-python/gen_encoding.py +++ b/lib/codegen/meta-python/gen_encoding.py @@ -110,7 +110,7 @@ def emit_instp(instp, fmt, has_func=False): fields = ', '.join(sorted(fnames)) with fmt.indented( - 'if let ir::InstructionData::{} {{ {}, .. }} = *inst {{' + 'if let crate::ir::InstructionData::{} {{ {}, .. }} = *inst {{' .format(iform.name, fields), '}'): if has_type_check: # We could implement this if we need to. @@ -132,7 +132,8 @@ def emit_inst_predicates(instps, fmt): for instp, number in instps.items(): name = 'inst_predicate_{}'.format(number) with fmt.indented( - 'fn {}(func: &ir::Function, inst: &ir::InstructionData)' + 'fn {}(func: &crate::ir::Function, ' + 'inst: &crate::ir::InstructionData)' '-> bool {{'.format(name), '}'): emit_instp(instp, fmt, has_func=True) @@ -168,7 +169,7 @@ def emit_recipe_predicates(isa, fmt): # Generate the predicate function. with fmt.indented( - 'fn {}({}: ::settings::PredicateView, ' + 'fn {}({}: crate::settings::PredicateView, ' '{}: &ir::InstructionData) -> bool {{' .format( name, @@ -657,7 +658,8 @@ def emit_level2_hashtables(level2_hashtables, offt, level2_doc, fmt): if entry: fmt.line( 'Level2Entry ' + - '{{ opcode: Some(ir::Opcode::{}), offset: {:#08x} }},' + '{{ opcode: Some(crate::ir::Opcode::{}), ' + 'offset: {:#08x} }},' .format(entry.inst.camel_name, entry.offset)) else: fmt.line( @@ -682,15 +684,15 @@ def emit_level1_hashtable(cpumode, level1, offt, fmt): # Empty hash table entry. Include the default legalization action. if not level2: fmt.format( - 'Level1Entry {{ ty: ir::types::INVALID, log2len: !0, ' - 'offset: 0, legalize: {} }},', + 'Level1Entry {{ ty: crate::ir::types::INVALID, ' + 'log2len: !0, offset: 0, legalize: {} }},', level1.legalize_code) continue if level2.ty is not None: tyname = level2.ty.rust_name() else: - tyname = 'ir::types::INVALID' + tyname = 'crate::ir::types::INVALID' lcode = cpumode.isa.legalize_code(level2.legalize) diff --git a/lib/codegen/meta-python/gen_instr.py b/lib/codegen/meta-python/gen_instr.py index 2f5eeae93d..57be62a5d4 100644 --- a/lib/codegen/meta-python/gen_instr.py +++ b/lib/codegen/meta-python/gen_instr.py @@ -661,7 +661,7 @@ def gen_inst_builder(inst, fmt): # The controlling type variable will be inferred from the input values if # possible. Otherwise, it is the first method argument. if inst.is_polymorphic and not inst.use_typevar_operand: - args.append('{}: ir::Type'.format(inst.ctrl_typevar.name)) + args.append('{}: crate::ir::Type'.format(inst.ctrl_typevar.name)) tmpl_types = list() # type: List[str] into_args = list() # type: List[str] diff --git a/lib/codegen/meta-python/gen_legalizer.py b/lib/codegen/meta-python/gen_legalizer.py index 7e22f8377e..2f78d086f3 100644 --- a/lib/codegen/meta-python/gen_legalizer.py +++ b/lib/codegen/meta-python/gen_legalizer.py @@ -103,19 +103,21 @@ def emit_runtime_typecheck(check, fmt, type_sets): base_exp = build_derived_expr(tv.base) if (tv.derived_func == TypeVar.LANEOF): - return "{}.map(|t: ir::Type| t.lane_type())".format(base_exp) + return "{}.map(|t: crate::ir::Type| t.lane_type())"\ + .format(base_exp) elif (tv.derived_func == TypeVar.ASBOOL): - return "{}.map(|t: ir::Type| t.as_bool())".format(base_exp) + return "{}.map(|t: crate::ir::Type| t.as_bool())".format(base_exp) elif (tv.derived_func == TypeVar.HALFWIDTH): - return "{}.and_then(|t: ir::Type| t.half_width())".format(base_exp) + return "{}.and_then(|t: crate::ir::Type| t.half_width())"\ + .format(base_exp) elif (tv.derived_func == TypeVar.DOUBLEWIDTH): - return "{}.and_then(|t: ir::Type| t.double_width())"\ + return "{}.and_then(|t: crate::ir::Type| t.double_width())"\ .format(base_exp) elif (tv.derived_func == TypeVar.HALFVECTOR): - return "{}.and_then(|t: ir::Type| t.half_vector())"\ + return "{}.and_then(|t: crate::ir::Type| t.half_vector())"\ .format(base_exp) elif (tv.derived_func == TypeVar.DOUBLEVECTOR): - return "{}.and_then(|t: ir::Type| t.by(2))".format(base_exp) + return "{}.and_then(|t: crate::ir::Type| t.by(2))".format(base_exp) else: assert False, "Unknown derived function {}".format(tv.derived_func) @@ -174,7 +176,7 @@ def unwrap_inst(iref, node, fmt): arg_names = tuple( arg.name if isinstance(arg, Var) else '_' for arg in expr.args) with fmt.indented( - 'let ({}, predicate) = if let ir::InstructionData::{} {{' + 'let ({}, predicate) = if let crate::ir::InstructionData::{} {{' .format(', '.join(map(str, arg_names)), iform.name), '};'): # Fields are encoded directly. for f in iform.imm_fields: @@ -359,13 +361,13 @@ def gen_xform_group(xgrp, fmt, type_sets): fmt.doc_comment("Legalize `inst`.") fmt.line('#[allow(unused_variables,unused_assignments,non_snake_case)]') with fmt.indented('pub fn {}('.format(xgrp.name)): - fmt.line('inst: ir::Inst,') - fmt.line('func: &mut ir::Function,') - fmt.line('cfg: &mut ::flowgraph::ControlFlowGraph,') - fmt.line('isa: &::isa::TargetIsa,') + fmt.line('inst: crate::ir::Inst,') + fmt.line('func: &mut crate::ir::Function,') + fmt.line('cfg: &mut crate::flowgraph::ControlFlowGraph,') + fmt.line('isa: &crate::isa::TargetIsa,') with fmt.indented(') -> bool {', '}'): - fmt.line('use ir::InstBuilder;') - fmt.line('use cursor::{Cursor, FuncCursor};') + fmt.line('use crate::ir::InstBuilder;') + fmt.line('use crate::cursor::{Cursor, FuncCursor};') fmt.line('let mut pos = FuncCursor::new(func).at_inst(inst);') fmt.line('pos.use_srcloc(inst);') diff --git a/lib/codegen/meta-python/gen_settings.py b/lib/codegen/meta-python/gen_settings.py index 88d2a9e0cd..cb9d3615e3 100644 --- a/lib/codegen/meta-python/gen_settings.py +++ b/lib/codegen/meta-python/gen_settings.py @@ -117,10 +117,10 @@ def gen_getters(sgrp, fmt): with fmt.indented('impl Flags {', '}'): fmt.doc_comment('Get a view of the boolean predicates.') with fmt.indented( - 'pub fn predicate_view(&self) -> ::settings::PredicateView {', - '}'): + 'pub fn predicate_view(&self) -> ' + 'crate::settings::PredicateView {', '}'): fmt.format( - '::settings::PredicateView::new(&self.bytes[{}..])', + 'crate::settings::PredicateView::new(&self.bytes[{}..])', sgrp.boolean_offset) if sgrp.settings: fmt.doc_comment('Dynamic numbered predicate getter.') diff --git a/lib/codegen/meta-python/isa/x86/recipes.py b/lib/codegen/meta-python/isa/x86/recipes.py index 484f61ee6f..76544b0e28 100644 --- a/lib/codegen/meta-python/isa/x86/recipes.py +++ b/lib/codegen/meta-python/isa/x86/recipes.py @@ -1934,7 +1934,7 @@ icscc = TailRecipe( PUT_OP(bits, rex2(in_reg0, in_reg1), sink); modrm_rr(in_reg0, in_reg1, sink); // `setCC` instruction, no REX. - use ir::condcodes::IntCC::*; + use crate::ir::condcodes::IntCC::*; let setcc = match cond { Equal => 0x94, NotEqual => 0x95, @@ -1962,7 +1962,7 @@ icscc_ib = TailRecipe( let imm: i64 = imm.into(); sink.put1(imm as u8); // `setCC` instruction, no REX. - use ir::condcodes::IntCC::*; + use crate::ir::condcodes::IntCC::*; let setcc = match cond { Equal => 0x94, NotEqual => 0x95, @@ -1990,7 +1990,7 @@ icscc_id = TailRecipe( let imm: i64 = imm.into(); sink.put4(imm as u32); // `setCC` instruction, no REX. - use ir::condcodes::IntCC::*; + use crate::ir::condcodes::IntCC::*; let setcc = match cond { Equal => 0x94, NotEqual => 0x95, @@ -2030,7 +2030,7 @@ fcscc = TailRecipe( PUT_OP(bits, rex2(in_reg1, in_reg0), sink); modrm_rr(in_reg1, in_reg0, sink); // `setCC` instruction, no REX. - use ir::condcodes::FloatCC::*; + use crate::ir::condcodes::FloatCC::*; let setcc = match cond { Ordered => 0x9b, // EQ|LT|GT => setnp (P=0) Unordered => 0x9a, // UN => setp (P=1) diff --git a/lib/codegen/meta-python/test_gen_legalizer.py b/lib/codegen/meta-python/test_gen_legalizer.py index 3882bd0bf9..2b1dbf4aca 100644 --- a/lib/codegen/meta-python/test_gen_legalizer.py +++ b/lib/codegen/meta-python/test_gen_legalizer.py @@ -148,9 +148,9 @@ class TestRuntimeChecks(TestCase): self.v5 << vselect(self.v1, self.v3, self.v4), ) x = XForm(r, r) - tv2_exp = 'Some({}).map(|t: ir::Type| t.as_bool())'\ + tv2_exp = 'Some({}).map(|t: crate::ir::Type| t.as_bool())'\ .format(self.v2.get_typevar().name) - tv3_exp = 'Some({}).map(|t: ir::Type| t.as_bool())'\ + tv3_exp = 'Some({}).map(|t: crate::ir::Type| t.as_bool())'\ .format(self.v3.get_typevar().name) self.check_yo_check( diff --git a/lib/codegen/meta/Cargo.toml b/lib/codegen/meta/Cargo.toml index 92e4f34f20..2b443cb52e 100644 --- a/lib/codegen/meta/Cargo.toml +++ b/lib/codegen/meta/Cargo.toml @@ -6,6 +6,7 @@ description = "Metaprogram for cranelift-codegen code generator library" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/CraneStation/cranelift" readme = "README.md" +edition = "2018" [dependencies] cranelift-entity = { path = "../../entity", version = "0.26.0" } diff --git a/lib/codegen/meta/src/base/settings.rs b/lib/codegen/meta/src/base/settings.rs index c89a4e20ff..b792a72283 100644 --- a/lib/codegen/meta/src/base/settings.rs +++ b/lib/codegen/meta/src/base/settings.rs @@ -1,4 +1,4 @@ -use cdsl::settings::{SettingGroup, SettingGroupBuilder}; +use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder}; pub fn generate() -> SettingGroup { let mut settings = SettingGroupBuilder::new("shared"); diff --git a/lib/codegen/meta/src/cdsl/regs.rs b/lib/codegen/meta/src/cdsl/regs.rs index 4e8a34001b..11605de563 100644 --- a/lib/codegen/meta/src/cdsl/regs.rs +++ b/lib/codegen/meta/src/cdsl/regs.rs @@ -1,3 +1,4 @@ +use cranelift_entity::entity_impl; use cranelift_entity::EntityRef; #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/lib/codegen/meta/src/cdsl/types.rs b/lib/codegen/meta/src/cdsl/types.rs index 9fb7754c3c..a4e6443e47 100644 --- a/lib/codegen/meta/src/cdsl/types.rs +++ b/lib/codegen/meta/src/cdsl/types.rs @@ -5,7 +5,7 @@ use std::fmt; -use base::types as base_types; +use crate::base::types as base_types; // Numbering scheme for value types: // diff --git a/lib/codegen/meta/src/gen_registers.rs b/lib/codegen/meta/src/gen_registers.rs index 9234dc5c67..5fb326e84e 100644 --- a/lib/codegen/meta/src/gen_registers.rs +++ b/lib/codegen/meta/src/gen_registers.rs @@ -1,8 +1,8 @@ -use cdsl::isa::TargetIsa; -use cdsl::regs::{RegBank, RegClass}; +use crate::cdsl::isa::TargetIsa; +use crate::cdsl::regs::{RegBank, RegClass}; +use crate::error; +use crate::srcgen::Formatter; use cranelift_entity::EntityRef; -use error; -use srcgen::Formatter; fn gen_regbank(fmt: &mut Formatter, reg_bank: &RegBank) { let names = if reg_bank.names.len() > 0 { diff --git a/lib/codegen/meta/src/gen_settings.rs b/lib/codegen/meta/src/gen_settings.rs index 93fddce210..497c1cc2f1 100644 --- a/lib/codegen/meta/src/gen_settings.rs +++ b/lib/codegen/meta/src/gen_settings.rs @@ -1,12 +1,14 @@ -use base; -use cdsl::camel_case; -use cdsl::isa::TargetIsa; -use cdsl::settings::{BoolSetting, Predicate, Preset, Setting, SettingGroup, SpecificSetting}; -use constant_hash::{generate_table, simple_hash}; -use error; -use srcgen::{Formatter, Match}; +use crate::base; +use crate::cdsl::camel_case; +use crate::cdsl::isa::TargetIsa; +use crate::cdsl::settings::{ + BoolSetting, Predicate, Preset, Setting, SettingGroup, SpecificSetting, +}; +use crate::constant_hash::{generate_table, simple_hash}; +use crate::error; +use crate::srcgen::{Formatter, Match}; +use crate::unique_table::UniqueTable; use std::collections::HashMap; -use unique_table::UniqueTable; enum ParentGroup { None, diff --git a/lib/codegen/meta/src/gen_types.rs b/lib/codegen/meta/src/gen_types.rs index 8dbd647bee..5a9f9f8c5e 100644 --- a/lib/codegen/meta/src/gen_types.rs +++ b/lib/codegen/meta/src/gen_types.rs @@ -7,9 +7,9 @@ //! This ensures that the metaprogram and the generated program see the same //! type numbering. -use cdsl::types as cdsl_types; -use error; -use srcgen; +use crate::cdsl::types as cdsl_types; +use crate::error; +use crate::srcgen; /// Emit a constant definition of a single value type. fn emit_type(ty: &cdsl_types::ValueType, fmt: &mut srcgen::Formatter) -> Result<(), error::Error> { diff --git a/lib/codegen/meta/src/isa/arm32/mod.rs b/lib/codegen/meta/src/isa/arm32/mod.rs index 1a4fe471d7..ad615dfad2 100644 --- a/lib/codegen/meta/src/isa/arm32/mod.rs +++ b/lib/codegen/meta/src/isa/arm32/mod.rs @@ -1,6 +1,6 @@ -use cdsl::isa::{TargetIsa, TargetIsaBuilder}; -use cdsl::regs::{RegBankBuilder, RegClassBuilder}; -use cdsl::settings::{SettingGroup, SettingGroupBuilder}; +use crate::cdsl::isa::{TargetIsa, TargetIsaBuilder}; +use crate::cdsl::regs::{RegBankBuilder, RegClassBuilder}; +use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder}; fn define_settings(_shared: &SettingGroup) -> SettingGroup { let setting = SettingGroupBuilder::new("arm32"); diff --git a/lib/codegen/meta/src/isa/arm64/mod.rs b/lib/codegen/meta/src/isa/arm64/mod.rs index 63f5fa661e..7abdd51ca3 100644 --- a/lib/codegen/meta/src/isa/arm64/mod.rs +++ b/lib/codegen/meta/src/isa/arm64/mod.rs @@ -1,6 +1,6 @@ -use cdsl::isa::{TargetIsa, TargetIsaBuilder}; -use cdsl::regs::{RegBankBuilder, RegClassBuilder}; -use cdsl::settings::{SettingGroup, SettingGroupBuilder}; +use crate::cdsl::isa::{TargetIsa, TargetIsaBuilder}; +use crate::cdsl::regs::{RegBankBuilder, RegClassBuilder}; +use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder}; fn define_settings(_shared: &SettingGroup) -> SettingGroup { let setting = SettingGroupBuilder::new("arm64"); diff --git a/lib/codegen/meta/src/isa/mod.rs b/lib/codegen/meta/src/isa/mod.rs index f6d012fe78..eaa359b801 100644 --- a/lib/codegen/meta/src/isa/mod.rs +++ b/lib/codegen/meta/src/isa/mod.rs @@ -1,5 +1,5 @@ -use cdsl::isa::TargetIsa; -use cdsl::settings::SettingGroup; +use crate::cdsl::isa::TargetIsa; +use crate::cdsl::settings::SettingGroup; use std::fmt; mod arm32; diff --git a/lib/codegen/meta/src/isa/riscv/mod.rs b/lib/codegen/meta/src/isa/riscv/mod.rs index 9d82997e94..dbf0e16e8a 100644 --- a/lib/codegen/meta/src/isa/riscv/mod.rs +++ b/lib/codegen/meta/src/isa/riscv/mod.rs @@ -1,6 +1,6 @@ -use cdsl::isa::{TargetIsa, TargetIsaBuilder}; -use cdsl::regs::{RegBankBuilder, RegClassBuilder}; -use cdsl::settings::{PredicateNode, SettingGroup, SettingGroupBuilder}; +use crate::cdsl::isa::{TargetIsa, TargetIsaBuilder}; +use crate::cdsl::regs::{RegBankBuilder, RegClassBuilder}; +use crate::cdsl::settings::{PredicateNode, SettingGroup, SettingGroupBuilder}; fn define_settings(shared: &SettingGroup) -> SettingGroup { let mut setting = SettingGroupBuilder::new("riscv"); diff --git a/lib/codegen/meta/src/isa/x86/mod.rs b/lib/codegen/meta/src/isa/x86/mod.rs index 962446c9be..63087a2697 100644 --- a/lib/codegen/meta/src/isa/x86/mod.rs +++ b/lib/codegen/meta/src/isa/x86/mod.rs @@ -1,6 +1,6 @@ -use cdsl::isa::{TargetIsa, TargetIsaBuilder}; -use cdsl::regs::{RegBankBuilder, RegClassBuilder}; -use cdsl::settings::{PredicateNode, SettingGroup, SettingGroupBuilder}; +use crate::cdsl::isa::{TargetIsa, TargetIsaBuilder}; +use crate::cdsl::regs::{RegBankBuilder, RegClassBuilder}; +use crate::cdsl::settings::{PredicateNode, SettingGroup, SettingGroupBuilder}; pub fn define_settings(_shared: &SettingGroup) -> SettingGroup { let mut settings = SettingGroupBuilder::new("x86"); diff --git a/lib/codegen/meta/src/lib.rs b/lib/codegen/meta/src/lib.rs index e393079f45..d35d8cddcc 100644 --- a/lib/codegen/meta/src/lib.rs +++ b/lib/codegen/meta/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate cranelift_entity; - #[macro_use] mod cdsl; diff --git a/lib/codegen/meta/src/srcgen.rs b/lib/codegen/meta/src/srcgen.rs index 295567de80..164c477997 100644 --- a/lib/codegen/meta/src/srcgen.rs +++ b/lib/codegen/meta/src/srcgen.rs @@ -9,7 +9,7 @@ use std::fs; use std::io::Write; use std::path; -use error; +use crate::error; static SHIFTWIDTH: usize = 4; @@ -151,7 +151,7 @@ fn _indent(s: &str) -> Option { if s.is_empty() { None } else { - let t = s.trim_left(); + let t = s.trim_start(); Some(s.len() - t.len()) } } @@ -169,7 +169,7 @@ fn parse_multiline(s: &str) -> Vec { .iter() .skip(1) .filter(|l| !l.trim().is_empty()) - .map(|l| l.len() - l.trim_left().len()) + .map(|l| l.len() - l.trim_start().len()) .min(); // Strip off leading blank lines. @@ -186,12 +186,12 @@ fn parse_multiline(s: &str) -> Vec { // Note that empty lines may have fewer than `indent` chars. lines_iter .map(|l| &l[cmp::min(indent, l.len())..]) - .map(|l| l.trim_right()) + .map(|l| l.trim_end()) .map(|l| l.to_string()) .collect::>() } else { lines_iter - .map(|l| l.trim_right()) + .map(|l| l.trim_end()) .map(|l| l.to_string()) .collect::>() }; diff --git a/lib/codegen/src/abi.rs b/lib/codegen/src/abi.rs index 1a86295b8b..954c40b643 100644 --- a/lib/codegen/src/abi.rs +++ b/lib/codegen/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::{AbiParam, ArgumentExtension, ArgumentLoc, Type}; +use crate::ir::{AbiParam, ArgumentExtension, ArgumentLoc, Type}; use std::cmp::Ordering; use std::vec::Vec; @@ -182,8 +182,8 @@ pub fn legalize_abi_value(have: Type, arg: &AbiParam) -> ValueConversion { #[cfg(test)] mod tests { use super::*; - use ir::types; - use ir::AbiParam; + use crate::ir::types; + use crate::ir::AbiParam; #[test] fn legalize() { diff --git a/lib/codegen/src/binemit/memorysink.rs b/lib/codegen/src/binemit/memorysink.rs index 1e8a6ab15f..7f6c62f451 100644 --- a/lib/codegen/src/binemit/memorysink.rs +++ b/lib/codegen/src/binemit/memorysink.rs @@ -15,7 +15,7 @@ //! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe. use super::{Addend, CodeOffset, CodeSink, Reloc}; -use ir::{ExternalName, JumpTable, SourceLoc, TrapCode}; +use crate::ir::{ExternalName, JumpTable, SourceLoc, TrapCode}; use std::ptr::write_unaligned; /// A `CodeSink` that writes binary machine code directly into memory. @@ -57,13 +57,13 @@ impl<'a> MemoryCodeSink<'a> { /// A trait for receiving relocations for code that is emitted directly into memory. pub trait RelocSink { /// Add a relocation referencing an EBB at the current offset. - fn reloc_ebb(&mut self, CodeOffset, Reloc, CodeOffset); + fn reloc_ebb(&mut self, _: CodeOffset, _: Reloc, _: CodeOffset); /// Add a relocation referencing an external symbol at the current offset. - fn reloc_external(&mut self, CodeOffset, Reloc, &ExternalName, Addend); + fn reloc_external(&mut self, _: CodeOffset, _: Reloc, _: &ExternalName, _: Addend); /// Add a relocation referencing a jump table. - fn reloc_jt(&mut self, CodeOffset, Reloc, JumpTable); + fn reloc_jt(&mut self, _: CodeOffset, _: Reloc, _: JumpTable); } /// A trait for receiving trap codes and offsets. @@ -72,7 +72,7 @@ pub trait RelocSink { /// [`NullTrapSink`](binemit/trait.TrapSink.html) implementation. pub trait TrapSink { /// Add trap information for a specific offset. - fn trap(&mut self, CodeOffset, SourceLoc, TrapCode); + fn trap(&mut self, _: CodeOffset, _: SourceLoc, _: TrapCode); } impl<'a> CodeSink for MemoryCodeSink<'a> { diff --git a/lib/codegen/src/binemit/mod.rs b/lib/codegen/src/binemit/mod.rs index 9143af14e6..c4ad46c7df 100644 --- a/lib/codegen/src/binemit/mod.rs +++ b/lib/codegen/src/binemit/mod.rs @@ -10,9 +10,9 @@ mod shrink; pub use self::memorysink::{MemoryCodeSink, NullTrapSink, RelocSink, TrapSink}; pub use self::relaxation::relax_branches; pub use self::shrink::shrink_instructions; -pub use regalloc::RegDiversions; +pub use crate::regalloc::RegDiversions; -use ir::{ExternalName, Function, Inst, JumpTable, SourceLoc, TrapCode}; +use crate::ir::{ExternalName, Function, Inst, JumpTable, SourceLoc, TrapCode}; use std::fmt; /// Offset in bytes from the beginning of the function. @@ -72,28 +72,28 @@ pub trait CodeSink { fn offset(&self) -> CodeOffset; /// Add 1 byte to the code section. - fn put1(&mut self, u8); + fn put1(&mut self, _: u8); /// Add 2 bytes to the code section. - fn put2(&mut self, u16); + fn put2(&mut self, _: u16); /// Add 4 bytes to the code section. - fn put4(&mut self, u32); + fn put4(&mut self, _: u32); /// Add 8 bytes to the code section. - fn put8(&mut self, u64); + fn put8(&mut self, _: u64); /// Add a relocation referencing an EBB at the current offset. - fn reloc_ebb(&mut self, Reloc, CodeOffset); + fn reloc_ebb(&mut self, _: Reloc, _: CodeOffset); /// Add a relocation referencing an external symbol plus the addend at the current offset. - fn reloc_external(&mut self, Reloc, &ExternalName, Addend); + fn reloc_external(&mut self, _: Reloc, _: &ExternalName, _: Addend); /// Add a relocation referencing a jump table. - fn reloc_jt(&mut self, Reloc, JumpTable); + fn reloc_jt(&mut self, _: Reloc, _: JumpTable); /// Add trap information for the current offset. - fn trap(&mut self, TrapCode, SourceLoc); + fn trap(&mut self, _: TrapCode, _: SourceLoc); /// Code output is complete, read-only data may follow. fn begin_rodata(&mut self); diff --git a/lib/codegen/src/binemit/relaxation.rs b/lib/codegen/src/binemit/relaxation.rs index f658fb70b1..2ef2167d2e 100644 --- a/lib/codegen/src/binemit/relaxation.rs +++ b/lib/codegen/src/binemit/relaxation.rs @@ -27,14 +27,15 @@ //! ebb23: //! ``` -use binemit::CodeOffset; -use cursor::{Cursor, FuncCursor}; -use ir::{Function, InstructionData, Opcode}; -use isa::{EncInfo, TargetIsa}; -use iterators::IteratorExtras; -use regalloc::RegDiversions; -use timing; -use CodegenResult; +use crate::binemit::CodeOffset; +use crate::cursor::{Cursor, FuncCursor}; +use crate::ir::{Function, InstructionData, Opcode}; +use crate::isa::{EncInfo, TargetIsa}; +use crate::iterators::IteratorExtras; +use crate::regalloc::RegDiversions; +use crate::timing; +use crate::CodegenResult; +use log::debug; /// Relax branches and compute the final layout of EBB headers in `func`. /// diff --git a/lib/codegen/src/binemit/shrink.rs b/lib/codegen/src/binemit/shrink.rs index 92d2dd050f..b3cfdfa6d1 100644 --- a/lib/codegen/src/binemit/shrink.rs +++ b/lib/codegen/src/binemit/shrink.rs @@ -5,11 +5,12 @@ //! flexibility. However, once register allocation is done, this is no longer important, and we //! can switch to smaller encodings when possible. -use ir::instructions::InstructionData; -use ir::Function; -use isa::TargetIsa; -use regalloc::RegDiversions; -use timing; +use crate::ir::instructions::InstructionData; +use crate::ir::Function; +use crate::isa::TargetIsa; +use crate::regalloc::RegDiversions; +use crate::timing; +use log::debug; /// Pick the smallest valid encodings for instructions. pub fn shrink_instructions(func: &mut Function, isa: &TargetIsa) { diff --git a/lib/codegen/src/cfg_printer.rs b/lib/codegen/src/cfg_printer.rs index 382c83c658..c15ec134b9 100644 --- a/lib/codegen/src/cfg_printer.rs +++ b/lib/codegen/src/cfg_printer.rs @@ -2,9 +2,9 @@ use std::fmt::{Display, Formatter, Result, Write}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::instructions::BranchInfo; -use ir::Function; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::instructions::BranchInfo; +use crate::ir::Function; /// A utility for pretty-printing the CFG of a `Function`. pub struct CFGPrinter<'a> { diff --git a/lib/codegen/src/context.rs b/lib/codegen/src/context.rs index a0bd1e680d..a78553aa9e 100644 --- a/lib/codegen/src/context.rs +++ b/lib/codegen/src/context.rs @@ -9,28 +9,28 @@ //! contexts concurrently. Typically, you would have one context per compilation thread and only a //! single ISA instance. -use binemit::{ +use crate::binemit::{ relax_branches, shrink_instructions, CodeOffset, MemoryCodeSink, RelocSink, TrapSink, }; -use dce::do_dce; -use dominator_tree::DominatorTree; -use flowgraph::ControlFlowGraph; -use ir::Function; -use isa::TargetIsa; -use legalize_function; -use licm::do_licm; -use loop_analysis::LoopAnalysis; -use nan_canonicalization::do_nan_canonicalization; -use postopt::do_postopt; -use regalloc; -use result::CodegenResult; -use settings::{FlagsOrIsa, OptLevel}; -use simple_gvn::do_simple_gvn; -use simple_preopt::do_preopt; +use crate::dce::do_dce; +use crate::dominator_tree::DominatorTree; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::Function; +use crate::isa::TargetIsa; +use crate::legalize_function; +use crate::licm::do_licm; +use crate::loop_analysis::LoopAnalysis; +use crate::nan_canonicalization::do_nan_canonicalization; +use crate::postopt::do_postopt; +use crate::regalloc; +use crate::result::CodegenResult; +use crate::settings::{FlagsOrIsa, OptLevel}; +use crate::simple_gvn::do_simple_gvn; +use crate::simple_preopt::do_preopt; +use crate::timing; +use crate::unreachable_code::eliminate_unreachable_code; +use crate::verifier::{verify_context, verify_locations, VerifierErrors, VerifierResult}; use std::vec::Vec; -use timing; -use unreachable_code::eliminate_unreachable_code; -use verifier::{verify_context, verify_locations, VerifierErrors, VerifierResult}; /// Persistent data structures and compilation pipeline. pub struct Context { diff --git a/lib/codegen/src/cursor.rs b/lib/codegen/src/cursor.rs index daa23308f2..eae5fc0b1f 100644 --- a/lib/codegen/src/cursor.rs +++ b/lib/codegen/src/cursor.rs @@ -2,8 +2,8 @@ //! //! This module defines cursor data types that can be used for inserting instructions. -use ir; -use isa::TargetIsa; +use crate::ir; +use crate::isa::TargetIsa; /// The possible positions of a cursor. #[derive(Clone, Copy, PartialEq, Eq, Debug)] diff --git a/lib/codegen/src/dce.rs b/lib/codegen/src/dce.rs index 2c5d5e2a32..d42c36870e 100644 --- a/lib/codegen/src/dce.rs +++ b/lib/codegen/src/dce.rs @@ -3,13 +3,13 @@ //! Dead code here means instructions that have no side effects and have no //! result values used by other instructions. -use cursor::{Cursor, FuncCursor}; -use dominator_tree::DominatorTree; -use entity::EntityRef; -use ir::instructions::InstructionData; -use ir::{DataFlowGraph, Function, Inst, Opcode}; +use crate::cursor::{Cursor, FuncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::entity::EntityRef; +use crate::ir::instructions::InstructionData; +use crate::ir::{DataFlowGraph, Function, Inst, Opcode}; +use crate::timing; use std::vec::Vec; -use timing; /// Test whether the given opcode is unsafe to even consider for DCE. fn trivially_unsafe_for_dce(opcode: Opcode) -> bool { diff --git a/lib/codegen/src/dominator_tree.rs b/lib/codegen/src/dominator_tree.rs index c8c5132d73..9d20eab0d4 100644 --- a/lib/codegen/src/dominator_tree.rs +++ b/lib/codegen/src/dominator_tree.rs @@ -1,15 +1,15 @@ //! A Dominator Tree represented as mappings of Ebbs to their immediate dominator. -use entity::SecondaryMap; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::instructions::BranchInfo; -use ir::{Ebb, ExpandedProgramPoint, Function, Inst, Layout, ProgramOrder, Value}; -use packed_option::PackedOption; +use crate::entity::SecondaryMap; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::instructions::BranchInfo; +use crate::ir::{Ebb, ExpandedProgramPoint, Function, Inst, Layout, ProgramOrder, Value}; +use crate::packed_option::PackedOption; +use crate::timing; use std::cmp; use std::cmp::Ordering; use std::mem; use std::vec::Vec; -use timing; /// RPO numbers are not first assigned in a contiguous way but as multiples of STRIDE, to leave /// room for modifications of the dominator tree. @@ -671,12 +671,12 @@ impl DominatorTreePreorder { #[cfg(test)] mod tests { use super::*; - use cursor::{Cursor, FuncCursor}; - use flowgraph::ControlFlowGraph; - use ir::types::*; - use ir::{Function, InstBuilder, TrapCode}; - use settings; - use verifier::{verify_context, VerifierErrors}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::flowgraph::ControlFlowGraph; + use crate::ir::types::*; + use crate::ir::{Function, InstBuilder, TrapCode}; + use crate::settings; + use crate::verifier::{verify_context, VerifierErrors}; #[test] fn empty() { diff --git a/lib/codegen/src/flowgraph.rs b/lib/codegen/src/flowgraph.rs index 3f61f6a852..4412e53599 100644 --- a/lib/codegen/src/flowgraph.rs +++ b/lib/codegen/src/flowgraph.rs @@ -23,12 +23,12 @@ //! Here `Ebb1` and `Ebb2` would each have a single predecessor denoted as `(Ebb0, brz)` //! and `(Ebb0, jmp Ebb2)` respectively. -use bforest; -use entity::SecondaryMap; -use ir::instructions::BranchInfo; -use ir::{Ebb, Function, Inst}; +use crate::bforest; +use crate::entity::SecondaryMap; +use crate::ir::instructions::BranchInfo; +use crate::ir::{Ebb, Function, Inst}; +use crate::timing; use std::mem; -use timing; /// A basic block denoted by its enclosing Ebb and last instruction. #[derive(PartialEq, Eq)] @@ -212,8 +212,8 @@ pub type SuccIter<'a> = bforest::SetIter<'a, Ebb>; #[cfg(test)] mod tests { use super::*; - use cursor::{Cursor, FuncCursor}; - use ir::{types, Function, InstBuilder}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::ir::{types, Function, InstBuilder}; use std::vec::Vec; #[test] diff --git a/lib/codegen/src/ir/builder.rs b/lib/codegen/src/ir/builder.rs index ed5675eedf..7ed9a8e79e 100644 --- a/lib/codegen/src/ir/builder.rs +++ b/lib/codegen/src/ir/builder.rs @@ -3,11 +3,11 @@ //! A `Builder` provides a convenient interface for inserting instructions into a Cranelift //! function. Many of its methods are generated from the meta language instruction definitions. -use ir; -use ir::types; -use ir::{DataFlowGraph, InstructionData}; -use ir::{Inst, Opcode, Type, Value}; -use isa; +use crate::ir; +use crate::ir::types; +use crate::ir::{DataFlowGraph, InstructionData}; +use crate::ir::{Inst, Opcode, Type, Value}; +use crate::isa; /// Base trait for instruction builders. /// @@ -215,10 +215,10 @@ impl<'f> InstBuilderBase<'f> for ReplaceBuilder<'f> { #[cfg(test)] mod tests { - use cursor::{Cursor, FuncCursor}; - use ir::condcodes::*; - use ir::types::*; - use ir::{Function, InstBuilder, ValueDef}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::ir::condcodes::*; + use crate::ir::types::*; + use crate::ir::{Function, InstBuilder, ValueDef}; #[test] fn types() { diff --git a/lib/codegen/src/ir/dfg.rs b/lib/codegen/src/ir/dfg.rs index 905238275a..7d3e5c94ea 100644 --- a/lib/codegen/src/ir/dfg.rs +++ b/lib/codegen/src/ir/dfg.rs @@ -1,20 +1,20 @@ //! Data flow graph tracking Instructions, Values, and EBBs. -use entity::{self, PrimaryMap, SecondaryMap}; -use ir; -use ir::builder::ReplaceBuilder; -use ir::extfunc::ExtFuncData; -use ir::instructions::{BranchInfo, CallInfo, InstructionData}; -use ir::types; -use ir::{Ebb, FuncRef, Inst, SigRef, Signature, Type, Value, ValueList, ValueListPool}; -use isa::TargetIsa; -use packed_option::ReservedValue; +use crate::entity::{self, PrimaryMap, SecondaryMap}; +use crate::ir; +use crate::ir::builder::ReplaceBuilder; +use crate::ir::extfunc::ExtFuncData; +use crate::ir::instructions::{BranchInfo, CallInfo, InstructionData}; +use crate::ir::types; +use crate::ir::{Ebb, FuncRef, Inst, SigRef, Signature, Type, Value, ValueList, ValueListPool}; +use crate::isa::TargetIsa; +use crate::packed_option::ReservedValue; +use crate::write::write_operands; use std::fmt; use std::iter; use std::mem; use std::ops::{Index, IndexMut}; use std::u16; -use write::write_operands; /// A data flow graph defines all instructions and extended basic blocks in a function as well as /// the data flow dependencies between them. The DFG also tracks values which can be either @@ -1063,9 +1063,9 @@ impl DataFlowGraph { #[cfg(test)] mod tests { use super::*; - use cursor::{Cursor, FuncCursor}; - use ir::types; - use ir::{Function, InstructionData, Opcode, TrapCode}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::ir::types; + use crate::ir::{Function, InstructionData, Opcode, TrapCode}; use std::string::ToString; #[test] @@ -1218,8 +1218,8 @@ mod tests { #[test] fn aliases() { - use ir::condcodes::IntCC; - use ir::InstBuilder; + use crate::ir::condcodes::IntCC; + use crate::ir::InstBuilder; let mut func = Function::new(); let ebb0 = func.dfg.make_ebb(); diff --git a/lib/codegen/src/ir/entities.rs b/lib/codegen/src/ir/entities.rs index 185af8b9e7..b669cf77b6 100644 --- a/lib/codegen/src/ir/entities.rs +++ b/lib/codegen/src/ir/entities.rs @@ -19,6 +19,7 @@ //! The entity references all implement the `Display` trait in a way that matches the textual IR //! format. +use crate::entity::entity_impl; use std::fmt; use std::u32; @@ -318,7 +319,7 @@ mod tests { #[test] fn memory() { - use packed_option::PackedOption; + use crate::packed_option::PackedOption; use std::mem; // This is the whole point of `PackedOption`. assert_eq!( diff --git a/lib/codegen/src/ir/extfunc.rs b/lib/codegen/src/ir/extfunc.rs index 7ee4fbe8e2..9c17f34556 100644 --- a/lib/codegen/src/ir/extfunc.rs +++ b/lib/codegen/src/ir/extfunc.rs @@ -5,8 +5,8 @@ //! //! This module declares the data types used to represent external functions and call signatures. -use ir::{ArgumentLoc, ExternalName, SigRef, Type}; -use isa::{CallConv, RegInfo, RegUnit}; +use crate::ir::{ArgumentLoc, ExternalName, SigRef, Type}; +use crate::isa::{CallConv, RegInfo, RegUnit}; use std::fmt; use std::str::FromStr; use std::vec::Vec; @@ -334,7 +334,7 @@ impl fmt::Display for ExtFuncData { #[cfg(test)] mod tests { use super::*; - use ir::types::{B8, F32, I32}; + use crate::ir::types::{B8, F32, I32}; use std::string::ToString; #[test] diff --git a/lib/codegen/src/ir/extname.rs b/lib/codegen/src/ir/extname.rs index b35c9aeb05..7a9da78f7f 100644 --- a/lib/codegen/src/ir/extname.rs +++ b/lib/codegen/src/ir/extname.rs @@ -4,7 +4,7 @@ //! function. The name of an external declaration doesn't have any meaning to //! Cranelift, which compiles functions independently. -use ir::LibCall; +use crate::ir::LibCall; use std::cmp; use std::fmt::{self, Write}; use std::str::FromStr; @@ -119,7 +119,7 @@ impl FromStr for ExternalName { #[cfg(test)] mod tests { use super::ExternalName; - use ir::LibCall; + use crate::ir::LibCall; use std::string::ToString; use std::u32; diff --git a/lib/codegen/src/ir/function.rs b/lib/codegen/src/ir/function.rs index 629741b4ae..85bfdb5207 100644 --- a/lib/codegen/src/ir/function.rs +++ b/lib/codegen/src/ir/function.rs @@ -3,20 +3,20 @@ //! The `Function` struct defined in this module owns all of its extended basic blocks and //! instructions. -use binemit::CodeOffset; -use entity::{PrimaryMap, SecondaryMap}; -use ir; -use ir::{DataFlowGraph, ExternalName, Layout, Signature}; -use ir::{ +use crate::binemit::CodeOffset; +use crate::entity::{PrimaryMap, SecondaryMap}; +use crate::ir; +use crate::ir::{DataFlowGraph, ExternalName, Layout, Signature}; +use crate::ir::{ Ebb, ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Heap, HeapData, JumpTable, JumpTableData, SigRef, StackSlot, StackSlotData, Table, TableData, }; -use ir::{EbbOffsets, InstEncodings, SourceLocs, StackSlots, ValueLocations}; -use ir::{JumpTableOffsets, JumpTables}; -use isa::{CallConv, EncInfo, Encoding, Legalize, TargetIsa}; -use regalloc::RegDiversions; +use crate::ir::{EbbOffsets, InstEncodings, SourceLocs, StackSlots, ValueLocations}; +use crate::ir::{JumpTableOffsets, JumpTables}; +use crate::isa::{CallConv, EncInfo, Encoding, Legalize, TargetIsa}; +use crate::regalloc::RegDiversions; +use crate::write::write_function; use std::fmt; -use write::write_function; /// A function. /// diff --git a/lib/codegen/src/ir/globalvalue.rs b/lib/codegen/src/ir/globalvalue.rs index b46a2ab4e6..aedfa1dfc8 100644 --- a/lib/codegen/src/ir/globalvalue.rs +++ b/lib/codegen/src/ir/globalvalue.rs @@ -1,8 +1,8 @@ //! Global values. -use ir::immediates::{Imm64, Offset32}; -use ir::{ExternalName, GlobalValue, Type}; -use isa::TargetIsa; +use crate::ir::immediates::{Imm64, Offset32}; +use crate::ir::{ExternalName, GlobalValue, Type}; +use crate::isa::TargetIsa; use std::fmt; /// Information about a global value declaration. diff --git a/lib/codegen/src/ir/heap.rs b/lib/codegen/src/ir/heap.rs index f8d1b78cb0..8495fd51e3 100644 --- a/lib/codegen/src/ir/heap.rs +++ b/lib/codegen/src/ir/heap.rs @@ -1,7 +1,7 @@ //! Heaps. -use ir::immediates::Uimm64; -use ir::{GlobalValue, Type}; +use crate::ir::immediates::Uimm64; +use crate::ir::{GlobalValue, Type}; use std::fmt; /// Information about a heap declaration. diff --git a/lib/codegen/src/ir/instructions.rs b/lib/codegen/src/ir/instructions.rs index b01525ca80..f0ac7c24c1 100644 --- a/lib/codegen/src/ir/instructions.rs +++ b/lib/codegen/src/ir/instructions.rs @@ -11,14 +11,14 @@ use std::ops::{Deref, DerefMut}; use std::str::FromStr; use std::vec::Vec; -use ir; -use ir::types; -use ir::{Ebb, FuncRef, JumpTable, SigRef, Type, Value}; -use isa; +use crate::ir; +use crate::ir::types; +use crate::ir::{Ebb, FuncRef, JumpTable, SigRef, Type, Value}; +use crate::isa; -use bitset::BitSet; -use entity; -use ref_slice::{ref_slice, ref_slice_mut}; +use crate::bitset::BitSet; +use crate::entity; +use crate::ref_slice::{ref_slice, ref_slice_mut}; /// Some instructions use an external list of argument values because there is not enough space in /// the 16-byte `InstructionData` struct. These value lists are stored in a memory pool in @@ -73,7 +73,7 @@ impl FromStr for Opcode { /// Parse an Opcode name from a string. fn from_str(s: &str) -> Result { - use constant_hash::{probe, simple_hash, Table}; + use crate::constant_hash::{probe, simple_hash, Table}; impl<'a> Table<&'a str> for [Option] { fn len(&self) -> usize { @@ -645,7 +645,7 @@ mod tests { #[test] fn value_set() { - use ir::types::*; + use crate::ir::types::*; let vts = ValueTypeSet { lanes: BitSet16::from_range(0, 8), diff --git a/lib/codegen/src/ir/jumptable.rs b/lib/codegen/src/ir/jumptable.rs index 7ba0a7d13c..e436ea412f 100644 --- a/lib/codegen/src/ir/jumptable.rs +++ b/lib/codegen/src/ir/jumptable.rs @@ -3,7 +3,7 @@ //! Jump tables are declared in the preamble and assigned an `ir::entities::JumpTable` reference. //! The actual table of destinations is stored in a `JumpTableData` struct defined in this module. -use ir::entities::Ebb; +use crate::ir::entities::Ebb; use std::fmt::{self, Display, Formatter}; use std::slice::{Iter, IterMut}; use std::vec::Vec; @@ -83,8 +83,8 @@ impl Display for JumpTableData { #[cfg(test)] mod tests { use super::JumpTableData; - use entity::EntityRef; - use ir::Ebb; + use crate::entity::EntityRef; + use crate::ir::Ebb; use std::string::ToString; #[test] diff --git a/lib/codegen/src/ir/layout.rs b/lib/codegen/src/ir/layout.rs index f598246b84..748217847f 100644 --- a/lib/codegen/src/ir/layout.rs +++ b/lib/codegen/src/ir/layout.rs @@ -3,13 +3,14 @@ //! The order of extended basic blocks in a function and the order of instructions in an EBB is //! determined by the `Layout` data structure defined in this module. -use entity::SecondaryMap; -use ir::progpoint::{ExpandedProgramPoint, ProgramOrder}; -use ir::{Ebb, Inst}; -use packed_option::PackedOption; +use crate::entity::SecondaryMap; +use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder}; +use crate::ir::{Ebb, Inst}; +use crate::packed_option::PackedOption; +use crate::timing; +use log::debug; use std::cmp; use std::iter::{IntoIterator, Iterator}; -use timing; /// The `Layout` struct determines the layout of EBBs and instructions in a function. It does not /// contain definitions of instructions or EBBs, but depends on `Inst` and `Ebb` entity references @@ -741,9 +742,9 @@ impl<'f> DoubleEndedIterator for Insts<'f> { #[cfg(test)] mod tests { use super::Layout; - use cursor::{Cursor, CursorPosition}; - use entity::EntityRef; - use ir::{Ebb, Inst, ProgramOrder, SourceLoc}; + use crate::cursor::{Cursor, CursorPosition}; + use crate::entity::EntityRef; + use crate::ir::{Ebb, Inst, ProgramOrder, SourceLoc}; use std::cmp::Ordering; use std::vec::Vec; diff --git a/lib/codegen/src/ir/libcall.rs b/lib/codegen/src/ir/libcall.rs index 1e5297022e..c282de34e4 100644 --- a/lib/codegen/src/ir/libcall.rs +++ b/lib/codegen/src/ir/libcall.rs @@ -1,10 +1,10 @@ //! Naming well-known routines in the runtime library. -use ir::{ +use crate::ir::{ types, AbiParam, ArgumentPurpose, ExtFuncData, ExternalName, FuncRef, Function, Inst, Opcode, Signature, Type, }; -use isa::{CallConv, RegUnit, TargetIsa}; +use crate::isa::{CallConv, RegUnit, TargetIsa}; use std::fmt; use std::str::FromStr; diff --git a/lib/codegen/src/ir/mod.rs b/lib/codegen/src/ir/mod.rs index 716bf99b85..8167d3b607 100644 --- a/lib/codegen/src/ir/mod.rs +++ b/lib/codegen/src/ir/mod.rs @@ -23,32 +23,36 @@ mod trapcode; pub mod types; mod valueloc; -pub use ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase}; -pub use ir::dfg::{DataFlowGraph, ValueDef}; -pub use ir::entities::{ +pub use crate::ir::builder::{InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase}; +pub use crate::ir::dfg::{DataFlowGraph, ValueDef}; +pub use crate::ir::entities::{ Ebb, FuncRef, GlobalValue, Heap, Inst, JumpTable, SigRef, StackSlot, Table, Value, }; -pub use ir::extfunc::{AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature}; -pub use ir::extname::ExternalName; -pub use ir::function::Function; -pub use ir::globalvalue::GlobalValueData; -pub use ir::heap::{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::{get_libcall_funcref, get_probestack_funcref, LibCall}; -pub use ir::memflags::MemFlags; -pub use ir::progpoint::{ExpandedProgramPoint, ProgramOrder, ProgramPoint}; -pub use ir::sourceloc::SourceLoc; -pub use ir::stackslot::{StackSlotData, StackSlotKind, StackSlots}; -pub use ir::table::TableData; -pub use ir::trapcode::TrapCode; -pub use ir::types::Type; -pub use ir::valueloc::{ArgumentLoc, ValueLoc}; +pub use crate::ir::extfunc::{ + AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature, +}; +pub use crate::ir::extname::ExternalName; +pub use crate::ir::function::Function; +pub use crate::ir::globalvalue::GlobalValueData; +pub use crate::ir::heap::{HeapData, HeapStyle}; +pub use crate::ir::instructions::{ + InstructionData, Opcode, ValueList, ValueListPool, VariableArgs, +}; +pub use crate::ir::jumptable::JumpTableData; +pub use crate::ir::layout::Layout; +pub use crate::ir::libcall::{get_libcall_funcref, get_probestack_funcref, LibCall}; +pub use crate::ir::memflags::MemFlags; +pub use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder, ProgramPoint}; +pub use crate::ir::sourceloc::SourceLoc; +pub use crate::ir::stackslot::{StackSlotData, StackSlotKind, StackSlots}; +pub use crate::ir::table::TableData; +pub use crate::ir::trapcode::TrapCode; +pub use crate::ir::types::Type; +pub use crate::ir::valueloc::{ArgumentLoc, ValueLoc}; -use binemit; -use entity::{PrimaryMap, SecondaryMap}; -use isa; +use crate::binemit; +use crate::entity::{PrimaryMap, SecondaryMap}; +use crate::isa; /// Map of value locations. pub type ValueLocations = SecondaryMap; diff --git a/lib/codegen/src/ir/progpoint.rs b/lib/codegen/src/ir/progpoint.rs index 19d14892b1..abe2dd786f 100644 --- a/lib/codegen/src/ir/progpoint.rs +++ b/lib/codegen/src/ir/progpoint.rs @@ -1,7 +1,7 @@ //! Program points. -use entity::EntityRef; -use ir::{Ebb, Inst, ValueDef}; +use crate::entity::EntityRef; +use crate::ir::{Ebb, Inst, ValueDef}; use std::cmp; use std::fmt; use std::u32; @@ -146,8 +146,8 @@ pub trait ProgramOrder { #[cfg(test)] mod tests { use super::*; - use entity::EntityRef; - use ir::{Ebb, Inst}; + use crate::entity::EntityRef; + use crate::ir::{Ebb, Inst}; use std::string::ToString; #[test] diff --git a/lib/codegen/src/ir/sourceloc.rs b/lib/codegen/src/ir/sourceloc.rs index b6bea0e7d9..3f2add7346 100644 --- a/lib/codegen/src/ir/sourceloc.rs +++ b/lib/codegen/src/ir/sourceloc.rs @@ -50,7 +50,7 @@ impl fmt::Display for SourceLoc { #[cfg(test)] mod tests { - use ir::SourceLoc; + use crate::ir::SourceLoc; use std::string::ToString; #[test] diff --git a/lib/codegen/src/ir/stackslot.rs b/lib/codegen/src/ir/stackslot.rs index c574986d46..bf2d555bf2 100644 --- a/lib/codegen/src/ir/stackslot.rs +++ b/lib/codegen/src/ir/stackslot.rs @@ -3,9 +3,9 @@ //! The `StackSlotData` struct keeps track of a single stack slot in a function. //! -use entity::{Iter, IterMut, Keys, PrimaryMap}; -use ir::{StackSlot, Type}; -use packed_option::PackedOption; +use crate::entity::{Iter, IterMut, Keys, PrimaryMap}; +use crate::ir::{StackSlot, Type}; +use crate::packed_option::PackedOption; use std::cmp; use std::fmt; use std::ops::{Index, IndexMut}; @@ -340,8 +340,8 @@ impl StackSlots { #[cfg(test)] mod tests { use super::*; - use ir::types; - use ir::Function; + use crate::ir::types; + use crate::ir::Function; use std::string::ToString; #[test] diff --git a/lib/codegen/src/ir/table.rs b/lib/codegen/src/ir/table.rs index 0b019d81cd..003eb710b9 100644 --- a/lib/codegen/src/ir/table.rs +++ b/lib/codegen/src/ir/table.rs @@ -1,7 +1,7 @@ //! Tables. -use ir::immediates::Uimm64; -use ir::{GlobalValue, Type}; +use crate::ir::immediates::Uimm64; +use crate::ir::{GlobalValue, Type}; use std::fmt; /// Information about a table declaration. diff --git a/lib/codegen/src/ir/valueloc.rs b/lib/codegen/src/ir/valueloc.rs index a88a3af4de..f2c5151f09 100644 --- a/lib/codegen/src/ir/valueloc.rs +++ b/lib/codegen/src/ir/valueloc.rs @@ -3,8 +3,8 @@ //! The register allocator assigns every SSA value to either a register or a stack slot. This //! assignment is represented by a `ValueLoc` object. -use ir::StackSlot; -use isa::{RegInfo, RegUnit}; +use crate::ir::StackSlot; +use crate::isa::{RegInfo, RegUnit}; use std::fmt; /// Value location. diff --git a/lib/codegen/src/isa/arm32/abi.rs b/lib/codegen/src/isa/arm32/abi.rs index 1305685825..a1890fa329 100644 --- a/lib/codegen/src/isa/arm32/abi.rs +++ b/lib/codegen/src/isa/arm32/abi.rs @@ -1,10 +1,10 @@ //! ARM ABI implementation. use super::registers::{D, GPR, Q, S}; -use ir; -use isa::RegClass; -use regalloc::RegisterSet; -use settings as shared_settings; +use crate::ir; +use crate::isa::RegClass; +use crate::regalloc::RegisterSet; +use crate::settings as shared_settings; /// Legalize `sig`. pub fn legalize_signature( diff --git a/lib/codegen/src/isa/arm32/binemit.rs b/lib/codegen/src/isa/arm32/binemit.rs index 9f50e63993..2ca78b4d6f 100644 --- a/lib/codegen/src/isa/arm32/binemit.rs +++ b/lib/codegen/src/isa/arm32/binemit.rs @@ -1,7 +1,7 @@ //! Emitting binary ARM32 machine code. -use binemit::{bad_encoding, CodeSink}; -use ir::{Function, Inst}; -use regalloc::RegDiversions; +use crate::binemit::{bad_encoding, CodeSink}; +use crate::ir::{Function, Inst}; +use crate::regalloc::RegDiversions; include!(concat!(env!("OUT_DIR"), "/binemit-arm32.rs")); diff --git a/lib/codegen/src/isa/arm32/enc_tables.rs b/lib/codegen/src/isa/arm32/enc_tables.rs index f71dd33f87..e3833eecf7 100644 --- a/lib/codegen/src/isa/arm32/enc_tables.rs +++ b/lib/codegen/src/isa/arm32/enc_tables.rs @@ -1,10 +1,9 @@ //! Encoding tables for ARM32 ISA. -use ir; -use isa; -use isa::constraints::*; -use isa::enc_tables::*; -use isa::encoding::RecipeSizing; +use crate::isa; +use crate::isa::constraints::*; +use crate::isa::enc_tables::*; +use crate::isa::encoding::RecipeSizing; include!(concat!(env!("OUT_DIR"), "/encoding-arm32.rs")); include!(concat!(env!("OUT_DIR"), "/legalize-arm32.rs")); diff --git a/lib/codegen/src/isa/arm32/mod.rs b/lib/codegen/src/isa/arm32/mod.rs index cee753a5f0..a184061ac0 100644 --- a/lib/codegen/src/isa/arm32/mod.rs +++ b/lib/codegen/src/isa/arm32/mod.rs @@ -8,13 +8,13 @@ pub mod settings; use super::super::settings as shared_settings; #[cfg(feature = "testing_hooks")] -use binemit::CodeSink; -use binemit::{emit_function, MemoryCodeSink}; -use ir; -use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; -use isa::Builder as IsaBuilder; -use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; -use regalloc; +use crate::binemit::CodeSink; +use crate::binemit::{emit_function, MemoryCodeSink}; +use crate::ir; +use crate::isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; +use crate::isa::Builder as IsaBuilder; +use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa}; +use crate::regalloc; use std::boxed::Box; use std::fmt; use target_lexicon::{Architecture, Triple}; diff --git a/lib/codegen/src/isa/arm32/registers.rs b/lib/codegen/src/isa/arm32/registers.rs index 305890b29e..70549528cf 100644 --- a/lib/codegen/src/isa/arm32/registers.rs +++ b/lib/codegen/src/isa/arm32/registers.rs @@ -1,13 +1,13 @@ //! ARM32 register descriptions. -use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; +use crate::isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs")); #[cfg(test)] mod tests { use super::{D, GPR, INFO, S}; - use isa::RegUnit; + use crate::isa::RegUnit; use std::string::{String, ToString}; #[test] @@ -34,7 +34,7 @@ mod tests { #[test] fn overlaps() { // arm32 has the most interesting register geometries, so test `regs_overlap()` here. - use isa::regs_overlap; + use crate::isa::regs_overlap; let r0 = GPR.unit(0); let r1 = GPR.unit(1); diff --git a/lib/codegen/src/isa/arm32/settings.rs b/lib/codegen/src/isa/arm32/settings.rs index a5075597d9..d32483100f 100644 --- a/lib/codegen/src/isa/arm32/settings.rs +++ b/lib/codegen/src/isa/arm32/settings.rs @@ -1,6 +1,6 @@ //! ARM32 Settings. -use settings::{self, detail, Builder}; +use crate::settings::{self, detail, Builder}; use std::fmt; // Include code generated by `lib/codegen/meta-python/gen_settings.py`. This file contains a public diff --git a/lib/codegen/src/isa/arm64/abi.rs b/lib/codegen/src/isa/arm64/abi.rs index 79b7a97cd7..efc1f6125d 100644 --- a/lib/codegen/src/isa/arm64/abi.rs +++ b/lib/codegen/src/isa/arm64/abi.rs @@ -1,10 +1,10 @@ //! ARM 64 ABI implementation. use super::registers::{FPR, GPR}; -use ir; -use isa::RegClass; -use regalloc::RegisterSet; -use settings as shared_settings; +use crate::ir; +use crate::isa::RegClass; +use crate::regalloc::RegisterSet; +use crate::settings as shared_settings; /// Legalize `sig`. pub fn legalize_signature( diff --git a/lib/codegen/src/isa/arm64/binemit.rs b/lib/codegen/src/isa/arm64/binemit.rs index dd0654067e..05df67e5bb 100644 --- a/lib/codegen/src/isa/arm64/binemit.rs +++ b/lib/codegen/src/isa/arm64/binemit.rs @@ -1,7 +1,7 @@ //! Emitting binary ARM64 machine code. -use binemit::{bad_encoding, CodeSink}; -use ir::{Function, Inst}; -use regalloc::RegDiversions; +use crate::binemit::{bad_encoding, CodeSink}; +use crate::ir::{Function, Inst}; +use crate::regalloc::RegDiversions; include!(concat!(env!("OUT_DIR"), "/binemit-arm64.rs")); diff --git a/lib/codegen/src/isa/arm64/enc_tables.rs b/lib/codegen/src/isa/arm64/enc_tables.rs index 6007450cb5..6e1b73e0e9 100644 --- a/lib/codegen/src/isa/arm64/enc_tables.rs +++ b/lib/codegen/src/isa/arm64/enc_tables.rs @@ -1,10 +1,9 @@ //! Encoding tables for ARM64 ISA. -use ir; -use isa; -use isa::constraints::*; -use isa::enc_tables::*; -use isa::encoding::RecipeSizing; +use crate::isa; +use crate::isa::constraints::*; +use crate::isa::enc_tables::*; +use crate::isa::encoding::RecipeSizing; include!(concat!(env!("OUT_DIR"), "/encoding-arm64.rs")); include!(concat!(env!("OUT_DIR"), "/legalize-arm64.rs")); diff --git a/lib/codegen/src/isa/arm64/mod.rs b/lib/codegen/src/isa/arm64/mod.rs index 830a109b52..b438e49949 100644 --- a/lib/codegen/src/isa/arm64/mod.rs +++ b/lib/codegen/src/isa/arm64/mod.rs @@ -8,13 +8,13 @@ pub mod settings; use super::super::settings as shared_settings; #[cfg(feature = "testing_hooks")] -use binemit::CodeSink; -use binemit::{emit_function, MemoryCodeSink}; -use ir; -use isa::enc_tables::{lookup_enclist, Encodings}; -use isa::Builder as IsaBuilder; -use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; -use regalloc; +use crate::binemit::CodeSink; +use crate::binemit::{emit_function, MemoryCodeSink}; +use crate::ir; +use crate::isa::enc_tables::{lookup_enclist, Encodings}; +use crate::isa::Builder as IsaBuilder; +use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa}; +use crate::regalloc; use std::boxed::Box; use std::fmt; use target_lexicon::Triple; diff --git a/lib/codegen/src/isa/arm64/registers.rs b/lib/codegen/src/isa/arm64/registers.rs index 2c1d85e091..91ca256bbe 100644 --- a/lib/codegen/src/isa/arm64/registers.rs +++ b/lib/codegen/src/isa/arm64/registers.rs @@ -1,13 +1,13 @@ //! ARM64 register descriptions. -use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; +use crate::isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs")); #[cfg(test)] mod tests { use super::INFO; - use isa::RegUnit; + use crate::isa::RegUnit; use std::string::{String, ToString}; #[test] diff --git a/lib/codegen/src/isa/arm64/settings.rs b/lib/codegen/src/isa/arm64/settings.rs index 6d51aed6ad..6ef1fcb258 100644 --- a/lib/codegen/src/isa/arm64/settings.rs +++ b/lib/codegen/src/isa/arm64/settings.rs @@ -1,6 +1,6 @@ //! ARM64 Settings. -use settings::{self, detail, Builder}; +use crate::settings::{self, detail, Builder}; use std::fmt; // Include code generated by `lib/codegen/meta-python/gen_settings.py`. This file contains a public diff --git a/lib/codegen/src/isa/constraints.rs b/lib/codegen/src/isa/constraints.rs index 7c5da6032d..d6e8097385 100644 --- a/lib/codegen/src/isa/constraints.rs +++ b/lib/codegen/src/isa/constraints.rs @@ -7,10 +7,10 @@ //! It is the register allocator's job to make sure that the register constraints on value operands //! are satisfied. -use binemit::CodeOffset; -use ir::{Function, Inst, ValueLoc}; -use isa::{RegClass, RegUnit}; -use regalloc::RegDiversions; +use crate::binemit::CodeOffset; +use crate::ir::{Function, Inst, ValueLoc}; +use crate::isa::{RegClass, RegUnit}; +use crate::regalloc::RegDiversions; /// Register constraint for a single value operand or instruction result. #[derive(PartialEq, Debug)] diff --git a/lib/codegen/src/isa/enc_tables.rs b/lib/codegen/src/isa/enc_tables.rs index 8cc259420f..ccdbc28ebd 100644 --- a/lib/codegen/src/isa/enc_tables.rs +++ b/lib/codegen/src/isa/enc_tables.rs @@ -3,10 +3,10 @@ //! This module contains types and functions for working with the encoding tables generated by //! `lib/codegen/meta-python/gen_encoding.py`. -use constant_hash::{probe, Table}; -use ir::{Function, InstructionData, Opcode, Type}; -use isa::{Encoding, Legalize}; -use settings::PredicateView; +use crate::constant_hash::{probe, Table}; +use crate::ir::{Function, InstructionData, Opcode, Type}; +use crate::isa::{Encoding, Legalize}; +use crate::settings::PredicateView; use std::ops::Range; /// A recipe predicate. diff --git a/lib/codegen/src/isa/encoding.rs b/lib/codegen/src/isa/encoding.rs index ee643c508d..bf6a001b07 100644 --- a/lib/codegen/src/isa/encoding.rs +++ b/lib/codegen/src/isa/encoding.rs @@ -1,9 +1,9 @@ //! The `Encoding` struct. -use binemit::CodeOffset; -use ir::{Function, Inst}; -use isa::constraints::{BranchRange, RecipeConstraints}; -use regalloc::RegDiversions; +use crate::binemit::CodeOffset; +use crate::ir::{Function, Inst}; +use crate::isa::constraints::{BranchRange, RecipeConstraints}; +use crate::regalloc::RegDiversions; use std::fmt; /// Bits needed to encode an instruction as binary machine code. diff --git a/lib/codegen/src/isa/mod.rs b/lib/codegen/src/isa/mod.rs index d8eba6ccc3..291fdfb76c 100644 --- a/lib/codegen/src/isa/mod.rs +++ b/lib/codegen/src/isa/mod.rs @@ -46,24 +46,27 @@ //! The configured target ISA trait object is a `Box` which can be used for multiple //! concurrent function compilations. -pub use isa::call_conv::CallConv; -pub use isa::constraints::{BranchRange, ConstraintKind, OperandConstraint, RecipeConstraints}; -pub use isa::encoding::{base_size, EncInfo, Encoding}; -pub use isa::registers::{regs_overlap, RegClass, RegClassIndex, RegInfo, RegUnit}; -pub use isa::stack::{StackBase, StackBaseMask, StackRef}; +pub use crate::isa::call_conv::CallConv; +pub use crate::isa::constraints::{ + BranchRange, ConstraintKind, OperandConstraint, RecipeConstraints, +}; +pub use crate::isa::encoding::{base_size, EncInfo, Encoding}; +pub use crate::isa::registers::{regs_overlap, RegClass, RegClassIndex, RegInfo, RegUnit}; +pub use crate::isa::stack::{StackBase, StackBaseMask, StackRef}; -use binemit; -use flowgraph; -use ir; -use isa::enc_tables::Encodings; -use regalloc; -use result::CodegenResult; -use settings; -use settings::SetResult; +use crate::binemit; +use crate::flowgraph; +use crate::ir; +use crate::isa::enc_tables::Encodings; +use crate::regalloc; +use crate::result::CodegenResult; +use crate::settings; +use crate::settings::SetResult; +use crate::timing; +use failure_derive::Fail; use std::boxed::Box; use std::fmt; use target_lexicon::{Architecture, PointerWidth, Triple}; -use timing; #[cfg(build_riscv)] mod riscv; @@ -334,8 +337,8 @@ pub trait TargetIsa: fmt::Display + Sync { fn prologue_epilogue(&self, func: &mut ir::Function) -> CodegenResult<()> { let _tt = timing::prologue_epilogue(); // This default implementation is unlikely to be good enough. - use ir::stackslot::{StackOffset, StackSize}; - use stack_layout::layout_stack; + use crate::ir::stackslot::{StackOffset, StackSize}; + use crate::stack_layout::layout_stack; let word_size = StackSize::from(self.pointer_bytes()); diff --git a/lib/codegen/src/isa/registers.rs b/lib/codegen/src/isa/registers.rs index a11a3fbd52..4941712618 100644 --- a/lib/codegen/src/isa/registers.rs +++ b/lib/codegen/src/isa/registers.rs @@ -1,6 +1,6 @@ //! Data structures describing the registers in an ISA. -use entity::EntityRef; +use crate::entity::EntityRef; use std::fmt; /// Register units are the smallest units of register allocation. diff --git a/lib/codegen/src/isa/riscv/abi.rs b/lib/codegen/src/isa/riscv/abi.rs index ed7230d2cb..cd33de404e 100644 --- a/lib/codegen/src/isa/riscv/abi.rs +++ b/lib/codegen/src/isa/riscv/abi.rs @@ -7,10 +7,10 @@ use super::registers::{FPR, GPR}; use super::settings; -use abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; -use ir::{self, AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, Type}; -use isa::RegClass; -use regalloc::RegisterSet; +use crate::abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; +use crate::ir::{self, AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, Type}; +use crate::isa::RegClass; +use crate::regalloc::RegisterSet; use std::i32; use target_lexicon::Triple; diff --git a/lib/codegen/src/isa/riscv/binemit.rs b/lib/codegen/src/isa/riscv/binemit.rs index 120324d1be..cd153f4ac1 100644 --- a/lib/codegen/src/isa/riscv/binemit.rs +++ b/lib/codegen/src/isa/riscv/binemit.rs @@ -1,10 +1,10 @@ //! Emitting binary RISC-V machine code. -use binemit::{bad_encoding, CodeSink, Reloc}; -use ir::{Function, Inst, InstructionData}; -use isa::{RegUnit, StackBaseMask, StackRef}; -use predicates::is_signed_int; -use regalloc::RegDiversions; +use crate::binemit::{bad_encoding, CodeSink, Reloc}; +use crate::ir::{Function, Inst, InstructionData}; +use crate::isa::{RegUnit, StackBaseMask, StackRef}; +use crate::predicates::is_signed_int; +use crate::regalloc::RegDiversions; use std::u32; include!(concat!(env!("OUT_DIR"), "/binemit-riscv.rs")); diff --git a/lib/codegen/src/isa/riscv/enc_tables.rs b/lib/codegen/src/isa/riscv/enc_tables.rs index bbb7492805..19488003a3 100644 --- a/lib/codegen/src/isa/riscv/enc_tables.rs +++ b/lib/codegen/src/isa/riscv/enc_tables.rs @@ -1,11 +1,11 @@ //! Encoding tables for RISC-V. use super::registers::*; -use ir; -use isa; -use isa::constraints::*; -use isa::enc_tables::*; -use isa::encoding::{base_size, RecipeSizing}; +use crate::ir; +use crate::isa; +use crate::isa::constraints::*; +use crate::isa::enc_tables::*; +use crate::isa::encoding::{base_size, RecipeSizing}; // Include the generated encoding tables: // - `LEVEL1_RV32` diff --git a/lib/codegen/src/isa/riscv/mod.rs b/lib/codegen/src/isa/riscv/mod.rs index 393219571f..7382809893 100644 --- a/lib/codegen/src/isa/riscv/mod.rs +++ b/lib/codegen/src/isa/riscv/mod.rs @@ -8,13 +8,13 @@ pub mod settings; use super::super::settings as shared_settings; #[cfg(feature = "testing_hooks")] -use binemit::CodeSink; -use binemit::{emit_function, MemoryCodeSink}; -use ir; -use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; -use isa::Builder as IsaBuilder; -use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; -use regalloc; +use crate::binemit::CodeSink; +use crate::binemit::{emit_function, MemoryCodeSink}; +use crate::ir; +use crate::isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; +use crate::isa::Builder as IsaBuilder; +use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa}; +use crate::regalloc; use std::boxed::Box; use std::fmt; use target_lexicon::{PointerWidth, Triple}; @@ -125,13 +125,13 @@ impl TargetIsa for Isa { #[cfg(test)] mod tests { - use ir::{immediates, types}; - use ir::{Function, InstructionData, Opcode}; - use isa; - use settings::{self, Configurable}; + use crate::ir::{immediates, types}; + use crate::ir::{Function, InstructionData, Opcode}; + use crate::isa; + use crate::settings::{self, Configurable}; use std::str::FromStr; use std::string::{String, ToString}; - use target_lexicon; + use target_lexicon::triple; fn encstr(isa: &isa::TargetIsa, enc: Result) -> String { match enc { diff --git a/lib/codegen/src/isa/riscv/registers.rs b/lib/codegen/src/isa/riscv/registers.rs index d6254fe38e..4f167bae8f 100644 --- a/lib/codegen/src/isa/riscv/registers.rs +++ b/lib/codegen/src/isa/riscv/registers.rs @@ -1,13 +1,13 @@ //! RISC-V register descriptions. -use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; +use crate::isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs")); #[cfg(test)] mod tests { use super::{FPR, GPR, INFO}; - use isa::RegUnit; + use crate::isa::RegUnit; use std::string::{String, ToString}; #[test] diff --git a/lib/codegen/src/isa/riscv/settings.rs b/lib/codegen/src/isa/riscv/settings.rs index 972f5c6b5f..2530c4a860 100644 --- a/lib/codegen/src/isa/riscv/settings.rs +++ b/lib/codegen/src/isa/riscv/settings.rs @@ -1,6 +1,6 @@ //! RISC-V Settings. -use settings::{self, detail, Builder}; +use crate::settings::{self, detail, Builder}; use std::fmt; // Include code generated by `lib/codegen/meta-python/gen_settings.py`. This file contains a public @@ -11,7 +11,7 @@ include!(concat!(env!("OUT_DIR"), "/settings-riscv.rs")); #[cfg(test)] mod tests { use super::{builder, Flags}; - use settings::{self, Configurable}; + use crate::settings::{self, Configurable}; use std::string::ToString; #[test] diff --git a/lib/codegen/src/isa/stack.rs b/lib/codegen/src/isa/stack.rs index df61f77edc..cc7b578039 100644 --- a/lib/codegen/src/isa/stack.rs +++ b/lib/codegen/src/isa/stack.rs @@ -4,8 +4,8 @@ //! defined in this module expresses the low-level details of accessing a stack slot from an //! encoded instruction. -use ir::stackslot::{StackOffset, StackSlotKind, StackSlots}; -use ir::StackSlot; +use crate::ir::stackslot::{StackOffset, StackSlotKind, StackSlots}; +use crate::ir::StackSlot; /// A method for referencing a stack slot in the current stack frame. /// diff --git a/lib/codegen/src/isa/x86/abi.rs b/lib/codegen/src/isa/x86/abi.rs index 1f385af419..fd09a9511c 100644 --- a/lib/codegen/src/isa/x86/abi.rs +++ b/lib/codegen/src/isa/x86/abi.rs @@ -1,19 +1,19 @@ //! x86 ABI implementation. use super::registers::{FPR, GPR, RU}; -use abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; -use cursor::{Cursor, CursorPosition, EncCursor}; -use ir; -use ir::immediates::Imm64; -use ir::stackslot::{StackOffset, StackSize}; -use ir::{ +use crate::abi::{legalize_args, ArgAction, ArgAssigner, ValueConversion}; +use crate::cursor::{Cursor, CursorPosition, EncCursor}; +use crate::ir; +use crate::ir::immediates::Imm64; +use crate::ir::stackslot::{StackOffset, StackSize}; +use crate::ir::{ get_probestack_funcref, AbiParam, ArgumentExtension, ArgumentLoc, ArgumentPurpose, InstBuilder, ValueLoc, }; -use isa::{CallConv, RegClass, RegUnit, TargetIsa}; -use regalloc::RegisterSet; -use result::CodegenResult; -use stack_layout::layout_stack; +use crate::isa::{CallConv, RegClass, RegUnit, TargetIsa}; +use crate::regalloc::RegisterSet; +use crate::result::CodegenResult; +use crate::stack_layout::layout_stack; use std::i32; use target_lexicon::{PointerWidth, Triple}; @@ -511,7 +511,7 @@ fn insert_common_prologue( /// Insert a check that generates a trap if the stack pointer goes /// below a value in `stack_limit_arg`. fn insert_stack_check(pos: &mut EncCursor, stack_size: i64, stack_limit_arg: ir::Value) { - use ir::condcodes::IntCC; + use crate::ir::condcodes::IntCC; // Copy `stack_limit_arg` into a %rax and use it for calculating // a SP threshold. diff --git a/lib/codegen/src/isa/x86/binemit.rs b/lib/codegen/src/isa/x86/binemit.rs index c930af39fd..513d6347fa 100644 --- a/lib/codegen/src/isa/x86/binemit.rs +++ b/lib/codegen/src/isa/x86/binemit.rs @@ -2,11 +2,11 @@ use super::enc_tables::{needs_offset, needs_sib_byte}; use super::registers::RU; -use binemit::{bad_encoding, CodeSink, Reloc}; -use ir::condcodes::{CondCode, FloatCC, IntCC}; -use ir::{Ebb, Function, Inst, InstructionData, JumpTable, Opcode, TrapCode}; -use isa::{RegUnit, StackBase, StackBaseMask, StackRef}; -use regalloc::RegDiversions; +use crate::binemit::{bad_encoding, CodeSink, Reloc}; +use crate::ir::condcodes::{CondCode, FloatCC, IntCC}; +use crate::ir::{Ebb, Function, Inst, InstructionData, JumpTable, Opcode, TrapCode}; +use crate::isa::{RegUnit, StackBase, StackBaseMask, StackRef}; +use crate::regalloc::RegDiversions; include!(concat!(env!("OUT_DIR"), "/binemit-x86.rs")); @@ -270,7 +270,7 @@ fn sib(scale: u8, index: RegUnit, base: RegUnit, sink: &m /// 0x0f 0x90: SetCC. /// fn icc2opc(cond: IntCC) -> u16 { - use ir::condcodes::IntCC::*; + use crate::ir::condcodes::IntCC::*; match cond { // 0x0 = Overflow. // 0x1 = !Overflow. @@ -303,7 +303,7 @@ fn icc2opc(cond: IntCC) -> u16 { /// /// Not all floating point condition codes are supported. fn fcc2opc(cond: FloatCC) -> u16 { - use ir::condcodes::FloatCC::*; + use crate::ir::condcodes::FloatCC::*; match cond { Ordered => 0xb, // EQ|LT|GT => *np (P=0) Unordered => 0xa, // UN => *p (P=1) diff --git a/lib/codegen/src/isa/x86/enc_tables.rs b/lib/codegen/src/isa/x86/enc_tables.rs index a709d03b76..bdd3458f14 100644 --- a/lib/codegen/src/isa/x86/enc_tables.rs +++ b/lib/codegen/src/isa/x86/enc_tables.rs @@ -1,18 +1,18 @@ //! Encoding tables for x86 ISAs. use super::registers::*; -use bitset::BitSet; -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::condcodes::IntCC; -use ir::{self, Function, Inst, InstBuilder}; -use isa; -use isa::constraints::*; -use isa::enc_tables::*; -use isa::encoding::base_size; -use isa::encoding::RecipeSizing; -use isa::RegUnit; -use regalloc::RegDiversions; +use crate::bitset::BitSet; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::condcodes::IntCC; +use crate::ir::{self, Function, Inst, InstBuilder}; +use crate::isa; +use crate::isa::constraints::*; +use crate::isa::enc_tables::*; +use crate::isa::encoding::base_size; +use crate::isa::encoding::RecipeSizing; +use crate::isa::RegUnit; +use crate::regalloc::RegDiversions; include!(concat!(env!("OUT_DIR"), "/encoding-x86.rs")); include!(concat!(env!("OUT_DIR"), "/legalize-x86.rs")); @@ -228,7 +228,7 @@ fn expand_minmax( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::FloatCC; + use crate::ir::condcodes::FloatCC; let (x, y, x86_opc, bitwise_opc) = match func.dfg[inst] { ir::InstructionData::Binary { @@ -322,7 +322,7 @@ fn expand_fcvt_from_uint( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::IntCC; + use crate::ir::condcodes::IntCC; let x; match func.dfg[inst] { @@ -395,8 +395,8 @@ fn expand_fcvt_to_sint( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{FloatCC, IntCC}; - use ir::immediates::{Ieee32, Ieee64}; + use crate::ir::condcodes::{FloatCC, IntCC}; + use crate::ir::immediates::{Ieee32, Ieee64}; let x = match func.dfg[inst] { ir::InstructionData::Unary { @@ -491,8 +491,8 @@ fn expand_fcvt_to_sint_sat( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{FloatCC, IntCC}; - use ir::immediates::{Ieee32, Ieee64}; + use crate::ir::condcodes::{FloatCC, IntCC}; + use crate::ir::immediates::{Ieee32, Ieee64}; let x = match func.dfg[inst] { ir::InstructionData::Unary { @@ -611,8 +611,8 @@ fn expand_fcvt_to_uint( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{FloatCC, IntCC}; - use ir::immediates::{Ieee32, Ieee64}; + use crate::ir::condcodes::{FloatCC, IntCC}; + use crate::ir::immediates::{Ieee32, Ieee64}; let x = match func.dfg[inst] { ir::InstructionData::Unary { @@ -693,8 +693,8 @@ fn expand_fcvt_to_uint_sat( cfg: &mut ControlFlowGraph, _isa: &isa::TargetIsa, ) { - use ir::condcodes::{FloatCC, IntCC}; - use ir::immediates::{Ieee32, Ieee64}; + use crate::ir::condcodes::{FloatCC, IntCC}; + use crate::ir::immediates::{Ieee32, Ieee64}; let x = match func.dfg[inst] { ir::InstructionData::Unary { diff --git a/lib/codegen/src/isa/x86/mod.rs b/lib/codegen/src/isa/x86/mod.rs index 1dfa62bf61..10ec0e5269 100644 --- a/lib/codegen/src/isa/x86/mod.rs +++ b/lib/codegen/src/isa/x86/mod.rs @@ -8,18 +8,18 @@ pub mod settings; use super::super::settings as shared_settings; #[cfg(feature = "testing_hooks")] -use binemit::CodeSink; -use binemit::{emit_function, MemoryCodeSink}; -use ir; -use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; -use isa::Builder as IsaBuilder; -use isa::{EncInfo, RegClass, RegInfo, TargetIsa}; -use regalloc; -use result::CodegenResult; +use crate::binemit::CodeSink; +use crate::binemit::{emit_function, MemoryCodeSink}; +use crate::ir; +use crate::isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings}; +use crate::isa::Builder as IsaBuilder; +use crate::isa::{EncInfo, RegClass, RegInfo, TargetIsa}; +use crate::regalloc; +use crate::result::CodegenResult; +use crate::timing; use std::boxed::Box; use std::fmt; use target_lexicon::{PointerWidth, Triple}; -use timing; #[allow(dead_code)] struct Isa { diff --git a/lib/codegen/src/isa/x86/registers.rs b/lib/codegen/src/isa/x86/registers.rs index 5ca0c4912c..a5ebf438d4 100644 --- a/lib/codegen/src/isa/x86/registers.rs +++ b/lib/codegen/src/isa/x86/registers.rs @@ -1,13 +1,13 @@ //! x86 register descriptions. -use isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; +use crate::isa::registers::{RegBank, RegClass, RegClassData, RegInfo, RegUnit}; include!(concat!(env!("OUT_DIR"), "/registers-x86.rs")); #[cfg(test)] mod tests { use super::*; - use isa::RegUnit; + use crate::isa::RegUnit; use std::string::{String, ToString}; #[test] diff --git a/lib/codegen/src/isa/x86/settings.rs b/lib/codegen/src/isa/x86/settings.rs index 66699b1289..52eccaf9f8 100644 --- a/lib/codegen/src/isa/x86/settings.rs +++ b/lib/codegen/src/isa/x86/settings.rs @@ -1,6 +1,6 @@ //! x86 Settings. -use settings::{self, detail, Builder}; +use crate::settings::{self, detail, Builder}; use std::fmt; // Include code generated by `lib/codegen/meta-python/gen_settings.py`. This file contains a public @@ -11,7 +11,7 @@ include!(concat!(env!("OUT_DIR"), "/settings-x86.rs")); #[cfg(test)] mod tests { use super::{builder, Flags}; - use settings::{self, Configurable}; + use crate::settings::{self, Configurable}; #[test] fn presets() { diff --git a/lib/codegen/src/legalizer/boundary.rs b/lib/codegen/src/legalizer/boundary.rs index 8b7b6c564c..c4bbcc9db6 100644 --- a/lib/codegen/src/legalizer/boundary.rs +++ b/lib/codegen/src/legalizer/boundary.rs @@ -17,16 +17,17 @@ //! Between the two phases, preamble signatures and call/return arguments don't match. This //! intermediate state doesn't type check. -use abi::{legalize_abi_value, ValueConversion}; -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::instructions::CallInfo; -use ir::{ +use crate::abi::{legalize_abi_value, ValueConversion}; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::instructions::CallInfo; +use crate::ir::{ AbiParam, ArgumentLoc, ArgumentPurpose, DataFlowGraph, Ebb, Function, Inst, InstBuilder, SigRef, Signature, Type, Value, ValueLoc, }; -use isa::TargetIsa; -use legalizer::split::{isplit, vsplit}; +use crate::isa::TargetIsa; +use crate::legalizer::split::{isplit, vsplit}; +use log::debug; use std::vec::Vec; /// Legalize all the function signatures in `func`. diff --git a/lib/codegen/src/legalizer/call.rs b/lib/codegen/src/legalizer/call.rs index 21753d19db..6122937f3c 100644 --- a/lib/codegen/src/legalizer/call.rs +++ b/lib/codegen/src/legalizer/call.rs @@ -3,10 +3,10 @@ //! This module exports the `expand_call` function which transforms a `call` //! instruction into `func_addr` and `call_indirect` instructions. -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::{self, InstBuilder}; -use isa::TargetIsa; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::{self, InstBuilder}; +use crate::isa::TargetIsa; /// Expand a `call` instruction. This lowers it to a `call_indirect`, which /// is only done if the ABI doesn't support direct calls. diff --git a/lib/codegen/src/legalizer/globalvalue.rs b/lib/codegen/src/legalizer/globalvalue.rs index e6b8dce39e..344a8b8d0f 100644 --- a/lib/codegen/src/legalizer/globalvalue.rs +++ b/lib/codegen/src/legalizer/globalvalue.rs @@ -3,10 +3,10 @@ //! This module exports the `expand_global_value` function which transforms a `global_value` //! instruction into code that depends on the kind of global value referenced. -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::{self, InstBuilder}; -use isa::TargetIsa; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::{self, InstBuilder}; +use crate::isa::TargetIsa; /// Expand a `global_value` instruction according to the definition of the global value. pub fn expand_global_value( diff --git a/lib/codegen/src/legalizer/heap.rs b/lib/codegen/src/legalizer/heap.rs index 2edf2fae37..41d9778421 100644 --- a/lib/codegen/src/legalizer/heap.rs +++ b/lib/codegen/src/legalizer/heap.rs @@ -3,11 +3,11 @@ //! This module exports the `expand_heap_addr` function which transforms a `heap_addr` //! instruction into code that depends on the kind of heap referenced. -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::condcodes::IntCC; -use ir::{self, InstBuilder}; -use isa::TargetIsa; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::condcodes::IntCC; +use crate::ir::{self, InstBuilder}; +use crate::isa::TargetIsa; /// Expand a `heap_addr` instruction according to the definition of the heap. pub fn expand_heap_addr( diff --git a/lib/codegen/src/legalizer/libcall.rs b/lib/codegen/src/legalizer/libcall.rs index fb1ba6e313..c4cbac30ee 100644 --- a/lib/codegen/src/legalizer/libcall.rs +++ b/lib/codegen/src/legalizer/libcall.rs @@ -1,9 +1,9 @@ //! Expanding instructions as runtime library calls. -use ir; -use ir::{get_libcall_funcref, InstBuilder}; -use isa::TargetIsa; -use legalizer::boundary::legalize_libcall_signature; +use crate::ir; +use crate::ir::{get_libcall_funcref, InstBuilder}; +use crate::isa::TargetIsa; +use crate::legalizer::boundary::legalize_libcall_signature; use std::vec::Vec; /// Try to expand `inst` as a library call, returning true is successful. diff --git a/lib/codegen/src/legalizer/mod.rs b/lib/codegen/src/legalizer/mod.rs index f2a4636719..db0fb107fa 100644 --- a/lib/codegen/src/legalizer/mod.rs +++ b/lib/codegen/src/legalizer/mod.rs @@ -13,13 +13,13 @@ //! The legalizer does not deal with register allocation constraints. These constraints are derived //! from the encoding recipes, and solved later by the register allocator. -use bitset::BitSet; -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::types::I32; -use ir::{self, InstBuilder, MemFlags}; -use isa::TargetIsa; -use timing; +use crate::bitset::BitSet; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::types::I32; +use crate::ir::{self, InstBuilder, MemFlags}; +use crate::isa::TargetIsa; +use crate::timing; mod boundary; mod call; @@ -195,7 +195,7 @@ fn expand_br_table_jt( cfg: &mut ControlFlowGraph, isa: &TargetIsa, ) { - use ir::condcodes::IntCC; + use crate::ir::condcodes::IntCC; let (arg, default_ebb, table) = match func.dfg[inst] { ir::InstructionData::BranchTable { @@ -241,7 +241,7 @@ fn expand_br_table_conds( cfg: &mut ControlFlowGraph, _isa: &TargetIsa, ) { - use ir::condcodes::IntCC; + use crate::ir::condcodes::IntCC; let (arg, default_ebb, table) = match func.dfg[inst] { ir::InstructionData::BranchTable { diff --git a/lib/codegen/src/legalizer/split.rs b/lib/codegen/src/legalizer/split.rs index 6de664863a..9e27ae2397 100644 --- a/lib/codegen/src/legalizer/split.rs +++ b/lib/codegen/src/legalizer/split.rs @@ -64,9 +64,9 @@ //! It is possible to have circular dependencies of EBB arguments that are never used by any real //! instructions. These loops will remain in the program. -use cursor::{Cursor, CursorPosition, FuncCursor}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::{self, Ebb, Inst, InstBuilder, InstructionData, Opcode, Type, Value, ValueDef}; +use crate::cursor::{Cursor, CursorPosition, FuncCursor}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::{self, Ebb, Inst, InstBuilder, InstructionData, Opcode, Type, Value, ValueDef}; use std::iter; use std::vec::Vec; diff --git a/lib/codegen/src/legalizer/table.rs b/lib/codegen/src/legalizer/table.rs index f6005f1518..14da52612f 100644 --- a/lib/codegen/src/legalizer/table.rs +++ b/lib/codegen/src/legalizer/table.rs @@ -3,12 +3,12 @@ //! This module exports the `expand_table_addr` function which transforms a `table_addr` //! instruction into code that depends on the kind of table referenced. -use cursor::{Cursor, FuncCursor}; -use flowgraph::ControlFlowGraph; -use ir::condcodes::IntCC; -use ir::immediates::Offset32; -use ir::{self, InstBuilder}; -use isa::TargetIsa; +use crate::cursor::{Cursor, FuncCursor}; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::condcodes::IntCC; +use crate::ir::immediates::Offset32; +use crate::ir::{self, InstBuilder}; +use crate::isa::TargetIsa; /// Expand a `table_addr` instruction according to the definition of the table. pub fn expand_table_addr( diff --git a/lib/codegen/src/lib.rs b/lib/codegen/src/lib.rs index c8d4e4434f..737aca4140 100644 --- a/lib/codegen/src/lib.rs +++ b/lib/codegen/src/lib.rs @@ -49,26 +49,17 @@ #[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; -extern crate failure; -#[macro_use] -extern crate failure_derive; -#[cfg_attr(test, macro_use)] -extern crate target_lexicon; -#[macro_use] -extern crate log; - -pub use context::Context; -pub use legalizer::legalize_function; -pub use verifier::verify_function; -pub use write::write_function; +pub use crate::context::Context; +pub use crate::legalizer::legalize_function; +pub use crate::verifier::verify_function; +pub use crate::write::write_function; /// Version number of the cranelift-codegen crate. pub const VERSION: &str = env!("CARGO_PKG_VERSION"); -#[macro_use] -pub extern crate cranelift_entity as entity; -pub extern crate cranelift_bforest as bforest; +pub use cranelift_bforest as bforest; +pub use cranelift_entity as entity; pub mod binemit; pub mod cfg_printer; @@ -85,7 +76,7 @@ pub mod timing; pub mod verifier; pub mod write; -pub use entity::packed_option; +pub use crate::entity::packed_option; mod abi; mod bitset; @@ -111,7 +102,7 @@ mod stack_layout; mod topo_order; mod unreachable_code; -pub use result::{CodegenError, CodegenResult}; +pub use crate::result::{CodegenError, CodegenResult}; /// This replaces `std` in builds with `core`. #[cfg(not(feature = "std"))] diff --git a/lib/codegen/src/licm.rs b/lib/codegen/src/licm.rs index b203fdfe9e..101eb47d36 100644 --- a/lib/codegen/src/licm.rs +++ b/lib/codegen/src/licm.rs @@ -1,15 +1,15 @@ //! A Loop Invariant Code Motion optimization pass -use cursor::{Cursor, EncCursor, FuncCursor}; -use dominator_tree::DominatorTree; -use entity::{EntityList, ListPool}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use fx::FxHashSet; -use ir::{DataFlowGraph, Ebb, Function, Inst, InstBuilder, Layout, Opcode, Type, Value}; -use isa::TargetIsa; -use loop_analysis::{Loop, LoopAnalysis}; +use crate::cursor::{Cursor, EncCursor, FuncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::entity::{EntityList, ListPool}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::fx::FxHashSet; +use crate::ir::{DataFlowGraph, Ebb, Function, Inst, InstBuilder, Layout, Opcode, Type, Value}; +use crate::isa::TargetIsa; +use crate::loop_analysis::{Loop, LoopAnalysis}; +use crate::timing; use std::vec::Vec; -use timing; /// Performs the LICM pass by detecting loops within the CFG and moving /// loop-invariant instructions out of them. diff --git a/lib/codegen/src/loop_analysis.rs b/lib/codegen/src/loop_analysis.rs index 3f6490f5fb..ea26332b40 100644 --- a/lib/codegen/src/loop_analysis.rs +++ b/lib/codegen/src/loop_analysis.rs @@ -1,14 +1,15 @@ //! A loop analysis represented as mappings of loops to their header Ebb //! and parent in the loop tree. -use dominator_tree::DominatorTree; -use entity::SecondaryMap; -use entity::{Keys, PrimaryMap}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::{Ebb, Function, Layout}; -use packed_option::PackedOption; +use crate::dominator_tree::DominatorTree; +use crate::entity::entity_impl; +use crate::entity::SecondaryMap; +use crate::entity::{Keys, PrimaryMap}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::{Ebb, Function, Layout}; +use crate::packed_option::PackedOption; +use crate::timing; use std::vec::Vec; -use timing; /// A opaque reference to a code loop. #[derive(Copy, Clone, PartialEq, Eq, Hash)] @@ -231,11 +232,11 @@ impl LoopAnalysis { #[cfg(test)] mod tests { - use cursor::{Cursor, FuncCursor}; - use dominator_tree::DominatorTree; - use flowgraph::ControlFlowGraph; - use ir::{types, Function, InstBuilder}; - use loop_analysis::{Loop, LoopAnalysis}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::dominator_tree::DominatorTree; + use crate::flowgraph::ControlFlowGraph; + use crate::ir::{types, Function, InstBuilder}; + use crate::loop_analysis::{Loop, LoopAnalysis}; use std::vec::Vec; #[test] diff --git a/lib/codegen/src/nan_canonicalization.rs b/lib/codegen/src/nan_canonicalization.rs index 0f11c39fe8..235203b764 100644 --- a/lib/codegen/src/nan_canonicalization.rs +++ b/lib/codegen/src/nan_canonicalization.rs @@ -2,13 +2,13 @@ //! instructions that may return a NaN result with a sequence of operations //! that will replace nondeterministic NaN's with a single canonical NaN value. -use cursor::{Cursor, FuncCursor}; -use ir::condcodes::FloatCC; -use ir::immediates::{Ieee32, Ieee64}; -use ir::types; -use ir::types::Type; -use ir::{Function, Inst, InstBuilder, InstructionData, Opcode, Value}; -use timing; +use crate::cursor::{Cursor, FuncCursor}; +use crate::ir::condcodes::FloatCC; +use crate::ir::immediates::{Ieee32, Ieee64}; +use crate::ir::types; +use crate::ir::types::Type; +use crate::ir::{Function, Inst, InstBuilder, InstructionData, Opcode, Value}; +use crate::timing; // Canonical 32-bit and 64-bit NaN values. static CANON_32BIT_NAN: u32 = 0b01111111110000000000000000000000; diff --git a/lib/codegen/src/postopt.rs b/lib/codegen/src/postopt.rs index a57497b331..591b92ed03 100644 --- a/lib/codegen/src/postopt.rs +++ b/lib/codegen/src/postopt.rs @@ -2,14 +2,14 @@ #![allow(non_snake_case)] -use cursor::{Cursor, EncCursor}; -use ir::condcodes::{CondCode, FloatCC, IntCC}; -use ir::dfg::ValueDef; -use ir::immediates::{Imm64, Offset32}; -use ir::instructions::{Opcode, ValueList}; -use ir::{Ebb, Function, Inst, InstBuilder, InstructionData, MemFlags, Type, Value}; -use isa::TargetIsa; -use timing; +use crate::cursor::{Cursor, EncCursor}; +use crate::ir::condcodes::{CondCode, FloatCC, IntCC}; +use crate::ir::dfg::ValueDef; +use crate::ir::immediates::{Imm64, Offset32}; +use crate::ir::instructions::{Opcode, ValueList}; +use crate::ir::{Ebb, Function, Inst, InstBuilder, InstructionData, MemFlags, Type, Value}; +use crate::isa::TargetIsa; +use crate::timing; /// Information collected about a compare+branch sequence. struct CmpBrInfo { diff --git a/lib/codegen/src/predicates.rs b/lib/codegen/src/predicates.rs index eca8f2318c..d35b54c6c3 100644 --- a/lib/codegen/src/predicates.rs +++ b/lib/codegen/src/predicates.rs @@ -9,7 +9,7 @@ //! Some of these predicates may be unused in certain ISA configurations, so we suppress the //! dead code warning. -use ir; +use crate::ir; /// Check that a 64-bit floating point value is zero. #[allow(dead_code)] @@ -93,7 +93,7 @@ mod tests { #[test] fn cvt_imm64() { - use ir::immediates::Imm64; + use crate::ir::immediates::Imm64; let x1 = Imm64::new(-8); let x2 = Imm64::new(8); diff --git a/lib/codegen/src/print_errors.rs b/lib/codegen/src/print_errors.rs index de9fef8844..c4f48ef300 100644 --- a/lib/codegen/src/print_errors.rs +++ b/lib/codegen/src/print_errors.rs @@ -1,18 +1,18 @@ //! Utility routines for pretty-printing error messages. -use entity::SecondaryMap; -use ir; -use ir::entities::{AnyEntity, Ebb, Inst, Value}; -use ir::function::Function; -use isa::TargetIsa; -use result::CodegenError; +use crate::entity::SecondaryMap; +use crate::ir; +use crate::ir::entities::{AnyEntity, Ebb, Inst, Value}; +use crate::ir::function::Function; +use crate::isa::TargetIsa; +use crate::result::CodegenError; +use crate::verifier::{VerifierError, VerifierErrors}; +use crate::write::{decorate_function, FuncWriter, PlainWriter}; use std::boxed::Box; use std::fmt; use std::fmt::Write; use std::string::{String, ToString}; use std::vec::Vec; -use verifier::{VerifierError, VerifierErrors}; -use write::{decorate_function, FuncWriter, PlainWriter}; /// Pretty-print a verifier error. pub fn pretty_verifier_error<'a>( diff --git a/lib/codegen/src/regalloc/affinity.rs b/lib/codegen/src/regalloc/affinity.rs index 44d3dbb11b..39d23b31bb 100644 --- a/lib/codegen/src/regalloc/affinity.rs +++ b/lib/codegen/src/regalloc/affinity.rs @@ -8,8 +8,8 @@ //! subclass. This is just a hint, and the register allocator is allowed to pick a register from a //! larger register class instead. -use ir::{AbiParam, ArgumentLoc}; -use isa::{ConstraintKind, OperandConstraint, RegClassIndex, RegInfo, TargetIsa}; +use crate::ir::{AbiParam, ArgumentLoc}; +use crate::isa::{ConstraintKind, OperandConstraint, RegClassIndex, RegInfo, TargetIsa}; use std::fmt; /// Preferred register allocation for an SSA value. diff --git a/lib/codegen/src/regalloc/coalescing.rs b/lib/codegen/src/regalloc/coalescing.rs index cfdfd984fd..cf290e1f31 100644 --- a/lib/codegen/src/regalloc/coalescing.rs +++ b/lib/codegen/src/regalloc/coalescing.rs @@ -5,23 +5,24 @@ //! possible and inserting copies where necessary such that all argument values passed to an EBB //! parameter will belong to the same virtual register as the EBB parameter value itself. -use cursor::{Cursor, EncCursor}; -use dbg::DisplayList; -use dominator_tree::{DominatorTree, DominatorTreePreorder}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use fx::FxHashMap; -use ir::{self, InstBuilder, ProgramOrder}; -use ir::{Ebb, ExpandedProgramPoint, Function, Inst, Value}; -use isa::{EncInfo, TargetIsa}; -use regalloc::affinity::Affinity; -use regalloc::liveness::Liveness; -use regalloc::virtregs::{VirtReg, VirtRegs}; +use crate::cursor::{Cursor, EncCursor}; +use crate::dbg::DisplayList; +use crate::dominator_tree::{DominatorTree, DominatorTreePreorder}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::fx::FxHashMap; +use crate::ir::{self, InstBuilder, ProgramOrder}; +use crate::ir::{Ebb, ExpandedProgramPoint, Function, Inst, Value}; +use crate::isa::{EncInfo, TargetIsa}; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::virtregs::{VirtReg, VirtRegs}; +use crate::timing; +use log::debug; use std::cmp; use std::fmt; use std::iter; use std::slice; use std::vec::Vec; -use timing; // # Implementation // diff --git a/lib/codegen/src/regalloc/coloring.rs b/lib/codegen/src/regalloc/coloring.rs index d040140984..566dd7dee3 100644 --- a/lib/codegen/src/regalloc/coloring.rs +++ b/lib/codegen/src/regalloc/coloring.rs @@ -42,22 +42,23 @@ //! //! The exception is the entry block whose arguments are colored from the ABI requirements. -use cursor::{Cursor, EncCursor}; -use dominator_tree::DominatorTree; -use ir::{AbiParam, ArgumentLoc, InstBuilder, ValueDef}; -use ir::{Ebb, Function, Inst, Layout, SigRef, Value, ValueLoc}; -use isa::{regs_overlap, RegClass, RegInfo, RegUnit}; -use isa::{ConstraintKind, EncInfo, OperandConstraint, RecipeConstraints, TargetIsa}; -use packed_option::PackedOption; -use regalloc::affinity::Affinity; -use regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; -use regalloc::liveness::Liveness; -use regalloc::liverange::{LiveRange, LiveRangeContext}; -use regalloc::register_set::RegisterSet; -use regalloc::solver::{Solver, SolverError}; -use regalloc::RegDiversions; +use crate::cursor::{Cursor, EncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::ir::{AbiParam, ArgumentLoc, InstBuilder, ValueDef}; +use crate::ir::{Ebb, Function, Inst, Layout, SigRef, Value, ValueLoc}; +use crate::isa::{regs_overlap, RegClass, RegInfo, RegUnit}; +use crate::isa::{ConstraintKind, EncInfo, OperandConstraint, RecipeConstraints, TargetIsa}; +use crate::packed_option::PackedOption; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::liverange::{LiveRange, LiveRangeContext}; +use crate::regalloc::register_set::RegisterSet; +use crate::regalloc::solver::{Solver, SolverError}; +use crate::regalloc::RegDiversions; +use crate::timing; +use log::debug; use std::mem; -use timing; /// Data structures for the coloring pass. /// @@ -901,7 +902,7 @@ impl<'a> Context<'a> { /// branch destinations. Branch arguments and EBB parameters are not considered live on the /// edge. fn is_live_on_outgoing_edge(&self, value: Value) -> bool { - use ir::instructions::BranchInfo::*; + use crate::ir::instructions::BranchInfo::*; let inst = self.cur.current_inst().expect("Not on an instruction"); let ctx = self.liveness.context(&self.cur.func.layout); @@ -930,7 +931,7 @@ impl<'a> Context<'a> { /// /// The solver needs to be reminded of the available registers before any moves are inserted. fn shuffle_inputs(&mut self, regs: &mut RegisterSet) { - use regalloc::solver::Move::*; + use crate::regalloc::solver::Move::*; let spills = self.solver.schedule_moves(regs); diff --git a/lib/codegen/src/regalloc/context.rs b/lib/codegen/src/regalloc/context.rs index c297250ea7..7ad78743db 100644 --- a/lib/codegen/src/regalloc/context.rs +++ b/lib/codegen/src/regalloc/context.rs @@ -4,21 +4,23 @@ //! the register allocator algorithm. This doesn't preserve any data between functions, but it //! avoids allocating data structures independently for each function begin compiled. -use dominator_tree::DominatorTree; -use flowgraph::ControlFlowGraph; -use ir::Function; -use isa::TargetIsa; -use regalloc::coalescing::Coalescing; -use regalloc::coloring::Coloring; -use regalloc::live_value_tracker::LiveValueTracker; -use regalloc::liveness::Liveness; -use regalloc::reload::Reload; -use regalloc::spilling::Spilling; -use regalloc::virtregs::VirtRegs; -use result::CodegenResult; -use timing; -use topo_order::TopoOrder; -use verifier::{verify_context, verify_cssa, verify_liveness, verify_locations, VerifierErrors}; +use crate::dominator_tree::DominatorTree; +use crate::flowgraph::ControlFlowGraph; +use crate::ir::Function; +use crate::isa::TargetIsa; +use crate::regalloc::coalescing::Coalescing; +use crate::regalloc::coloring::Coloring; +use crate::regalloc::live_value_tracker::LiveValueTracker; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::reload::Reload; +use crate::regalloc::spilling::Spilling; +use crate::regalloc::virtregs::VirtRegs; +use crate::result::CodegenResult; +use crate::timing; +use crate::topo_order::TopoOrder; +use crate::verifier::{ + verify_context, verify_cssa, verify_liveness, verify_locations, VerifierErrors, +}; /// Persistent memory allocations for register allocation. pub struct Context { diff --git a/lib/codegen/src/regalloc/diversion.rs b/lib/codegen/src/regalloc/diversion.rs index 090bf936c9..516f95c610 100644 --- a/lib/codegen/src/regalloc/diversion.rs +++ b/lib/codegen/src/regalloc/diversion.rs @@ -7,10 +7,10 @@ //! These register diversions are local to an EBB. No values can be diverted when entering a new //! EBB. -use fx::FxHashMap; -use ir::{InstructionData, Opcode}; -use ir::{StackSlot, Value, ValueLoc, ValueLocations}; -use isa::{RegInfo, RegUnit}; +use crate::fx::FxHashMap; +use crate::ir::{InstructionData, Opcode}; +use crate::ir::{StackSlot, Value, ValueLoc, ValueLocations}; +use crate::isa::{RegInfo, RegUnit}; use std::collections::hash_map::{Entry, Iter}; use std::fmt; @@ -191,8 +191,8 @@ impl<'a> fmt::Display for DisplayDiversions<'a> { #[cfg(test)] mod tests { use super::*; - use entity::EntityRef; - use ir::Value; + use crate::entity::EntityRef; + use crate::ir::Value; #[test] fn inserts() { diff --git a/lib/codegen/src/regalloc/live_value_tracker.rs b/lib/codegen/src/regalloc/live_value_tracker.rs index 9fe6e2615a..1b08862e37 100644 --- a/lib/codegen/src/regalloc/live_value_tracker.rs +++ b/lib/codegen/src/regalloc/live_value_tracker.rs @@ -4,14 +4,14 @@ //! The sets of live values are computed on the fly as the tracker is moved from instruction to //! instruction, starting at the EBB header. -use dominator_tree::DominatorTree; -use entity::{EntityList, ListPool}; -use fx::FxHashMap; -use ir::{DataFlowGraph, Ebb, ExpandedProgramPoint, Inst, Layout, Value}; -use partition_slice::partition_slice; -use regalloc::affinity::Affinity; -use regalloc::liveness::Liveness; -use regalloc::liverange::LiveRange; +use crate::dominator_tree::DominatorTree; +use crate::entity::{EntityList, ListPool}; +use crate::fx::FxHashMap; +use crate::ir::{DataFlowGraph, Ebb, ExpandedProgramPoint, Inst, Layout, Value}; +use crate::partition_slice::partition_slice; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::liverange::LiveRange; use std::vec::Vec; type ValueList = EntityList; diff --git a/lib/codegen/src/regalloc/liveness.rs b/lib/codegen/src/regalloc/liveness.rs index 01f72d9adb..186aaadd60 100644 --- a/lib/codegen/src/regalloc/liveness.rs +++ b/lib/codegen/src/regalloc/liveness.rs @@ -175,17 +175,17 @@ //! //! There is some room for improvement. -use entity::SparseMap; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::dfg::ValueDef; -use ir::{Ebb, Function, Inst, Layout, ProgramPoint, Value}; -use isa::{EncInfo, OperandConstraint, TargetIsa}; -use regalloc::affinity::Affinity; -use regalloc::liverange::{LiveRange, LiveRangeContext, LiveRangeForest}; +use crate::entity::SparseMap; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::dfg::ValueDef; +use crate::ir::{Ebb, Function, Inst, Layout, ProgramPoint, Value}; +use crate::isa::{EncInfo, OperandConstraint, TargetIsa}; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::liverange::{LiveRange, LiveRangeContext, LiveRangeForest}; +use crate::timing; use std::mem; use std::ops::Index; use std::vec::Vec; -use timing; /// A set of live ranges, indexed by value number. type LiveRangeSet = SparseMap; diff --git a/lib/codegen/src/regalloc/liverange.rs b/lib/codegen/src/regalloc/liverange.rs index 7e56b88fb9..a1012ef1c4 100644 --- a/lib/codegen/src/regalloc/liverange.rs +++ b/lib/codegen/src/regalloc/liverange.rs @@ -107,10 +107,10 @@ //! of coalescing, so we would need to roll our own. //! -use bforest; -use entity::SparseMapValue; -use ir::{Ebb, ExpandedProgramPoint, Inst, Layout, ProgramOrder, ProgramPoint, Value}; -use regalloc::affinity::Affinity; +use crate::bforest; +use crate::entity::SparseMapValue; +use crate::ir::{Ebb, ExpandedProgramPoint, Inst, Layout, ProgramOrder, ProgramPoint, Value}; +use crate::regalloc::affinity::Affinity; use std::cmp::Ordering; use std::marker::PhantomData; @@ -457,10 +457,10 @@ impl SparseMapValue for GenLiveRange { #[cfg(test)] mod tests { use super::{GenLiveRange, LiveRangeContext}; - use bforest; - use entity::EntityRef; - use ir::{Ebb, Inst, Value}; - use ir::{ExpandedProgramPoint, ProgramOrder}; + use crate::bforest; + use crate::entity::EntityRef; + use crate::ir::{Ebb, Inst, Value}; + use crate::ir::{ExpandedProgramPoint, ProgramOrder}; use std::cmp::Ordering; use std::vec::Vec; diff --git a/lib/codegen/src/regalloc/pressure.rs b/lib/codegen/src/regalloc/pressure.rs index a70407bad1..1e45942585 100644 --- a/lib/codegen/src/regalloc/pressure.rs +++ b/lib/codegen/src/regalloc/pressure.rs @@ -36,8 +36,8 @@ // Remove once we're using the pressure tracker. #![allow(dead_code)] -use isa::registers::{RegClass, RegClassMask, RegInfo, MAX_TRACKED_TOPRCS}; -use regalloc::RegisterSet; +use crate::isa::registers::{RegClass, RegClassMask, RegInfo, MAX_TRACKED_TOPRCS}; +use crate::regalloc::RegisterSet; use std::cmp::min; use std::fmt; use std::iter::ExactSizeIterator; @@ -273,17 +273,17 @@ impl fmt::Display for Pressure { #[cfg(build_arm32)] mod tests { use super::Pressure; - use isa::{RegClass, TargetIsa}; - use regalloc::RegisterSet; + use crate::isa::{RegClass, TargetIsa}; + use crate::regalloc::RegisterSet; use std::borrow::Borrow; use std::boxed::Box; use std::str::FromStr; - use target_lexicon; + use target_lexicon::triple; // Make an arm32 `TargetIsa`, if possible. fn arm32() -> Option> { - use isa; - use settings; + use crate::isa; + use crate::settings; let shared_builder = settings::builder(); let shared_flags = settings::Flags::new(shared_builder); diff --git a/lib/codegen/src/regalloc/register_set.rs b/lib/codegen/src/regalloc/register_set.rs index 99a3f3e416..df73a3cda0 100644 --- a/lib/codegen/src/regalloc/register_set.rs +++ b/lib/codegen/src/regalloc/register_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::{RegClass, RegInfo, RegUnit, RegUnitMask}; +use crate::isa::registers::{RegClass, RegInfo, RegUnit, RegUnitMask}; use std::char; use std::fmt; use std::iter::ExactSizeIterator; @@ -228,7 +228,7 @@ impl fmt::Display for RegisterSet { #[cfg(test)] mod tests { use super::*; - use isa::registers::{RegClass, RegClassData}; + use crate::isa::registers::{RegClass, RegClassData}; use std::vec::Vec; // Register classes for testing. diff --git a/lib/codegen/src/regalloc/reload.rs b/lib/codegen/src/regalloc/reload.rs index 8240d7fa51..efbe2204bd 100644 --- a/lib/codegen/src/regalloc/reload.rs +++ b/lib/codegen/src/regalloc/reload.rs @@ -9,19 +9,20 @@ //! possible to minimize the number of `fill` instructions needed. This must not cause the register //! pressure limits to be exceeded. -use cursor::{Cursor, EncCursor}; -use dominator_tree::DominatorTree; -use entity::{SparseMap, SparseMapValue}; -use ir::{AbiParam, ArgumentLoc, InstBuilder}; -use ir::{Ebb, Function, Inst, InstructionData, Opcode, Value}; -use isa::RegClass; -use isa::{ConstraintKind, EncInfo, Encoding, RecipeConstraints, TargetIsa}; -use regalloc::affinity::Affinity; -use regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; -use regalloc::liveness::Liveness; +use crate::cursor::{Cursor, EncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::entity::{SparseMap, SparseMapValue}; +use crate::ir::{AbiParam, ArgumentLoc, InstBuilder}; +use crate::ir::{Ebb, Function, Inst, InstructionData, Opcode, Value}; +use crate::isa::RegClass; +use crate::isa::{ConstraintKind, EncInfo, Encoding, RecipeConstraints, TargetIsa}; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; +use crate::regalloc::liveness::Liveness; +use crate::timing; +use crate::topo_order::TopoOrder; +use log::debug; use std::vec::Vec; -use timing; -use topo_order::TopoOrder; /// Reusable data structures for the reload pass. pub struct Reload { diff --git a/lib/codegen/src/regalloc/solver.rs b/lib/codegen/src/regalloc/solver.rs index 283a461378..0b433a4587 100644 --- a/lib/codegen/src/regalloc/solver.rs +++ b/lib/codegen/src/regalloc/solver.rs @@ -99,11 +99,12 @@ //! over. use super::RegisterSet; -use dbg::DisplayList; -use entity::{SparseMap, SparseMapValue}; -use ir::Value; -use isa::{RegClass, RegUnit}; -use regalloc::register_set::RegSetIter; +use crate::dbg::DisplayList; +use crate::entity::{SparseMap, SparseMapValue}; +use crate::ir::Value; +use crate::isa::{RegClass, RegUnit}; +use crate::regalloc::register_set::RegSetIter; +use log::debug; use std::cmp; use std::fmt; use std::mem; @@ -1129,18 +1130,18 @@ impl fmt::Display for Solver { #[cfg(build_arm32)] mod tests { use super::{Move, Solver}; - use entity::EntityRef; - use ir::Value; - use isa::{RegClass, RegInfo, RegUnit, TargetIsa}; - use regalloc::RegisterSet; + use crate::entity::EntityRef; + use crate::ir::Value; + use crate::isa::{RegClass, RegInfo, RegUnit, TargetIsa}; + use crate::regalloc::RegisterSet; use std::boxed::Box; use std::str::FromStr; - use target_lexicon; + use target_lexicon::triple; // Make an arm32 `TargetIsa`, if possible. fn arm32() -> Option> { - use isa; - use settings; + use crate::isa; + use crate::settings; let shared_builder = settings::builder(); let shared_flags = settings::Flags::new(shared_builder); diff --git a/lib/codegen/src/regalloc/spilling.rs b/lib/codegen/src/regalloc/spilling.rs index 108d08b095..7bbf26422c 100644 --- a/lib/codegen/src/regalloc/spilling.rs +++ b/lib/codegen/src/regalloc/spilling.rs @@ -15,20 +15,21 @@ //! be compatible. Otherwise, the value must be copied into a new register for some of the //! operands. -use cursor::{Cursor, EncCursor}; -use dominator_tree::DominatorTree; -use ir::{ArgumentLoc, Ebb, Function, Inst, InstBuilder, SigRef, Value, ValueLoc}; -use isa::registers::{RegClass, RegClassIndex, RegClassMask, RegUnit}; -use isa::{ConstraintKind, EncInfo, RecipeConstraints, RegInfo, TargetIsa}; -use regalloc::affinity::Affinity; -use regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; -use regalloc::liveness::Liveness; -use regalloc::pressure::Pressure; -use regalloc::virtregs::VirtRegs; +use crate::cursor::{Cursor, EncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::ir::{ArgumentLoc, Ebb, Function, Inst, InstBuilder, SigRef, Value, ValueLoc}; +use crate::isa::registers::{RegClass, RegClassIndex, RegClassMask, RegUnit}; +use crate::isa::{ConstraintKind, EncInfo, RecipeConstraints, RegInfo, TargetIsa}; +use crate::regalloc::affinity::Affinity; +use crate::regalloc::live_value_tracker::{LiveValue, LiveValueTracker}; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::pressure::Pressure; +use crate::regalloc::virtregs::VirtRegs; +use crate::timing; +use crate::topo_order::TopoOrder; +use log::debug; use std::fmt; use std::vec::Vec; -use timing; -use topo_order::TopoOrder; /// Return a top-level register class which contains `unit`. fn toprc_containing_regunit(unit: RegUnit, reginfo: &RegInfo) -> RegClass { diff --git a/lib/codegen/src/regalloc/virtregs.rs b/lib/codegen/src/regalloc/virtregs.rs index 63c2e7a413..deb3b5f20b 100644 --- a/lib/codegen/src/regalloc/virtregs.rs +++ b/lib/codegen/src/regalloc/virtregs.rs @@ -11,13 +11,14 @@ //! If any values in a virtual register are spilled, they will use the same stack slot. This avoids //! memory-to-memory copies when a spilled value is passed as an EBB argument. -use dbg::DisplayList; -use dominator_tree::DominatorTreePreorder; -use entity::{EntityList, ListPool}; -use entity::{Keys, PrimaryMap, SecondaryMap}; -use ir::{Function, Value}; -use packed_option::PackedOption; -use ref_slice::ref_slice; +use crate::dbg::DisplayList; +use crate::dominator_tree::DominatorTreePreorder; +use crate::entity::entity_impl; +use crate::entity::{EntityList, ListPool}; +use crate::entity::{Keys, PrimaryMap, SecondaryMap}; +use crate::ir::{Function, Value}; +use crate::packed_option::PackedOption; +use crate::ref_slice::ref_slice; use std::cmp::Ordering; use std::fmt; use std::vec::Vec; @@ -399,8 +400,8 @@ impl VirtRegs { #[cfg(test)] mod tests { use super::*; - use entity::EntityRef; - use ir::Value; + use crate::entity::EntityRef; + use crate::ir::Value; #[test] fn empty_union_find() { diff --git a/lib/codegen/src/result.rs b/lib/codegen/src/result.rs index dace896049..5beb416a94 100644 --- a/lib/codegen/src/result.rs +++ b/lib/codegen/src/result.rs @@ -1,6 +1,7 @@ //! Result and error types representing the outcome of compiling a function. -use verifier::VerifierErrors; +use crate::verifier::VerifierErrors; +use failure_derive::Fail; /// A compilation error. /// diff --git a/lib/codegen/src/scoped_hash_map.rs b/lib/codegen/src/scoped_hash_map.rs index f7fd992ac0..97d073151b 100644 --- a/lib/codegen/src/scoped_hash_map.rs +++ b/lib/codegen/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 fx::FxHashMap; +use crate::fx::FxHashMap; use std::collections::hash_map; use std::hash::Hash; use std::mem; diff --git a/lib/codegen/src/settings.rs b/lib/codegen/src/settings.rs index 50cd38b7fa..a8ce0166f3 100644 --- a/lib/codegen/src/settings.rs +++ b/lib/codegen/src/settings.rs @@ -20,8 +20,9 @@ //! assert_eq!(f.opt_level(), settings::OptLevel::Fastest); //! ``` -use constant_hash::{probe, simple_hash}; -use isa::TargetIsa; +use crate::constant_hash::{probe, simple_hash}; +use crate::isa::TargetIsa; +use failure_derive::Fail; use std::boxed::Box; use std::fmt; use std::str; @@ -202,7 +203,7 @@ impl<'a> PredicateView<'a> { /// This module holds definitions that need to be public so the can be instantiated by generated /// code in other modules. pub mod detail { - use constant_hash; + use crate::constant_hash; use std::fmt; /// An instruction group template. diff --git a/lib/codegen/src/simple_gvn.rs b/lib/codegen/src/simple_gvn.rs index d60bdb6899..576934071d 100644 --- a/lib/codegen/src/simple_gvn.rs +++ b/lib/codegen/src/simple_gvn.rs @@ -1,13 +1,13 @@ //! A simple GVN pass. -use cursor::{Cursor, FuncCursor}; -use dominator_tree::DominatorTree; -use ir::{Function, Inst, InstructionData, Opcode, Type}; -use scoped_hash_map::ScopedHashMap; +use crate::cursor::{Cursor, FuncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::ir::{Function, Inst, InstructionData, Opcode, Type}; +use crate::scoped_hash_map::ScopedHashMap; +use crate::timing; use std::cell::{Ref, RefCell}; use std::hash::{Hash, Hasher}; use std::vec::Vec; -use timing; /// Test whether the given opcode is unsafe to even consider for GVN. fn trivially_unsafe_for_gvn(opcode: Opcode) -> bool { @@ -121,7 +121,7 @@ pub fn do_simple_gvn(func: &mut Function, domtree: &mut DominatorTree) { ty: ctrl_typevar, pos: &pos, }; - use scoped_hash_map::Entry::*; + use crate::scoped_hash_map::Entry::*; match visible_values.entry(key) { Occupied(entry) => { debug_assert!(domtree.dominates(*entry.get(), inst, &func.layout)); diff --git a/lib/codegen/src/simple_preopt.rs b/lib/codegen/src/simple_preopt.rs index e252659d35..793def27ef 100644 --- a/lib/codegen/src/simple_preopt.rs +++ b/lib/codegen/src/simple_preopt.rs @@ -2,15 +2,15 @@ #![allow(non_snake_case)] -use cursor::{Cursor, FuncCursor}; -use divconst_magic_numbers::{magicS32, magicS64, magicU32, magicU64}; -use divconst_magic_numbers::{MS32, MS64, MU32, MU64}; -use ir::dfg::ValueDef; -use ir::instructions::Opcode; -use ir::types::{I32, I64}; -use ir::Inst; -use ir::{DataFlowGraph, Function, InstBuilder, InstructionData, Type, Value}; -use timing; +use crate::cursor::{Cursor, FuncCursor}; +use crate::divconst_magic_numbers::{magicS32, magicS64, magicU32, magicU64}; +use crate::divconst_magic_numbers::{MS32, MS64, MU32, MU64}; +use crate::ir::dfg::ValueDef; +use crate::ir::instructions::Opcode; +use crate::ir::types::{I32, I64}; +use crate::ir::Inst; +use crate::ir::{DataFlowGraph, Function, InstBuilder, InstructionData, Type, Value}; +use crate::timing; //---------------------------------------------------------------------- // diff --git a/lib/codegen/src/stack_layout.rs b/lib/codegen/src/stack_layout.rs index 9a34e06374..54eff6a759 100644 --- a/lib/codegen/src/stack_layout.rs +++ b/lib/codegen/src/stack_layout.rs @@ -1,8 +1,8 @@ //! Computing stack layout. -use ir::stackslot::{StackOffset, StackSize, StackSlotKind}; -use ir::StackSlots; -use result::{CodegenError, CodegenResult}; +use crate::ir::stackslot::{StackOffset, StackSize, StackSlotKind}; +use crate::ir::StackSlots; +use crate::result::{CodegenError, CodegenResult}; use std::cmp::{max, min}; /// Compute the stack frame layout. @@ -111,10 +111,10 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> CodegenResu #[cfg(test)] mod tests { use super::layout_stack; - use ir::stackslot::StackOffset; - use ir::types; - use ir::{StackSlotData, StackSlotKind, StackSlots}; - use result::CodegenError; + use crate::ir::stackslot::StackOffset; + use crate::ir::types; + use crate::ir::{StackSlotData, StackSlotKind, StackSlots}; + use crate::result::CodegenError; #[test] fn layout() { diff --git a/lib/codegen/src/timing.rs b/lib/codegen/src/timing.rs index 285e4102a1..b3aaab1f41 100644 --- a/lib/codegen/src/timing.rs +++ b/lib/codegen/src/timing.rs @@ -102,6 +102,7 @@ impl fmt::Display for Pass { #[cfg(feature = "std")] mod details { use super::{Pass, DESCRIPTIONS, NUM_PASSES}; + use log::debug; use std::cell::{Cell, RefCell}; use std::fmt; use std::mem; diff --git a/lib/codegen/src/topo_order.rs b/lib/codegen/src/topo_order.rs index aaedaf0e10..9486b054f4 100644 --- a/lib/codegen/src/topo_order.rs +++ b/lib/codegen/src/topo_order.rs @@ -1,8 +1,8 @@ //! Topological order of EBBs, according to the dominator tree. -use dominator_tree::DominatorTree; -use entity::SparseSet; -use ir::{Ebb, Layout}; +use crate::dominator_tree::DominatorTree; +use crate::entity::SparseSet; +use crate::ir::{Ebb, Layout}; use std::vec::Vec; /// Present EBBs in a topological order such that all dominating EBBs are guaranteed to be visited @@ -90,10 +90,10 @@ impl TopoOrder { #[cfg(test)] mod tests { use super::*; - use cursor::{Cursor, FuncCursor}; - use dominator_tree::DominatorTree; - use flowgraph::ControlFlowGraph; - use ir::{Function, InstBuilder}; + use crate::cursor::{Cursor, FuncCursor}; + use crate::dominator_tree::DominatorTree; + use crate::flowgraph::ControlFlowGraph; + use crate::ir::{Function, InstBuilder}; use std::iter; #[test] diff --git a/lib/codegen/src/unreachable_code.rs b/lib/codegen/src/unreachable_code.rs index 74cc6f4ea4..95e2955245 100644 --- a/lib/codegen/src/unreachable_code.rs +++ b/lib/codegen/src/unreachable_code.rs @@ -1,10 +1,11 @@ //! Unreachable code elimination. -use cursor::{Cursor, FuncCursor}; -use dominator_tree::DominatorTree; -use flowgraph::ControlFlowGraph; -use ir; -use timing; +use crate::cursor::{Cursor, FuncCursor}; +use crate::dominator_tree::DominatorTree; +use crate::flowgraph::ControlFlowGraph; +use crate::ir; +use crate::timing; +use log::debug; /// Eliminate unreachable code. /// diff --git a/lib/codegen/src/verifier/cssa.rs b/lib/codegen/src/verifier/cssa.rs index 3162bfb5e9..6014ff8030 100644 --- a/lib/codegen/src/verifier/cssa.rs +++ b/lib/codegen/src/verifier/cssa.rs @@ -1,13 +1,13 @@ //! Verify conventional SSA form. -use dbg::DisplayList; -use dominator_tree::{DominatorTree, DominatorTreePreorder}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::{ExpandedProgramPoint, Function}; -use regalloc::liveness::Liveness; -use regalloc::virtregs::VirtRegs; -use timing; -use verifier::{VerifierErrors, VerifierStepResult}; +use crate::dbg::DisplayList; +use crate::dominator_tree::{DominatorTree, DominatorTreePreorder}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::{ExpandedProgramPoint, Function}; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::virtregs::VirtRegs; +use crate::timing; +use crate::verifier::{VerifierErrors, VerifierStepResult}; /// Verify conventional SSA form for `func`. /// diff --git a/lib/codegen/src/verifier/flags.rs b/lib/codegen/src/verifier/flags.rs index 022ba5e1f3..9be8d48280 100644 --- a/lib/codegen/src/verifier/flags.rs +++ b/lib/codegen/src/verifier/flags.rs @@ -1,13 +1,13 @@ //! Verify CPU flags values. -use entity::{SecondaryMap, SparseSet}; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir; -use ir::instructions::BranchInfo; -use isa; -use packed_option::PackedOption; -use timing; -use verifier::{VerifierErrors, VerifierStepResult}; +use crate::entity::{SecondaryMap, SparseSet}; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir; +use crate::ir::instructions::BranchInfo; +use crate::isa; +use crate::packed_option::PackedOption; +use crate::timing; +use crate::verifier::{VerifierErrors, VerifierStepResult}; /// Verify that CPU flags are used correctly. /// diff --git a/lib/codegen/src/verifier/liveness.rs b/lib/codegen/src/verifier/liveness.rs index e5fae0585f..c77ac82e16 100644 --- a/lib/codegen/src/verifier/liveness.rs +++ b/lib/codegen/src/verifier/liveness.rs @@ -1,14 +1,14 @@ //! Liveness verifier. -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir::entities::AnyEntity; -use ir::{ExpandedProgramPoint, Function, Inst, ProgramOrder, ProgramPoint, Value}; -use isa::TargetIsa; -use regalloc::liveness::Liveness; -use regalloc::liverange::LiveRange; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir::entities::AnyEntity; +use crate::ir::{ExpandedProgramPoint, Function, Inst, ProgramOrder, ProgramPoint, Value}; +use crate::isa::TargetIsa; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::liverange::LiveRange; +use crate::timing; +use crate::verifier::{VerifierErrors, VerifierStepResult}; use std::cmp::Ordering; -use timing; -use verifier::{VerifierErrors, VerifierStepResult}; /// Verify liveness information for `func`. /// diff --git a/lib/codegen/src/verifier/locations.rs b/lib/codegen/src/verifier/locations.rs index f03a2bed37..26e5edfaf1 100644 --- a/lib/codegen/src/verifier/locations.rs +++ b/lib/codegen/src/verifier/locations.rs @@ -1,11 +1,11 @@ //! Verify value locations. -use ir; -use isa; -use regalloc::liveness::Liveness; -use regalloc::RegDiversions; -use timing; -use verifier::{VerifierErrors, VerifierStepResult}; +use crate::ir; +use crate::isa; +use crate::regalloc::liveness::Liveness; +use crate::regalloc::RegDiversions; +use crate::timing; +use crate::verifier::{VerifierErrors, VerifierStepResult}; /// Verify value locations for `func`. /// @@ -303,7 +303,7 @@ impl<'a> LocationVerifier<'a> { divert: &RegDiversions, errors: &mut VerifierErrors, ) -> VerifierStepResult<()> { - use ir::instructions::BranchInfo::*; + use crate::ir::instructions::BranchInfo::*; // We can only check CFG edges if we have a liveness analysis. let liveness = match self.liveness { diff --git a/lib/codegen/src/verifier/mod.rs b/lib/codegen/src/verifier/mod.rs index adcf9d5a93..1268ed489f 100644 --- a/lib/codegen/src/verifier/mod.rs +++ b/lib/codegen/src/verifier/mod.rs @@ -57,26 +57,27 @@ //! of arguments must match the destination type, and the lane indexes must be in range. use self::flags::verify_flags; -use dbg::DisplayList; -use dominator_tree::DominatorTree; -use entity::SparseSet; -use flowgraph::{BasicBlock, ControlFlowGraph}; -use ir; -use ir::entities::AnyEntity; -use ir::instructions::{BranchInfo, CallInfo, InstructionFormat, ResolvedConstraint}; -use ir::{ +use crate::dbg::DisplayList; +use crate::dominator_tree::DominatorTree; +use crate::entity::SparseSet; +use crate::flowgraph::{BasicBlock, ControlFlowGraph}; +use crate::ir; +use crate::ir::entities::AnyEntity; +use crate::ir::instructions::{BranchInfo, CallInfo, InstructionFormat, ResolvedConstraint}; +use crate::ir::{ types, ArgumentLoc, Ebb, FuncRef, Function, GlobalValue, Inst, JumpTable, Opcode, SigRef, StackSlot, StackSlotKind, Type, Value, ValueDef, ValueList, ValueLoc, }; -use isa::TargetIsa; -use iterators::IteratorExtras; -use settings::FlagsOrIsa; +use crate::isa::TargetIsa; +use crate::iterators::IteratorExtras; +use crate::settings::FlagsOrIsa; +use crate::timing; +use failure_derive::Fail; use std::cmp::Ordering; use std::collections::BTreeSet; use std::fmt::{self, Display, Formatter, Write}; use std::string::String; use std::vec::Vec; -use timing; pub use self::cssa::verify_cssa; pub use self::liveness::verify_liveness; @@ -90,14 +91,14 @@ pub use self::locations::verify_locations; /// as the error message. macro_rules! report { ( $errors: expr, $loc: expr, $msg: tt ) => { - $errors.0.push(::verifier::VerifierError { + $errors.0.push(crate::verifier::VerifierError { location: $loc.into(), message: String::from($msg), }) }; ( $errors: expr, $loc: expr, $fmt: tt, $( $arg: expr ),+ ) => { - $errors.0.push(::verifier::VerifierError { + $errors.0.push(crate::verifier::VerifierError { location: $loc.into(), message: format!( $fmt, $( $arg ),+ ), }) @@ -551,7 +552,7 @@ impl<'a> Verifier<'a> { inst: Inst, errors: &mut VerifierErrors, ) -> VerifierStepResult<()> { - use ir::instructions::InstructionData::*; + use crate::ir::instructions::InstructionData::*; for &arg in self.func.dfg.inst_args(inst) { self.verify_inst_arg(inst, arg, errors)?; @@ -1699,10 +1700,10 @@ impl<'a> Verifier<'a> { #[cfg(test)] mod tests { use super::{Verifier, VerifierError, VerifierErrors}; - use entity::EntityList; - use ir::instructions::{InstructionData, Opcode}; - use ir::Function; - use settings; + use crate::entity::EntityList; + use crate::ir::instructions::{InstructionData, Opcode}; + use crate::ir::Function; + use crate::settings; macro_rules! assert_err_with_msg { ($e:expr, $msg:expr) => { diff --git a/lib/codegen/src/write.rs b/lib/codegen/src/write.rs index 6629f0f3be..c01e7b8bd4 100644 --- a/lib/codegen/src/write.rs +++ b/lib/codegen/src/write.rs @@ -3,11 +3,11 @@ //! 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 `cranelift-reader` crate. -use entity::SecondaryMap; -use ir::entities::AnyEntity; -use ir::{DataFlowGraph, Ebb, Function, Inst, SigRef, Type, Value, ValueDef}; -use isa::{RegInfo, TargetIsa}; -use packed_option::ReservedValue; +use crate::entity::SecondaryMap; +use crate::ir::entities::AnyEntity; +use crate::ir::{DataFlowGraph, Ebb, Function, Inst, SigRef, Type, Value, ValueDef}; +use crate::isa::{RegInfo, TargetIsa}; +use crate::packed_option::ReservedValue; use std::fmt::{self, Write}; use std::string::String; use std::vec::Vec; @@ -413,7 +413,7 @@ pub fn write_operands( inst: Inst, ) -> fmt::Result { let pool = &dfg.value_lists; - use ir::instructions::InstructionData::*; + use crate::ir::instructions::InstructionData::*; match dfg[inst] { Unary { arg, .. } => write!(w, " {}", arg), UnaryImm { imm, .. } => write!(w, " {}", imm), @@ -663,9 +663,9 @@ impl<'a> fmt::Display for DisplayValuesWithDelimiter<'a> { #[cfg(test)] mod tests { - use cursor::{Cursor, CursorPosition, FuncCursor}; - use ir::types; - use ir::{ExternalName, Function, InstBuilder, StackSlotData, StackSlotKind}; + use crate::cursor::{Cursor, CursorPosition, FuncCursor}; + use crate::ir::types; + use crate::ir::{ExternalName, Function, InstBuilder, StackSlotData, StackSlotKind}; use std::string::ToString; #[test] @@ -714,7 +714,7 @@ mod tests { #[test] fn aliases() { - use ir::InstBuilder; + use crate::ir::InstBuilder; let mut func = Function::new(); { diff --git a/lib/entity/Cargo.toml b/lib/entity/Cargo.toml index a7eeae5787..ca28428af9 100644 --- a/lib/entity/Cargo.toml +++ b/lib/entity/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/CraneStation/cranelift" categories = ["no-std"] readme = "README.md" keywords = ["entity", "set", "map"] +edition = "2018" [features] default = ["std"] diff --git a/lib/entity/src/boxed_slice.rs b/lib/entity/src/boxed_slice.rs index 6f9890e7d7..c97522467c 100644 --- a/lib/entity/src/boxed_slice.rs +++ b/lib/entity/src/boxed_slice.rs @@ -1,11 +1,11 @@ //! Boxed slices for `PrimaryMap`. -use iter::{Iter, IterMut}; -use keys::Keys; +use crate::iter::{Iter, IterMut}; +use crate::keys::Keys; +use crate::EntityRef; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::slice; -use EntityRef; /// A slice mapping `K -> V` allocating dense entity references. /// @@ -144,7 +144,7 @@ where #[cfg(test)] mod tests { use super::*; - use primary::PrimaryMap; + use crate::primary::PrimaryMap; // `EntityRef` impl for testing. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/lib/entity/src/iter.rs b/lib/entity/src/iter.rs index f818bb0cf5..27053a0962 100644 --- a/lib/entity/src/iter.rs +++ b/lib/entity/src/iter.rs @@ -1,9 +1,9 @@ //! A double-ended iterator over entity references and entities. +use crate::EntityRef; use std::iter::Enumerate; use std::marker::PhantomData; use std::slice; -use EntityRef; /// Iterate over all keys in order. pub struct Iter<'a, K: EntityRef, V> diff --git a/lib/entity/src/keys.rs b/lib/entity/src/keys.rs index e0165f21b7..ea5bd89441 100644 --- a/lib/entity/src/keys.rs +++ b/lib/entity/src/keys.rs @@ -3,8 +3,8 @@ //! When `std::iter::Step` is stabilized, `Keys` could be implemented as a wrapper around //! `std::ops::Range`, but for now, we implement it manually. +use crate::EntityRef; use std::marker::PhantomData; -use EntityRef; /// Iterate over all keys in order. pub struct Keys { diff --git a/lib/entity/src/lib.rs b/lib/entity/src/lib.rs index e86ea0d8fd..cde226690b 100644 --- a/lib/entity/src/lib.rs +++ b/lib/entity/src/lib.rs @@ -71,7 +71,7 @@ pub extern crate core as __core; pub trait EntityRef: Copy + Eq { /// Create a new entity reference from a small integer. /// This should crash if the requested index is not representable. - fn new(usize) -> Self; + fn new(_: usize) -> Self; /// Get the index that was used to create this entity reference. fn index(self) -> usize; diff --git a/lib/entity/src/list.rs b/lib/entity/src/list.rs index c2b399da2c..37ac92ad0b 100644 --- a/lib/entity/src/list.rs +++ b/lib/entity/src/list.rs @@ -1,8 +1,8 @@ //! Small lists of entity references. +use crate::EntityRef; use std::marker::PhantomData; use std::mem; use std::vec::Vec; -use EntityRef; /// A small list of entity references allocated from a pool. /// @@ -483,7 +483,7 @@ impl EntityList { mod tests { use super::*; use super::{sclass_for_length, sclass_size}; - use EntityRef; + use crate::EntityRef; /// An opaque reference to an instruction in a function. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/lib/entity/src/map.rs b/lib/entity/src/map.rs index c7ced088f7..47e40d0a74 100644 --- a/lib/entity/src/map.rs +++ b/lib/entity/src/map.rs @@ -1,12 +1,12 @@ //! Densely numbered entity references as mapping keys. -use iter::{Iter, IterMut}; -use keys::Keys; +use crate::iter::{Iter, IterMut}; +use crate::keys::Keys; +use crate::EntityRef; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::slice; use std::vec::Vec; -use EntityRef; /// A mapping `K -> V` for densely indexed entity references. /// diff --git a/lib/entity/src/primary.rs b/lib/entity/src/primary.rs index 6d710c2e4f..7a45fa9582 100644 --- a/lib/entity/src/primary.rs +++ b/lib/entity/src/primary.rs @@ -1,13 +1,13 @@ //! Densely numbered entity references as mapping keys. -use boxed_slice::BoxedSlice; -use iter::{Iter, IterMut}; -use keys::Keys; +use crate::boxed_slice::BoxedSlice; +use crate::iter::{Iter, IterMut}; +use crate::keys::Keys; +use crate::EntityRef; use std::iter::FromIterator; use std::marker::PhantomData; use std::ops::{Index, IndexMut}; use std::slice; use std::vec::Vec; -use EntityRef; /// A primary mapping `K -> V` allocating dense entity references. /// diff --git a/lib/entity/src/set.rs b/lib/entity/src/set.rs index 58f1a7da0a..80765130e6 100644 --- a/lib/entity/src/set.rs +++ b/lib/entity/src/set.rs @@ -1,9 +1,9 @@ //! Densely numbered entity references as set keys. -use keys::Keys; +use crate::keys::Keys; +use crate::EntityRef; use std::marker::PhantomData; use std::vec::Vec; -use EntityRef; /// A set of `K` for densely indexed entity references. /// diff --git a/lib/entity/src/sparse.rs b/lib/entity/src/sparse.rs index b1af505304..a07dc589b1 100644 --- a/lib/entity/src/sparse.rs +++ b/lib/entity/src/sparse.rs @@ -7,12 +7,12 @@ //! > Briggs, Torczon, *An efficient representation for sparse sets*, //! ACM Letters on Programming Languages and Systems, Volume 2, Issue 1-4, March-Dec. 1993. -use map::SecondaryMap; +use crate::map::SecondaryMap; +use crate::EntityRef; use std::mem; use std::slice; use std::u32; use std::vec::Vec; -use EntityRef; /// Trait for extracting keys from values stored in a `SparseMap`. /// @@ -230,7 +230,7 @@ pub type SparseSet = SparseMap; #[cfg(test)] mod tests { use super::*; - use EntityRef; + use crate::EntityRef; /// An opaque reference to an instruction in a function. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/lib/faerie/Cargo.toml b/lib/faerie/Cargo.toml index 003ec93846..0edc0c723c 100644 --- a/lib/faerie/Cargo.toml +++ b/lib/faerie/Cargo.toml @@ -7,6 +7,7 @@ repository = "https://github.com/CraneStation/cranelift" documentation = "https://cranelift.readthedocs.io/" license = "Apache-2.0 WITH LLVM-exception" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0" } diff --git a/lib/faerie/src/backend.rs b/lib/faerie/src/backend.rs index 164d722396..6941fb6312 100644 --- a/lib/faerie/src/backend.rs +++ b/lib/faerie/src/backend.rs @@ -1,6 +1,7 @@ //! Defines `FaerieBackend`. -use container; +use crate::container; +use crate::traps::{FaerieTrapManifest, FaerieTrapSink}; use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::{self, binemit, ir}; @@ -12,7 +13,6 @@ use faerie; use failure::Error; use std::fs::File; use target_lexicon::Triple; -use traps::{FaerieTrapManifest, FaerieTrapSink}; #[derive(Debug)] /// Setting to enable collection of traps. Setting this to `Enabled` in diff --git a/lib/faerie/src/lib.rs b/lib/faerie/src/lib.rs index f9de8e7ab6..1f7167a8ce 100644 --- a/lib/faerie/src/lib.rs +++ b/lib/faerie/src/lib.rs @@ -28,16 +28,9 @@ ) )] -extern crate cranelift_codegen; -extern crate cranelift_module; -extern crate faerie; -extern crate failure; -extern crate goblin; -extern crate target_lexicon; - mod backend; mod container; pub mod traps; -pub use backend::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; -pub use container::Format; +pub use crate::backend::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; +pub use crate::container::Format; diff --git a/lib/filetests/Cargo.toml b/lib/filetests/Cargo.toml index 84701f2e83..2dc722be82 100644 --- a/lib/filetests/Cargo.toml +++ b/lib/filetests/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0 WITH LLVM-exception" documentation = "https://cranelift.readthedocs.io/en/latest/testing.html#file-tests" repository = "https://github.com/CraneStation/cranelift" publish = false +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", features = ["testing_hooks"] } diff --git a/lib/filetests/src/concurrent.rs b/lib/filetests/src/concurrent.rs index ae04a3b6c5..30e2c94cfe 100644 --- a/lib/filetests/src/concurrent.rs +++ b/lib/filetests/src/concurrent.rs @@ -3,18 +3,19 @@ //! This module provides the `ConcurrentRunner` struct which uses a pool of threads to run tests //! concurrently. +use crate::runone; +use crate::TestResult; use cranelift_codegen::dbg::LOG_FILENAME_PREFIX; use cranelift_codegen::timing; use file_per_thread_logger; +use log::error; use num_cpus; -use runone; use std::panic::catch_unwind; use std::path::{Path, PathBuf}; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; -use TestResult; /// Request sent to worker threads contains jobid and path. struct Request(usize, PathBuf); diff --git a/lib/filetests/src/lib.rs b/lib/filetests/src/lib.rs index ccdaab791a..084620e3a0 100644 --- a/lib/filetests/src/lib.rs +++ b/lib/filetests/src/lib.rs @@ -23,18 +23,9 @@ ) )] -extern crate cranelift_codegen; -extern crate cranelift_preopt; -extern crate cranelift_reader; -extern crate file_per_thread_logger; -extern crate filecheck; -extern crate num_cpus; -#[macro_use] -extern crate log; - +use crate::runner::TestRunner; use cranelift_codegen::timing; use cranelift_reader::TestCommand; -use runner::TestRunner; use std::path::Path; use std::time; diff --git a/lib/filetests/src/match_directive.rs b/lib/filetests/src/match_directive.rs index 9a8d94a4df..29c9fa6bae 100644 --- a/lib/filetests/src/match_directive.rs +++ b/lib/filetests/src/match_directive.rs @@ -9,7 +9,7 @@ pub fn match_directive<'a>(comment: &'a str, directive: &str) -> Option<&'a str> directive.ends_with(':'), "Directive must include trailing colon" ); - let text = comment.trim_left_matches(';').trim_left(); + let text = comment.trim_left_matches(';').trim_start(); if text.starts_with(directive) { Some(text[directive.len()..].trim()) } else { diff --git a/lib/filetests/src/runner.rs b/lib/filetests/src/runner.rs index 37224c2dd3..4c84551dd9 100644 --- a/lib/filetests/src/runner.rs +++ b/lib/filetests/src/runner.rs @@ -3,15 +3,15 @@ //! This module implements the `TestRunner` struct which manages executing tests as well as //! scanning directories for tests. -use concurrent::{ConcurrentRunner, Reply}; +use crate::concurrent::{ConcurrentRunner, Reply}; +use crate::runone; +use crate::TestResult; use cranelift_codegen::timing; -use runone; use std::error::Error; use std::ffi::OsStr; use std::fmt::{self, Display}; use std::path::{Path, PathBuf}; use std::time; -use TestResult; /// Timeout in seconds when we're not making progress. const TIMEOUT_PANIC: usize = 10; diff --git a/lib/filetests/src/runone.rs b/lib/filetests/src/runone.rs index 04c1e22f3b..a7b95dc7b5 100644 --- a/lib/filetests/src/runone.rs +++ b/lib/filetests/src/runone.rs @@ -1,5 +1,7 @@ //! Run the tests in a single test file. +use crate::subtest::{Context, SubTest, SubtestResult}; +use crate::{new_subtest, TestResult}; use cranelift_codegen::ir::Function; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::print_errors::pretty_verifier_error; @@ -8,13 +10,12 @@ use cranelift_codegen::timing; use cranelift_codegen::verify_function; use cranelift_reader::parse_test; use cranelift_reader::IsaSpec; +use log::info; use std::borrow::Cow; use std::fs; use std::io::{self, Read}; use std::path::Path; use std::time; -use subtest::{Context, SubTest, SubtestResult}; -use {new_subtest, TestResult}; /// Read an entire file into a string. fn read_to_string>(path: P) -> io::Result { diff --git a/lib/filetests/src/test_binemit.rs b/lib/filetests/src/test_binemit.rs index da8310bfe6..47fa59a2c0 100644 --- a/lib/filetests/src/test_binemit.rs +++ b/lib/filetests/src/test_binemit.rs @@ -3,6 +3,8 @@ //! The `binemit` test command generates binary machine code for every instruction in the input //! functions and compares the results to the expected output. +use crate::match_directive::match_directive; +use crate::subtest::{Context, SubTest, SubtestResult}; use cranelift_codegen::binemit; use cranelift_codegen::binemit::{CodeSink, RegDiversions}; use cranelift_codegen::dbg::DisplayList; @@ -11,11 +13,9 @@ use cranelift_codegen::ir::entities::AnyEntity; use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::settings::OptLevel; use cranelift_reader::TestCommand; -use match_directive::match_directive; use std::borrow::Cow; use std::collections::HashMap; use std::fmt::Write; -use subtest::{Context, SubTest, SubtestResult}; struct TestBinEmit; diff --git a/lib/filetests/src/test_cat.rs b/lib/filetests/src/test_cat.rs index ad37b444e6..88ebadf11e 100644 --- a/lib/filetests/src/test_cat.rs +++ b/lib/filetests/src/test_cat.rs @@ -1,9 +1,9 @@ //! The `cat` subtest. +use crate::subtest::{self, Context, SubTest, SubtestResult}; use cranelift_codegen::ir::Function; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{self, Context, SubTest, SubtestResult}; /// Object implementing the `test cat` sub-test. /// diff --git a/lib/filetests/src/test_compile.rs b/lib/filetests/src/test_compile.rs index 4ff112eab9..7cb9c702a4 100644 --- a/lib/filetests/src/test_compile.rs +++ b/lib/filetests/src/test_compile.rs @@ -2,12 +2,13 @@ //! //! The `compile` test command runs each function through the full code generator pipeline +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::{binemit, ir}; use cranelift_reader::TestCommand; +use log::info; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestCompile; diff --git a/lib/filetests/src/test_dce.rs b/lib/filetests/src/test_dce.rs index 6c1645d5fc..2b07654f64 100644 --- a/lib/filetests/src/test_dce.rs +++ b/lib/filetests/src/test_dce.rs @@ -5,12 +5,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestDCE; diff --git a/lib/filetests/src/test_domtree.rs b/lib/filetests/src/test_domtree.rs index 93a1b74a9d..c2683591f2 100644 --- a/lib/filetests/src/test_domtree.rs +++ b/lib/filetests/src/test_domtree.rs @@ -12,16 +12,16 @@ //! We verify that the dominator tree annotations are complete and correct. //! +use crate::match_directive::match_directive; +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen::dominator_tree::{DominatorTree, DominatorTreePreorder}; use cranelift_codegen::flowgraph::ControlFlowGraph; use cranelift_codegen::ir::entities::AnyEntity; use cranelift_codegen::ir::Function; use cranelift_reader::TestCommand; -use match_directive::match_directive; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fmt::{self, Write}; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestDomtree; diff --git a/lib/filetests/src/test_legalizer.rs b/lib/filetests/src/test_legalizer.rs index 10821ee6ab..cb9ab8858c 100644 --- a/lib/filetests/src/test_legalizer.rs +++ b/lib/filetests/src/test_legalizer.rs @@ -3,12 +3,12 @@ //! The `test legalizer` test command runs each function through `legalize_function()` and sends //! the result to filecheck. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestLegalizer; diff --git a/lib/filetests/src/test_licm.rs b/lib/filetests/src/test_licm.rs index 6c4ef0795d..32360cadc7 100644 --- a/lib/filetests/src/test_licm.rs +++ b/lib/filetests/src/test_licm.rs @@ -5,12 +5,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestLICM; diff --git a/lib/filetests/src/test_postopt.rs b/lib/filetests/src/test_postopt.rs index 4789fd00c7..e7919b13ca 100644 --- a/lib/filetests/src/test_postopt.rs +++ b/lib/filetests/src/test_postopt.rs @@ -2,12 +2,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestPostopt; diff --git a/lib/filetests/src/test_preopt.rs b/lib/filetests/src/test_preopt.rs index 43566bdfa5..2da3005df6 100644 --- a/lib/filetests/src/test_preopt.rs +++ b/lib/filetests/src/test_preopt.rs @@ -5,13 +5,13 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_preopt::optimize; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestPreopt; diff --git a/lib/filetests/src/test_print_cfg.rs b/lib/filetests/src/test_print_cfg.rs index 4de4a3e7f4..7053234dc3 100644 --- a/lib/filetests/src/test_print_cfg.rs +++ b/lib/filetests/src/test_print_cfg.rs @@ -5,10 +5,10 @@ use std::borrow::Cow; +use crate::subtest::{self, Context, SubTest, SubtestResult}; use cranelift_codegen::cfg_printer::CFGPrinter; use cranelift_codegen::ir::Function; use cranelift_reader::TestCommand; -use subtest::{self, Context, SubTest, SubtestResult}; /// 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 e09623a691..a813b43e2f 100644 --- a/lib/filetests/src/test_regalloc.rs +++ b/lib/filetests/src/test_regalloc.rs @@ -5,12 +5,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestRegalloc; diff --git a/lib/filetests/src/test_shrink.rs b/lib/filetests/src/test_shrink.rs index 7d909c6187..2cbd2b614f 100644 --- a/lib/filetests/src/test_shrink.rs +++ b/lib/filetests/src/test_shrink.rs @@ -5,12 +5,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestShrink; diff --git a/lib/filetests/src/test_simple_gvn.rs b/lib/filetests/src/test_simple_gvn.rs index 5b664a4f74..3752129a92 100644 --- a/lib/filetests/src/test_simple_gvn.rs +++ b/lib/filetests/src/test_simple_gvn.rs @@ -5,12 +5,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestSimpleGVN; diff --git a/lib/filetests/src/test_simple_preopt.rs b/lib/filetests/src/test_simple_preopt.rs index 803aa944e7..8b2ea6999c 100644 --- a/lib/filetests/src/test_simple_preopt.rs +++ b/lib/filetests/src/test_simple_preopt.rs @@ -2,12 +2,12 @@ //! //! The resulting function is sent to `filecheck`. +use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use cranelift_codegen; use cranelift_codegen::ir::Function; use cranelift_codegen::print_errors::pretty_error; use cranelift_reader::TestCommand; use std::borrow::Cow; -use subtest::{run_filecheck, Context, SubTest, SubtestResult}; struct TestSimplePreopt; diff --git a/lib/filetests/src/test_verifier.rs b/lib/filetests/src/test_verifier.rs index 90dcad7e20..7e057248fb 100644 --- a/lib/filetests/src/test_verifier.rs +++ b/lib/filetests/src/test_verifier.rs @@ -9,13 +9,13 @@ //! This annotation means that the verifier is expected to given an error for the jump instruction //! containing the substring "jump to non-existent EBB". +use crate::match_directive::match_directive; +use crate::subtest::{Context, SubTest, SubtestResult}; use cranelift_codegen::ir::Function; use cranelift_codegen::verify_function; use cranelift_reader::TestCommand; -use match_directive::match_directive; use std::borrow::{Borrow, Cow}; use std::fmt::Write; -use subtest::{Context, SubTest, SubtestResult}; struct TestVerifier; diff --git a/lib/frontend/Cargo.toml b/lib/frontend/Cargo.toml index 87791458e9..826edf278e 100644 --- a/lib/frontend/Cargo.toml +++ b/lib/frontend/Cargo.toml @@ -8,6 +8,7 @@ documentation = "https://cranelift.readthedocs.io/" categories = ["no-std"] repository = "https://github.com/CraneStation/cranelift" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/frontend/src/frontend.rs b/lib/frontend/src/frontend.rs index d3c364b0d6..2ed09fbd01 100644 --- a/lib/frontend/src/frontend.rs +++ b/lib/frontend/src/frontend.rs @@ -1,4 +1,6 @@ //! A frontend for building Cranelift IR from other languages. +use crate::ssa::{Block, SSABuilder, SideEffects}; +use crate::variable::Variable; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::entity::{EntitySet, SecondaryMap}; use cranelift_codegen::ir; @@ -11,9 +13,7 @@ use cranelift_codegen::ir::{ }; use cranelift_codegen::isa::{TargetFrontendConfig, TargetIsa}; use cranelift_codegen::packed_option::PackedOption; -use ssa::{Block, SSABuilder, SideEffects}; use std::vec::Vec; -use variable::Variable; /// Structure used for translating a series of functions into Cranelift IR. /// @@ -822,15 +822,15 @@ impl<'a> FunctionBuilder<'a> { #[cfg(test)] mod tests { use super::greatest_divisible_power_of_two; + use crate::frontend::{FunctionBuilder, FunctionBuilderContext}; + use crate::Variable; use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::types::*; use cranelift_codegen::ir::{AbiParam, ExternalName, Function, InstBuilder, Signature}; use cranelift_codegen::isa::CallConv; use cranelift_codegen::settings; use cranelift_codegen::verifier::verify_function; - use frontend::{FunctionBuilder, FunctionBuilderContext}; use std::string::ToString; - use Variable; fn sample_function(lazy_seal: bool) { let mut sig = Signature::new(CallConv::SystemV); diff --git a/lib/frontend/src/lib.rs b/lib/frontend/src/lib.rs index 97514a75f2..3f8ec616cc 100644 --- a/lib/frontend/src/lib.rs +++ b/lib/frontend/src/lib.rs @@ -180,15 +180,10 @@ #[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; -extern crate cranelift_codegen; -#[cfg(test)] -extern crate target_lexicon; -#[macro_use] -extern crate log; -pub use frontend::{FunctionBuilder, FunctionBuilderContext}; -pub use switch::Switch; -pub use variable::Variable; +pub use crate::frontend::{FunctionBuilder, FunctionBuilderContext}; +pub use crate::switch::Switch; +pub use crate::variable::Variable; mod frontend; mod ssa; diff --git a/lib/frontend/src/ssa.rs b/lib/frontend/src/ssa.rs index 15ba1c98ca..1046e960a2 100644 --- a/lib/frontend/src/ssa.rs +++ b/lib/frontend/src/ssa.rs @@ -5,6 +5,7 @@ //! In: Jhala R., De Bosschere K. (eds) Compiler Construction. CC 2013. //! Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg +use crate::Variable; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::entity::{EntityRef, PrimaryMap, SecondaryMap}; use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; @@ -16,7 +17,6 @@ use cranelift_codegen::packed_option::ReservedValue; use std::mem; use std::u32; use std::vec::Vec; -use Variable; /// Structure containing the data relevant the construction of SSA for a given function. /// @@ -749,6 +749,8 @@ impl SSABuilder { #[cfg(test)] mod tests { + use crate::ssa::SSABuilder; + use crate::Variable; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::instructions::BranchInfo; @@ -756,8 +758,6 @@ mod tests { use cranelift_codegen::ir::{Function, Inst, InstBuilder, JumpTableData, Opcode}; use cranelift_codegen::settings; use cranelift_codegen::verify_function; - use ssa::SSABuilder; - use Variable; #[test] fn simple_block() { diff --git a/lib/frontend/src/switch.rs b/lib/frontend/src/switch.rs index ce3a2d943f..d5af64ed8c 100644 --- a/lib/frontend/src/switch.rs +++ b/lib/frontend/src/switch.rs @@ -1,6 +1,7 @@ +use crate::frontend::FunctionBuilder; use cranelift_codegen::ir::condcodes::IntCC; use cranelift_codegen::ir::*; -use frontend::FunctionBuilder; +use log::debug; use std::collections::HashMap; use std::vec::Vec; @@ -200,8 +201,8 @@ impl ContiguousCaseRange { #[cfg(test)] mod tests { use super::*; + use crate::frontend::FunctionBuilderContext; use cranelift_codegen::ir::Function; - use frontend::FunctionBuilderContext; use std::string::ToString; macro_rules! setup { diff --git a/lib/module/Cargo.toml b/lib/module/Cargo.toml index 1694d065b2..826a00cf72 100644 --- a/lib/module/Cargo.toml +++ b/lib/module/Cargo.toml @@ -8,6 +8,7 @@ documentation = "https://cranelift.readthedocs.io/" categories = ["no-std"] license = "Apache-2.0 WITH LLVM-exception" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/module/src/backend.rs b/lib/module/src/backend.rs index 8138009341..37e235edb7 100644 --- a/lib/module/src/backend.rs +++ b/lib/module/src/backend.rs @@ -1,13 +1,13 @@ //! Defines the `Backend` trait. +use crate::DataContext; +use crate::Linkage; +use crate::ModuleNamespace; +use crate::ModuleResult; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::Context; use cranelift_codegen::{binemit, ir}; use std::marker; -use DataContext; -use Linkage; -use ModuleNamespace; -use ModuleResult; /// A `Backend` implements the functionality needed to support a `Module`. /// @@ -46,7 +46,7 @@ where type Product; /// Create a new `Backend` instance. - fn new(Self::Builder) -> Self; + fn new(_: Self::Builder) -> Self; /// Return the `TargetIsa` to compile for. fn isa(&self) -> &TargetIsa; diff --git a/lib/module/src/lib.rs b/lib/module/src/lib.rs index 7e31dc9f3c..bd6ca28c8a 100644 --- a/lib/module/src/lib.rs +++ b/lib/module/src/lib.rs @@ -29,21 +29,13 @@ #[cfg_attr(test, macro_use)] extern crate alloc; -extern crate cranelift_codegen; -#[macro_use] -extern crate cranelift_entity; -#[macro_use] -extern crate failure; -#[macro_use] -extern crate log; - mod backend; mod data_context; mod module; -pub use backend::Backend; -pub use data_context::{DataContext, DataDescription, Init}; -pub use module::{ +pub use crate::backend::Backend; +pub use crate::data_context::{DataContext, DataDescription, Init}; +pub use crate::module::{ DataId, FuncId, FuncOrDataId, Linkage, Module, ModuleError, ModuleNamespace, ModuleResult, }; diff --git a/lib/module/src/module.rs b/lib/module/src/module.rs index e070514c8a..1d5a33130a 100644 --- a/lib/module/src/module.rs +++ b/lib/module/src/module.rs @@ -5,14 +5,16 @@ // TODO: Factor out `ir::Function`'s `ext_funcs` and `global_values` into a struct // shared with `DataContext`? -use cranelift_codegen::entity::PrimaryMap; +use crate::data_context::DataContext; +use crate::Backend; +use cranelift_codegen::entity::{entity_impl, PrimaryMap}; use cranelift_codegen::{binemit, ir, isa, CodegenError, Context}; -use data_context::DataContext; +use failure::Fail; +use log::info; use std::borrow::ToOwned; use std::collections::HashMap; use std::string::String; use std::vec::Vec; -use Backend; /// A function identifier for use in the `Module` interface. #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/lib/native/Cargo.toml b/lib/native/Cargo.toml index 20fc2911df..f73357d938 100644 --- a/lib/native/Cargo.toml +++ b/lib/native/Cargo.toml @@ -7,6 +7,7 @@ repository = "https://github.com/CraneStation/cranelift" categories = ["no-std"] license = "Apache-2.0 WITH LLVM-exception" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/native/src/lib.rs b/lib/native/src/lib.rs index c62322afe9..24650ca28c 100644 --- a/lib/native/src/lib.rs +++ b/lib/native/src/lib.rs @@ -28,11 +28,6 @@ )] #![cfg_attr(not(feature = "std"), no_std)] -extern crate cranelift_codegen; -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -extern crate raw_cpuid; -extern crate target_lexicon; - use cranelift_codegen::isa; use cranelift_codegen::settings::Configurable; use target_lexicon::Triple; diff --git a/lib/preopt/Cargo.toml b/lib/preopt/Cargo.toml index f9337faa74..08c492f2f0 100644 --- a/lib/preopt/Cargo.toml +++ b/lib/preopt/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/CraneStation/cranelift" categories = ["no-std"] readme = "README.md" keywords = ["optimize", "compile", "compiler", "jit"] +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/preopt/src/lib.rs b/lib/preopt/src/lib.rs index 9f307c4dfd..321b7a58b6 100644 --- a/lib/preopt/src/lib.rs +++ b/lib/preopt/src/lib.rs @@ -27,9 +27,6 @@ #[cfg(not(feature = "std"))] extern crate alloc; -extern crate cranelift_codegen; -// extern crate rustc_apfloat; - mod constant_folding; use cranelift_codegen::{isa::TargetIsa, settings::FlagsOrIsa, CodegenResult, Context}; diff --git a/lib/reader/Cargo.toml b/lib/reader/Cargo.toml index 8d4b70b975..c183e689b3 100644 --- a/lib/reader/Cargo.toml +++ b/lib/reader/Cargo.toml @@ -7,6 +7,7 @@ license = "Apache-2.0 WITH LLVM-exception" documentation = "https://cranelift.readthedocs.io/" repository = "https://github.com/CraneStation/cranelift" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0" } diff --git a/lib/reader/src/isaspec.rs b/lib/reader/src/isaspec.rs index 9132395162..6b58982c3a 100644 --- a/lib/reader/src/isaspec.rs +++ b/lib/reader/src/isaspec.rs @@ -6,10 +6,10 @@ //! 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 crate::error::{Location, ParseResult}; +use crate::testcommand::TestOption; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::settings::{Configurable, Flags, SetError}; -use error::{Location, ParseResult}; -use testcommand::TestOption; /// The ISA specifications in a `.clif` file. pub enum IsaSpec { diff --git a/lib/reader/src/lexer.rs b/lib/reader/src/lexer.rs index 1a77a1814e..8673b2b922 100644 --- a/lib/reader/src/lexer.rs +++ b/lib/reader/src/lexer.rs @@ -1,8 +1,8 @@ //! Lexical analysis for .clif files. +use crate::error::Location; use cranelift_codegen::ir::types; use cranelift_codegen::ir::{Ebb, Value}; -use error::Location; #[allow(unused_imports, deprecated)] use std::ascii::AsciiExt; use std::str::CharIndices; @@ -481,9 +481,9 @@ impl<'a> Lexer<'a> { mod tests { use super::trailing_digits; use super::*; + use crate::error::Location; use cranelift_codegen::ir::types; use cranelift_codegen::ir::{Ebb, Value}; - use error::Location; #[test] fn digits() { diff --git a/lib/reader/src/lib.rs b/lib/reader/src/lib.rs index ca79ea2099..d2e6a96e8b 100644 --- a/lib/reader/src/lib.rs +++ b/lib/reader/src/lib.rs @@ -29,15 +29,12 @@ ) )] -extern crate cranelift_codegen; -extern crate target_lexicon; - -pub use error::{Location, ParseError, ParseResult}; -pub use isaspec::{parse_options, IsaSpec}; -pub use parser::{parse_functions, parse_test}; -pub use sourcemap::SourceMap; -pub use testcommand::{TestCommand, TestOption}; -pub use testfile::{Comment, Details, TestFile}; +pub use crate::error::{Location, ParseError, ParseResult}; +pub use crate::isaspec::{parse_options, IsaSpec}; +pub use crate::parser::{parse_functions, parse_test}; +pub use crate::sourcemap::SourceMap; +pub use crate::testcommand::{TestCommand, TestOption}; +pub use crate::testfile::{Comment, Details, TestFile}; mod error; mod isaspec; diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 3bcac20aca..7503805bb6 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -1,5 +1,11 @@ //! Parser for .clif files. +use crate::error::{Location, ParseError, ParseResult}; +use crate::isaspec; +use crate::lexer::{LexError, Lexer, LocatedError, LocatedToken, Token}; +use crate::sourcemap::SourceMap; +use crate::testcommand::TestCommand; +use crate::testfile::{Comment, Details, TestFile}; use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir; use cranelift_codegen::ir::entities::AnyEntity; @@ -15,16 +21,10 @@ use cranelift_codegen::ir::{ use cranelift_codegen::isa::{self, CallConv, Encoding, RegUnit, TargetIsa}; use cranelift_codegen::packed_option::ReservedValue; use cranelift_codegen::{settings, timing}; -use error::{Location, ParseError, ParseResult}; -use isaspec; -use lexer::{LexError, Lexer, LocatedError, LocatedToken, Token}; -use sourcemap::SourceMap; use std::mem; use std::str::FromStr; use std::{u16, u32}; use target_lexicon::Triple; -use testcommand::TestCommand; -use testfile::{Comment, Details, TestFile}; /// Parse the entire `text` into a list of functions. /// @@ -793,7 +793,7 @@ impl<'a> Parser<'a> { Ok(triple) => triple, Err(err) => return err!(loc, err), }; - let mut isa_builder = match isa::lookup(triple) { + let isa_builder = match isa::lookup(triple) { Err(isa::LookupError::SupportDisabled) => { return err!(loc, "support disabled target '{}'", targ) } @@ -2571,14 +2571,14 @@ impl<'a> Parser<'a> { #[cfg(test)] mod tests { use super::*; + use crate::error::ParseError; + use crate::isaspec::IsaSpec; + use crate::testfile::{Comment, Details}; use cranelift_codegen::ir::entities::AnyEntity; use cranelift_codegen::ir::types; use cranelift_codegen::ir::StackSlotKind; use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose}; use cranelift_codegen::isa::CallConv; - use error::ParseError; - use isaspec::IsaSpec; - use testfile::{Comment, Details}; #[test] fn argument_type() { diff --git a/lib/reader/src/sourcemap.rs b/lib/reader/src/sourcemap.rs index f3f0423e43..a398dd5849 100644 --- a/lib/reader/src/sourcemap.rs +++ b/lib/reader/src/sourcemap.rs @@ -6,12 +6,12 @@ //! The `SourceMap` struct defined in this module makes this mapping available //! to parser clients. +use crate::error::{Location, ParseResult}; +use crate::lexer::split_entity_name; use cranelift_codegen::ir::entities::AnyEntity; use cranelift_codegen::ir::{ Ebb, FuncRef, GlobalValue, Heap, JumpTable, SigRef, StackSlot, Table, Value, }; -use error::{Location, ParseResult}; -use lexer::split_entity_name; use std::collections::HashMap; /// Mapping from entity names to source locations. @@ -211,7 +211,7 @@ impl SourceMap { #[cfg(test)] mod tests { - use parse_test; + use crate::parse_test; #[test] fn details() { diff --git a/lib/reader/src/testfile.rs b/lib/reader/src/testfile.rs index 685b7d99e6..506694586f 100644 --- a/lib/reader/src/testfile.rs +++ b/lib/reader/src/testfile.rs @@ -4,12 +4,12 @@ //! file-based test case. //! +use crate::error::Location; +use crate::isaspec::IsaSpec; +use crate::sourcemap::SourceMap; +use crate::testcommand::TestCommand; use cranelift_codegen::ir::entities::AnyEntity; use cranelift_codegen::ir::Function; -use error::Location; -use isaspec::IsaSpec; -use sourcemap::SourceMap; -use testcommand::TestCommand; /// A parsed test case. /// diff --git a/lib/serde/Cargo.toml b/lib/serde/Cargo.toml index 086cfbe5a5..a8a34e64b2 100644 --- a/lib/serde/Cargo.toml +++ b/lib/serde/Cargo.toml @@ -8,6 +8,7 @@ license = "Apache-2.0 WITH LLVM-exception" categories = ["no-std"] readme = "README.md" keywords = ["webassembly", "serde"] +edition = "2018" [[bin]] name = "clif-json" diff --git a/lib/serde/src/clif-json.rs b/lib/serde/src/clif-json.rs index f06a9e552b..fa25a723ed 100644 --- a/lib/serde/src/clif-json.rs +++ b/lib/serde/src/clif-json.rs @@ -25,13 +25,6 @@ ) )] -extern crate clap; -extern crate cranelift_reader; -extern crate serde_json; -#[macro_use] -extern crate serde_derive; -extern crate cranelift_codegen; - use clap::{App, Arg, SubCommand}; use cranelift_reader::parse_functions; use std::fs::File; diff --git a/lib/serde/src/serde_clif_json.rs b/lib/serde/src/serde_clif_json.rs index 536dda6a3b..f771fc7438 100644 --- a/lib/serde/src/serde_clif_json.rs +++ b/lib/serde/src/serde_clif_json.rs @@ -1,4 +1,5 @@ use cranelift_codegen::ir::{Ebb, Function, Inst, InstructionData, Signature}; +use serde_derive::{Deserialize, Serialize}; /// Serializable version of the original Cranelift IR #[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] diff --git a/lib/simplejit/Cargo.toml b/lib/simplejit/Cargo.toml index 9ddbed39e8..440c4072f1 100644 --- a/lib/simplejit/Cargo.toml +++ b/lib/simplejit/Cargo.toml @@ -8,6 +8,7 @@ documentation = "https://cranelift.readthedocs.io/" categories = ["no-std"] license = "Apache-2.0 WITH LLVM-exception" readme = "README.md" +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/simplejit/examples/simplejit-minimal.rs b/lib/simplejit/examples/simplejit-minimal.rs index 4e2d156bc8..eb1d3257ac 100644 --- a/lib/simplejit/examples/simplejit-minimal.rs +++ b/lib/simplejit/examples/simplejit-minimal.rs @@ -1,7 +1,3 @@ -extern crate cranelift; -extern crate cranelift_module; -extern crate cranelift_simplejit; - use cranelift::prelude::*; use cranelift_module::{Linkage, Module}; use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; diff --git a/lib/simplejit/src/backend.rs b/lib/simplejit/src/backend.rs index b105e70e3c..b7582c9c7b 100644 --- a/lib/simplejit/src/backend.rs +++ b/lib/simplejit/src/backend.rs @@ -1,5 +1,6 @@ //! Defines `SimpleJITBackend`. +use crate::memory::Memory; use cranelift_codegen::binemit::{Addend, CodeOffset, NullTrapSink, Reloc, RelocSink}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::{self, ir, settings}; @@ -8,7 +9,6 @@ use cranelift_module::{ }; use cranelift_native; use libc; -use memory::Memory; use std::collections::HashMap; use std::ffi::CString; use std::io::Write; diff --git a/lib/simplejit/src/lib.rs b/lib/simplejit/src/lib.rs index c1a44f672d..eabeb7ac0f 100644 --- a/lib/simplejit/src/lib.rs +++ b/lib/simplejit/src/lib.rs @@ -26,18 +26,7 @@ ) )] -extern crate cranelift_codegen; -extern crate cranelift_module; -extern crate cranelift_native; -extern crate errno; -extern crate libc; -extern crate region; -extern crate target_lexicon; - -#[cfg(target_os = "windows")] -extern crate winapi; - mod backend; mod memory; -pub use backend::{SimpleJITBackend, SimpleJITBuilder}; +pub use crate::backend::{SimpleJITBackend, SimpleJITBuilder}; diff --git a/lib/simplejit/tests/basic.rs b/lib/simplejit/tests/basic.rs index 9128ef6068..38da80c9a2 100644 --- a/lib/simplejit/tests/basic.rs +++ b/lib/simplejit/tests/basic.rs @@ -1,9 +1,3 @@ -extern crate cranelift_codegen; -extern crate cranelift_entity; -extern crate cranelift_frontend; -extern crate cranelift_module; -extern crate cranelift_simplejit; - use cranelift_codegen::ir::*; use cranelift_codegen::isa::CallConv; use cranelift_codegen::Context; diff --git a/lib/umbrella/Cargo.toml b/lib/umbrella/Cargo.toml index 1ca70dcac1..eb80082dd6 100644 --- a/lib/umbrella/Cargo.toml +++ b/lib/umbrella/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/CraneStation/cranelift" categories = ["no-std"] readme = "README.md" keywords = ["compile", "compiler", "jit"] +edition = "2018" [dependencies] cranelift-codegen = { path = "../codegen", version = "0.26.0", default-features = false } diff --git a/lib/umbrella/src/lib.rs b/lib/umbrella/src/lib.rs index b3aaa3e7ca..c14134e4f4 100644 --- a/lib/umbrella/src/lib.rs +++ b/lib/umbrella/src/lib.rs @@ -27,23 +27,23 @@ )] /// Provide these crates, renamed to reduce stutter. -pub extern crate cranelift_codegen as codegen; -pub extern crate cranelift_frontend as frontend; +pub use cranelift_codegen as codegen; +pub use cranelift_frontend as frontend; /// A prelude providing convenient access to commonly-used cranelift features. Use /// as `use cranelift::prelude::*`. pub mod prelude { - pub use codegen; - pub use codegen::entity::EntityRef; - pub use codegen::ir::condcodes::{FloatCC, IntCC}; - pub use codegen::ir::immediates::{Ieee32, Ieee64, Imm64, Uimm64}; - pub use codegen::ir::types; - pub use codegen::ir::{ + pub use crate::codegen; + pub use crate::codegen::entity::EntityRef; + pub use crate::codegen::ir::condcodes::{FloatCC, IntCC}; + pub use crate::codegen::ir::immediates::{Ieee32, Ieee64, Imm64, Uimm64}; + pub use crate::codegen::ir::types; + pub use crate::codegen::ir::{ AbiParam, Ebb, ExtFuncData, ExternalName, GlobalValueData, InstBuilder, JumpTableData, MemFlags, Signature, StackSlotData, StackSlotKind, TrapCode, Type, Value, }; - pub use codegen::isa; - pub use codegen::settings::{self, Configurable}; + pub use crate::codegen::isa; + pub use crate::codegen::settings::{self, Configurable}; - pub use frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; + pub use crate::frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; } diff --git a/lib/wasm/Cargo.toml b/lib/wasm/Cargo.toml index 64a4716981..71b4b2547e 100644 --- a/lib/wasm/Cargo.toml +++ b/lib/wasm/Cargo.toml @@ -8,6 +8,7 @@ license = "Apache-2.0 WITH LLVM-exception" categories = ["no-std", "wasm"] readme = "README.md" keywords = ["webassembly", "wasm"] +edition = "2018" [dependencies] wasmparser = { version = "0.23.0", default-features = false } diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index c7683d8dab..a7b61fc580 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -22,18 +22,18 @@ //! //! That is why `translate_function_body` takes an object having the `WasmRuntime` trait as //! argument. +use crate::environ::{FuncEnvironment, GlobalVariable, ReturnMode, WasmError, WasmResult}; +use crate::state::{ControlStackFrame, TranslationState}; +use crate::translation_utils::{f32_translation, f64_translation, num_return_values, type_to_type}; +use crate::translation_utils::{FuncIndex, MemoryIndex, SignatureIndex, TableIndex}; use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; use cranelift_codegen::ir::types::*; use cranelift_codegen::ir::{self, InstBuilder, JumpTableData, MemFlags}; use cranelift_codegen::packed_option::ReservedValue; use cranelift_frontend::{FunctionBuilder, Variable}; -use environ::{FuncEnvironment, GlobalVariable, ReturnMode, WasmError, WasmResult}; -use state::{ControlStackFrame, TranslationState}; use std::collections::{hash_map, HashMap}; use std::vec::Vec; use std::{i32, u32}; -use translation_utils::{f32_translation, f64_translation, num_return_values, type_to_type}; -use translation_utils::{FuncIndex, MemoryIndex, SignatureIndex, TableIndex}; use wasmparser::{MemoryImmediate, Operator}; // Clippy warns about "flags: _" but its important to document that the flags field is ignored diff --git a/lib/wasm/src/environ/dummy.rs b/lib/wasm/src/environ/dummy.rs index fc7db3af38..81212fa379 100644 --- a/lib/wasm/src/environ/dummy.rs +++ b/lib/wasm/src/environ/dummy.rs @@ -5,6 +5,12 @@ //! [wasmtime-environ]: https://crates.io/crates/wasmtime-environ //! [Wasmtime]: https://github.com/CraneStation/wasmtime +use crate::environ::{FuncEnvironment, GlobalVariable, ModuleEnvironment, ReturnMode, WasmResult}; +use crate::func_translator::FuncTranslator; +use crate::translation_utils::{ + DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, + TableIndex, +}; use cast; use cranelift_codegen::cursor::FuncCursor; use cranelift_codegen::ir::immediates::{Offset32, Uimm64}; @@ -12,14 +18,8 @@ use cranelift_codegen::ir::types::*; use cranelift_codegen::ir::{self, InstBuilder}; use cranelift_codegen::isa::TargetFrontendConfig; use cranelift_entity::{EntityRef, PrimaryMap}; -use environ::{FuncEnvironment, GlobalVariable, ModuleEnvironment, ReturnMode, WasmResult}; -use func_translator::FuncTranslator; use std::string::String; use std::vec::Vec; -use translation_utils::{ - DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, - TableIndex, -}; /// Compute a `ir::ExternalName` for a given wasm function index. fn get_func_name(func_index: FuncIndex) -> ir::ExternalName { diff --git a/lib/wasm/src/environ/mod.rs b/lib/wasm/src/environ/mod.rs index d44011fd8c..831fa0ef5e 100644 --- a/lib/wasm/src/environ/mod.rs +++ b/lib/wasm/src/environ/mod.rs @@ -3,7 +3,7 @@ mod dummy; mod spec; -pub use environ::dummy::DummyEnvironment; -pub use environ::spec::{ +pub use crate::environ::dummy::DummyEnvironment; +pub use crate::environ::spec::{ FuncEnvironment, GlobalVariable, ModuleEnvironment, ReturnMode, WasmError, WasmResult, }; diff --git a/lib/wasm/src/environ/spec.rs b/lib/wasm/src/environ/spec.rs index 9f3c2ba165..cfd943ed78 100644 --- a/lib/wasm/src/environ/spec.rs +++ b/lib/wasm/src/environ/spec.rs @@ -6,15 +6,16 @@ //! //! [Wasmtime]: https://github.com/CraneStation/wasmtime +use crate::translation_utils::{ + FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex, +}; use cranelift_codegen::cursor::FuncCursor; use cranelift_codegen::ir::immediates::Offset32; use cranelift_codegen::ir::{self, InstBuilder}; use cranelift_codegen::isa::TargetFrontendConfig; +use failure_derive::Fail; use std::convert::From; use std::vec::Vec; -use translation_utils::{ - FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table, TableIndex, -}; use wasmparser::BinaryReaderError; /// The value of a WebAssembly global variable. diff --git a/lib/wasm/src/func_translator.rs b/lib/wasm/src/func_translator.rs index 4b9e5fe7ca..7e5255499d 100644 --- a/lib/wasm/src/func_translator.rs +++ b/lib/wasm/src/func_translator.rs @@ -4,13 +4,14 @@ //! function to Cranelift IR guided by a `FuncEnvironment` which provides information about the //! WebAssembly module and the runtime environment. -use code_translator::translate_operator; +use crate::code_translator::translate_operator; +use crate::environ::{FuncEnvironment, ReturnMode, WasmResult}; +use crate::state::TranslationState; use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::{self, Ebb, InstBuilder}; use cranelift_codegen::timing; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; -use environ::{FuncEnvironment, ReturnMode, WasmResult}; -use state::TranslationState; +use log::info; use wasmparser::{self, BinaryReader}; /// WebAssembly to Cranelift IR function translator. @@ -231,9 +232,10 @@ fn cur_srcloc(reader: &BinaryReader) -> ir::SourceLoc { #[cfg(test)] mod tests { use super::{FuncTranslator, ReturnMode}; + use crate::environ::DummyEnvironment; use cranelift_codegen::ir::types::I32; use cranelift_codegen::{ir, isa, settings, Context}; - use environ::DummyEnvironment; + use log::debug; use target_lexicon::PointerWidth; #[test] diff --git a/lib/wasm/src/lib.rs b/lib/wasm/src/lib.rs index acd63bedb4..2b75ce9e4c 100644 --- a/lib/wasm/src/lib.rs +++ b/lib/wasm/src/lib.rs @@ -33,22 +33,6 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(alloc))] -extern crate cranelift_codegen; -#[macro_use] -extern crate cranelift_entity; -extern crate cast; -extern crate cranelift_frontend; -#[cfg(test)] -extern crate target_lexicon; -extern crate wasmparser; - -extern crate failure; -#[macro_use] -extern crate failure_derive; - -#[macro_use] -extern crate log; - mod code_translator; mod environ; mod func_translator; @@ -57,13 +41,13 @@ mod sections_translator; mod state; mod translation_utils; -pub use environ::{ +pub use crate::environ::{ DummyEnvironment, FuncEnvironment, GlobalVariable, ModuleEnvironment, ReturnMode, WasmError, WasmResult, }; -pub use func_translator::FuncTranslator; -pub use module_translator::translate_module; -pub use translation_utils::{ +pub use crate::func_translator::FuncTranslator; +pub use crate::module_translator::translate_module; +pub use crate::translation_utils::{ DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex, diff --git a/lib/wasm/src/module_translator.rs b/lib/wasm/src/module_translator.rs index 7a7ce91b9b..1cf0f4cd2d 100644 --- a/lib/wasm/src/module_translator.rs +++ b/lib/wasm/src/module_translator.rs @@ -1,12 +1,12 @@ //! Translation skeleton that traverses the whole WebAssembly module and call helper functions //! to deal with each part of it. -use cranelift_codegen::timing; -use environ::{ModuleEnvironment, WasmResult}; -use sections_translator::{ +use crate::environ::{ModuleEnvironment, WasmResult}; +use crate::sections_translator::{ parse_code_section, parse_data_section, parse_element_section, parse_export_section, parse_function_section, parse_global_section, parse_import_section, parse_memory_section, parse_start_section, parse_table_section, parse_type_section, }; +use cranelift_codegen::timing; use wasmparser::{ModuleReader, SectionCode}; /// Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cranelift IR diff --git a/lib/wasm/src/sections_translator.rs b/lib/wasm/src/sections_translator.rs index 4ea84d51f2..c1bdda1460 100644 --- a/lib/wasm/src/sections_translator.rs +++ b/lib/wasm/src/sections_translator.rs @@ -7,15 +7,15 @@ //! 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 cranelift_codegen::ir::{self, AbiParam, Signature}; -use cranelift_entity::EntityRef; -use environ::{ModuleEnvironment, WasmResult}; -use std::str::from_utf8; -use std::vec::Vec; -use translation_utils::{ +use crate::environ::{ModuleEnvironment, WasmResult}; +use crate::translation_utils::{ type_to_type, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, SignatureIndex, Table, TableElementType, TableIndex, }; +use cranelift_codegen::ir::{self, AbiParam, Signature}; +use cranelift_entity::EntityRef; +use std::str::from_utf8; +use std::vec::Vec; use wasmparser::{ self, CodeSectionReader, Data, DataSectionReader, Element, ElementSectionReader, Export, ExportSectionReader, ExternalKind, FuncType, FunctionSectionReader, GlobalSectionReader, diff --git a/lib/wasm/src/state.rs b/lib/wasm/src/state.rs index 02efc65ae3..80d1f5fe23 100644 --- a/lib/wasm/src/state.rs +++ b/lib/wasm/src/state.rs @@ -3,11 +3,11 @@ //! The `TranslationState` struct defined in this module is used to keep track of the WebAssembly //! value and control stacks during the translation of a single function. +use crate::environ::{FuncEnvironment, GlobalVariable}; +use crate::translation_utils::{FuncIndex, GlobalIndex, MemoryIndex, SignatureIndex, TableIndex}; use cranelift_codegen::ir::{self, Ebb, Inst, Value}; -use environ::{FuncEnvironment, GlobalVariable}; use std::collections::HashMap; use std::vec::Vec; -use translation_utils::{FuncIndex, GlobalIndex, MemoryIndex, SignatureIndex, TableIndex}; /// A control stack frame can be an `if`, a `block` or a `loop`, each one having the following /// fields: diff --git a/lib/wasm/src/translation_utils.rs b/lib/wasm/src/translation_utils.rs index 9dc8a2ffd6..cdfe276d46 100644 --- a/lib/wasm/src/translation_utils.rs +++ b/lib/wasm/src/translation_utils.rs @@ -1,4 +1,5 @@ //! Helper functions and structures for the translation. +use cranelift_codegen::entity::entity_impl; use cranelift_codegen::ir; use std::u32; use wasmparser; diff --git a/lib/wasm/tests/wasm_testsuite.rs b/lib/wasm/tests/wasm_testsuite.rs index 18b8c08c11..30428954bd 100644 --- a/lib/wasm/tests/wasm_testsuite.rs +++ b/lib/wasm/tests/wasm_testsuite.rs @@ -1,9 +1,3 @@ -extern crate cranelift_codegen; -extern crate cranelift_wasm; -#[macro_use] -extern crate target_lexicon; -extern crate wabt; - use cranelift_codegen::isa; use cranelift_codegen::print_errors::pretty_verifier_error; use cranelift_codegen::settings::{self, Flags}; @@ -15,6 +9,7 @@ use std::io; use std::io::prelude::*; use std::path::Path; use std::str::FromStr; +use target_lexicon::triple; use wabt::wat2wasm; #[test]