From 399cada762d5c2f8cdedb9efa8e7e7fb8059cd85 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Dec 2019 12:40:18 +0100 Subject: [PATCH] Directly depend on cranelift_{codegen,frontend} Fixes #838 --- Cargo.lock | 13 ++----------- Cargo.toml | 6 ++++-- src/abi/mod.rs | 2 ++ src/base.rs | 6 +++--- src/common.rs | 2 +- src/debuginfo/line_info.rs | 4 ++-- src/debuginfo/mod.rs | 10 +++++----- src/intrinsics/mod.rs | 4 ++-- src/lib.rs | 19 +++++++++++-------- src/pointer.rs | 2 +- src/pretty_clif.rs | 6 +++--- src/value_and_place.rs | 6 +++--- 12 files changed, 39 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3e359eac03..a8432a186f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,15 +63,6 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "cranelift" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" -dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", -] - [[package]] name = "cranelift-bforest" version = "0.52.0" @@ -408,8 +399,9 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -568,7 +560,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" diff --git a/Cargo.toml b/Cargo.toml index fc06285c566..efe56bffdca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ backend_object = ["object/write", "cranelift-object"] [dependencies] # These have to be in sync with each other -cranelift = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-faerie = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/", optional = true } @@ -35,7 +36,8 @@ features = ["compression", "read", "std"] # We don't need WASM support # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/cranelift/"] -#cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] } +#cranelift-codegen = { path = "../cranelift/cranelift-codegen", default-features = false, features = ["std"] } +#cranelift-frontend = { path = "../cranelift/cranelift-frontend", default-features = false, features = ["std"] } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 087cced93a3..9911f20655c 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -5,6 +5,8 @@ mod returning; use rustc_target::spec::abi::Abi; +use cranelift_codegen::ir::AbiParam; + use self::pass_mode::*; use crate::prelude::*; diff --git a/src/base.rs b/src/base.rs index 8bc5525160d..8cb3c2d150e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -103,11 +103,11 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { let flags = settings::Flags::new(settings::builder()); - match ::cranelift::codegen::verify_function(&func, &flags) { + match ::cranelift_codegen::verify_function(&func, &flags) { Ok(_) => {} Err(err) => { tcx.sess.err(&format!("{:?}", err)); - let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( + let pretty_error = ::cranelift_codegen::print_errors::pretty_verifier_error( &func, None, Some(Box::new(writer)), @@ -195,7 +195,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { targets, } => { let discr = trans_operand(fx, discr).load_scalar(fx); - let mut switch = ::cranelift::frontend::Switch::new(); + let mut switch = ::cranelift_frontend::Switch::new(); for (i, value) in values.iter().enumerate() { let ebb = fx.get_ebb(targets[i]); switch.set_entry(*value as u64, ebb); diff --git a/src/common.rs b/src/common.rs index d0c3385df6c..9506d4b5224 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,7 @@ use rustc::ty::layout::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift::codegen::ir::{InstructionData, Opcode, ValueDef}; +use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use crate::prelude::*; diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index e21b0b026c8..63acb3b4e8f 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -5,7 +5,7 @@ use crate::prelude::*; use syntax::source_map::FileName; -use cranelift::codegen::binemit::CodeOffset; +use cranelift_codegen::binemit::CodeOffset; use gimli::write::{ Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, UnitEntryId, @@ -104,7 +104,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub(crate) fn create_debug_lines( &mut self, context: &Context, - isa: &dyn cranelift::codegen::isa::TargetIsa, + isa: &dyn cranelift_codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) -> CodeOffset { let tcx = self.debug_context.tcx; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2e40e7c4cad..3d4e200f00c 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -3,9 +3,9 @@ mod line_info; use crate::prelude::*; -use cranelift::codegen::ir::{StackSlots, ValueLabel, ValueLoc}; -use cranelift::codegen::isa::RegUnit; -use cranelift::codegen::ValueLocRange; +use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; +use cranelift_codegen::isa::RegUnit; +use cranelift_codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, @@ -253,7 +253,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn define( &mut self, context: &Context, - isa: &dyn cranelift::codegen::isa::TargetIsa, + isa: &dyn cranelift_codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, local_map: HashMap>, ) { @@ -312,7 +312,7 @@ fn place_location<'a, 'tcx>( match cplace.inner() { CPlaceInner::Var(local) => { - let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32()); + let value_label = cranelift_codegen::ir::ValueLabel::from_u32(local.as_u32()); if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { let loc_list = LocationList( value_loc_ranges diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index ca10399cb9c..2e1584e3efa 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -633,7 +633,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } _ => { @@ -670,7 +670,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } CPlaceInner::Addr(_, _) => { diff --git a/src/lib.rs b/src/lib.rs index 7d67de73ae2..9337d07ffc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ use rustc::ty::query::Providers; use rustc::util::common::ErrorReported; use rustc_codegen_utils::codegen_backend::CodegenBackend; -use cranelift::codegen::settings; +use cranelift_codegen::settings; use crate::constant::ConstantCx; use crate::prelude::*; @@ -91,12 +91,15 @@ mod prelude { pub use rustc_codegen_ssa::traits::*; pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; - pub use cranelift::codegen::ir::{ - condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, SourceLoc, StackSlot, - }; - pub use cranelift::codegen::isa::CallConv; - pub use cranelift::codegen::Context; - pub use cranelift::prelude::*; + pub use cranelift_codegen::Context; + pub use cranelift_codegen::ir::{AbiParam, Ebb, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; + pub use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; + pub use cranelift_codegen::ir::function::Function; + pub use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; + pub use cranelift_codegen::ir::types; + pub use cranelift_codegen::isa::{self, CallConv}; + pub use cranelift_codegen::settings::{self, Configurable}; + pub use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; pub use cranelift_module::{ self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, Module, }; @@ -283,7 +286,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box( ); let mut clif = String::new(); - cranelift::codegen::write::decorate_function( + cranelift_codegen::write::decorate_function( &mut clif_comments, &mut clif, &func, @@ -255,7 +255,7 @@ impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> { writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); - ::cranelift::codegen::write::decorate_function( + ::cranelift_codegen::write::decorate_function( &mut &self.clif_comments, &mut clif, &self.bcx.func, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index b1e96d2ce2c..df59fb8302c 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use cranelift::codegen::ir::immediates::Offset32; +use cranelift_codegen::ir::immediates::Offset32; fn codegen_field<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, @@ -308,7 +308,7 @@ impl<'tcx> CPlace<'tcx> { match self.inner { CPlaceInner::Var(var) => { let val = fx.bcx.use_var(mir_var(var)); - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); CValue::by_val(val, layout) } CPlaceInner::Addr(ptr, extra) => { @@ -415,7 +415,7 @@ impl<'tcx> CPlace<'tcx> { let to_ptr = match self.inner { CPlaceInner::Var(var) => { let data = from.load_scalar(fx); - fx.bcx.set_val_label(data, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), data); return; }