diff --git a/cranelift/README.md b/cranelift/README.md index b84e89bad1..b304a97891 100644 --- a/cranelift/README.md +++ b/cranelift/README.md @@ -79,6 +79,7 @@ Building with no\_std The following crates support \`no\_std\`: - cranelift-entity + - cranelift-bforest - cranelift-codegen - cranelift-frontend - cranelift-native diff --git a/cranelift/publish-all.sh b/cranelift/publish-all.sh index 67311f5f6f..089e7f27cb 100755 --- a/cranelift/publish-all.sh +++ b/cranelift/publish-all.sh @@ -36,7 +36,7 @@ cargo update echo git commit -a -m "\"Bump version to $version"\" echo git push for crate in \ - entity codegen/meta codegen frontend native \ + entity bforest codegen/meta codegen frontend native \ reader wasm module simplejit \ faerie umbrella do diff --git a/lib/bforest/Cargo.toml b/lib/bforest/Cargo.toml new file mode 100644 index 0000000000..4b1d1d076c --- /dev/null +++ b/lib/bforest/Cargo.toml @@ -0,0 +1,21 @@ +[package] +authors = ["The Cranelift Project Developers"] +name = "cranelift-bforest" +version = "0.18.1" +description = "A forest of B+-trees" +license = "Apache-2.0" +documentation = "https://cranelift.readthedocs.io/" +repository = "https://github.com/CraneStation/cranelift" +readme = "README.md" +keywords = ["btree", "forest", "set", "map"] + +[dependencies] +cranelift-entity = { path = "../entity", version = "0.18.1", default-features = false } + +[features] +default = ["std"] +std = ["cranelift-entity/std"] + +[badges] +maintenance = { status = "experimental" } +travis-ci = { repository = "CraneStation/cranelift" } diff --git a/lib/bforest/README.md b/lib/bforest/README.md new file mode 100644 index 0000000000..718a4ed8fe --- /dev/null +++ b/lib/bforest/README.md @@ -0,0 +1,2 @@ +This crate contains array-based data structures used by the core Cranelift code +generator which represent a set of small ordered sets or maps. diff --git a/lib/codegen/src/bforest/mod.rs b/lib/bforest/src/lib.rs similarity index 79% rename from lib/codegen/src/bforest/mod.rs rename to lib/bforest/src/lib.rs index bc22cf88c0..1bddcd8a73 100644 --- a/lib/codegen/src/bforest/mod.rs +++ b/lib/bforest/src/lib.rs @@ -1,6 +1,6 @@ //! A forest of B+-trees. //! -//! This module provides a data structures representing a set of small ordered sets or maps. +//! This crate provides a data structures representing a set of small ordered sets or maps. //! It is implemented as a forest of B+-trees all allocating nodes out of the same pool. //! //! **These are not general purpose data structures that are somehow magically faster that the @@ -13,6 +13,34 @@ //! - Empty trees have a very small 32-bit footprint. //! - All the trees in a forest can be cleared in constant time. +#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] +#![warn(unused_import_braces)] +#![cfg_attr(feature = "std", warn(unstable_features))] +#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] +#![cfg_attr(feature = "cargo-clippy", allow(new_without_default, new_without_default_derive))] +#![cfg_attr( + feature = "cargo-clippy", + warn( + float_arithmetic, mut_mut, nonminimal_bool, option_map_unwrap_or, option_map_unwrap_or_else, + print_stdout, unicode_not_nfc, use_self + ) +)] +// Turns on no_std and alloc features if std is not available. +#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(feature = "std"), feature(alloc))] + +/// This replaces `std` in builds with `core`. +#[cfg(not(feature = "std"))] +mod std { + extern crate alloc; + pub use self::alloc::{boxed, string, vec}; + pub use core::*; +} + +#[macro_use] +extern crate cranelift_entity as entity; +use entity::packed_option; + use std::borrow::BorrowMut; use std::cmp::Ordering; @@ -124,7 +152,11 @@ fn slice_shift(s: &mut [T], n: usize) { mod test { use super::*; use entity::EntityRef; - use ir::Ebb; + + /// An opaque reference to an extended basic block in a function. + #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] + pub struct Ebb(u32); + entity_impl!(Ebb, "ebb"); #[test] fn comparator() { diff --git a/lib/codegen/src/bforest/map.rs b/lib/bforest/src/map.rs similarity index 100% rename from lib/codegen/src/bforest/map.rs rename to lib/bforest/src/map.rs diff --git a/lib/codegen/src/bforest/node.rs b/lib/bforest/src/node.rs similarity index 100% rename from lib/codegen/src/bforest/node.rs rename to lib/bforest/src/node.rs diff --git a/lib/codegen/src/bforest/path.rs b/lib/bforest/src/path.rs similarity index 100% rename from lib/codegen/src/bforest/path.rs rename to lib/bforest/src/path.rs diff --git a/lib/codegen/src/bforest/pool.rs b/lib/bforest/src/pool.rs similarity index 100% rename from lib/codegen/src/bforest/pool.rs rename to lib/bforest/src/pool.rs diff --git a/lib/codegen/src/bforest/set.rs b/lib/bforest/src/set.rs similarity index 100% rename from lib/codegen/src/bforest/set.rs rename to lib/bforest/src/set.rs diff --git a/lib/codegen/Cargo.toml b/lib/codegen/Cargo.toml index bb767dd67f..5bddad6418 100644 --- a/lib/codegen/Cargo.toml +++ b/lib/codegen/Cargo.toml @@ -12,6 +12,7 @@ build = "build.rs" [dependencies] cranelift-entity = { path = "../entity", version = "0.18.1", default-features = false } +cranelift-bforest = { path = "../bforest", version = "0.18.1", default-features = false } failure = { version = "0.1.1", default-features = false, features = ["derive"] } failure_derive = { version = "0.1.1", default-features = false } hashmap_core = { version = "0.1.9", optional = true } @@ -29,7 +30,7 @@ cranelift-codegen-meta = { path = "meta", version = "0.18.1" } # of some minimal std-like replacement libraries. At least one of these two # features need to be enabled. default = ["std"] -std = ["cranelift-entity/std", "target-lexicon/std"] +std = ["cranelift-entity/std", "cranelift-bforest/std", "target-lexicon/std"] core = ["hashmap_core"] [badges] diff --git a/lib/codegen/src/lib.rs b/lib/codegen/src/lib.rs index 5d24ddf709..23959e67ac 100644 --- a/lib/codegen/src/lib.rs +++ b/lib/codegen/src/lib.rs @@ -60,10 +60,11 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION"); #[macro_use] pub extern crate cranelift_entity as entity; +pub extern crate cranelift_bforest as bforest; + #[macro_use] pub mod dbg; -pub mod bforest; pub mod binemit; pub mod cfg_printer; pub mod cursor;