diff --git a/cranelift/codegen/meta/src/base/mod.rs b/cranelift/codegen/meta/src/base/mod.rs deleted file mode 100644 index 1d596a1306..0000000000 --- a/cranelift/codegen/meta/src/base/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Definitions for the base Cranelift language. - -pub mod settings; -pub mod types; diff --git a/cranelift/codegen/meta/src/cdsl/types.rs b/cranelift/codegen/meta/src/cdsl/types.rs index a4e6443e47..898c048b8b 100644 --- a/cranelift/codegen/meta/src/cdsl/types.rs +++ b/cranelift/codegen/meta/src/cdsl/types.rs @@ -5,7 +5,7 @@ use std::fmt; -use crate::base::types as base_types; +use crate::shared::types as shared_types; // Numbering scheme for value types: // @@ -149,9 +149,9 @@ impl From for ValueType { /// A concrete scalar type that can appear as a vector lane too. #[derive(Clone, Copy)] pub enum LaneType { - BoolType(base_types::Bool), - FloatType(base_types::Float), - IntType(base_types::Int), + BoolType(shared_types::Bool), + FloatType(shared_types::Float), + IntType(shared_types::Int), } impl LaneType { @@ -159,12 +159,12 @@ impl LaneType { pub fn doc(self) -> String { match self { LaneType::BoolType(_) => format!("A boolean type with {} bits.", self.lane_bits()), - LaneType::FloatType(base_types::Float::F32) => String::from( + LaneType::FloatType(shared_types::Float::F32) => String::from( "A 32-bit floating point type represented in the IEEE 754-2008 *binary32* interchange format. This corresponds to the :c:type:`float` type in most C implementations.", ), - LaneType::FloatType(base_types::Float::F64) => String::from( + LaneType::FloatType(shared_types::Float::F64) => String::from( "A 64-bit floating point type represented in the IEEE 754-2008 *binary64* interchange format. This corresponds to the :c:type:`double` type in most C implementations.", @@ -192,17 +192,17 @@ impl LaneType { pub fn number(self) -> u8 { LANE_BASE + match self { - LaneType::BoolType(base_types::Bool::B1) => 0, - LaneType::BoolType(base_types::Bool::B8) => 1, - LaneType::BoolType(base_types::Bool::B16) => 2, - LaneType::BoolType(base_types::Bool::B32) => 3, - LaneType::BoolType(base_types::Bool::B64) => 4, - LaneType::IntType(base_types::Int::I8) => 5, - LaneType::IntType(base_types::Int::I16) => 6, - LaneType::IntType(base_types::Int::I32) => 7, - LaneType::IntType(base_types::Int::I64) => 8, - LaneType::FloatType(base_types::Float::F32) => 9, - LaneType::FloatType(base_types::Float::F64) => 10, + LaneType::BoolType(shared_types::Bool::B1) => 0, + LaneType::BoolType(shared_types::Bool::B8) => 1, + LaneType::BoolType(shared_types::Bool::B16) => 2, + LaneType::BoolType(shared_types::Bool::B32) => 3, + LaneType::BoolType(shared_types::Bool::B64) => 4, + LaneType::IntType(shared_types::Int::I8) => 5, + LaneType::IntType(shared_types::Int::I16) => 6, + LaneType::IntType(shared_types::Int::I32) => 7, + LaneType::IntType(shared_types::Int::I64) => 8, + LaneType::FloatType(shared_types::Float::F32) => 9, + LaneType::FloatType(shared_types::Float::F64) => 10, } } } @@ -233,40 +233,40 @@ impl fmt::Debug for LaneType { } /// Create a LaneType from a given bool variant. -impl From for LaneType { - fn from(b: base_types::Bool) -> Self { +impl From for LaneType { + fn from(b: shared_types::Bool) -> Self { LaneType::BoolType(b) } } /// Create a LaneType from a given float variant. -impl From for LaneType { - fn from(f: base_types::Float) -> Self { +impl From for LaneType { + fn from(f: shared_types::Float) -> Self { LaneType::FloatType(f) } } /// Create a LaneType from a given int variant. -impl From for LaneType { - fn from(i: base_types::Int) -> Self { +impl From for LaneType { + fn from(i: shared_types::Int) -> Self { LaneType::IntType(i) } } /// An iterator for different lane types. pub struct LaneTypeIterator { - bool_iter: base_types::BoolIterator, - int_iter: base_types::IntIterator, - float_iter: base_types::FloatIterator, + bool_iter: shared_types::BoolIterator, + int_iter: shared_types::IntIterator, + float_iter: shared_types::FloatIterator, } impl LaneTypeIterator { /// Create a new lane type iterator. fn new() -> Self { Self { - bool_iter: base_types::BoolIterator::new(), - int_iter: base_types::IntIterator::new(), - float_iter: base_types::FloatIterator::new(), + bool_iter: shared_types::BoolIterator::new(), + int_iter: shared_types::IntIterator::new(), + float_iter: shared_types::FloatIterator::new(), } } } @@ -388,18 +388,18 @@ impl fmt::Debug for BVType { /// Special types cannot be used to form vectors. #[derive(Clone, Copy)] pub enum SpecialType { - Flag(base_types::Flag), + Flag(shared_types::Flag), } impl SpecialType { /// Return a string containing the documentation comment for this special type. pub fn doc(self) -> String { match self { - SpecialType::Flag(base_types::Flag::IFlags) => String::from( + SpecialType::Flag(shared_types::Flag::IFlags) => String::from( "CPU flags representing the result of an integer comparison. These flags can be tested with an :type:`intcc` condition code.", ), - SpecialType::Flag(base_types::Flag::FFlags) => String::from( + SpecialType::Flag(shared_types::Flag::FFlags) => String::from( "CPU flags representing the result of a floating point comparison. These flags can be tested with a :type:`floatcc` condition code.", ), @@ -416,8 +416,8 @@ impl SpecialType { /// Find the unique number associated with this special type. pub fn number(self) -> u8 { match self { - SpecialType::Flag(base_types::Flag::IFlags) => 1, - SpecialType::Flag(base_types::Flag::FFlags) => 2, + SpecialType::Flag(shared_types::Flag::IFlags) => 1, + SpecialType::Flag(shared_types::Flag::FFlags) => 2, } } } @@ -425,8 +425,8 @@ impl SpecialType { impl fmt::Display for SpecialType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - SpecialType::Flag(base_types::Flag::IFlags) => write!(f, "iflags"), - SpecialType::Flag(base_types::Flag::FFlags) => write!(f, "fflags"), + SpecialType::Flag(shared_types::Flag::IFlags) => write!(f, "iflags"), + SpecialType::Flag(shared_types::Flag::FFlags) => write!(f, "fflags"), } } } @@ -443,20 +443,20 @@ impl fmt::Debug for SpecialType { } } -impl From for SpecialType { - fn from(f: base_types::Flag) -> Self { +impl From for SpecialType { + fn from(f: shared_types::Flag) -> Self { SpecialType::Flag(f) } } pub struct SpecialTypeIterator { - flag_iter: base_types::FlagIterator, + flag_iter: shared_types::FlagIterator, } impl SpecialTypeIterator { fn new() -> Self { Self { - flag_iter: base_types::FlagIterator::new(), + flag_iter: shared_types::FlagIterator::new(), } } } diff --git a/cranelift/codegen/meta/src/gen_settings.rs b/cranelift/codegen/meta/src/gen_settings.rs index bdcd206e13..99b9f52689 100644 --- a/cranelift/codegen/meta/src/gen_settings.rs +++ b/cranelift/codegen/meta/src/gen_settings.rs @@ -1,4 +1,3 @@ -use crate::base; use crate::cdsl::camel_case; use crate::cdsl::isa::TargetIsa; use crate::cdsl::settings::{ @@ -6,6 +5,7 @@ use crate::cdsl::settings::{ }; use crate::constant_hash::{generate_table, simple_hash}; use crate::error; +use crate::shared; use crate::srcgen::{Formatter, Match}; use crate::unique_table::UniqueTable; use std::collections::HashMap; @@ -433,7 +433,7 @@ fn gen_group(group: &SettingGroup, parent: ParentGroup, fmt: &mut Formatter) { } pub fn generate_common(filename: &str, out_dir: &str) -> Result { - let settings = base::settings::generate(); + let settings = shared::settings::generate(); let mut fmt = Formatter::new(); gen_group(&settings, ParentGroup::None, &mut fmt); fmt.update_file(filename, out_dir)?; diff --git a/cranelift/codegen/meta/src/lib.rs b/cranelift/codegen/meta/src/lib.rs index f7f15b8d09..610f2cd4a2 100644 --- a/cranelift/codegen/meta/src/lib.rs +++ b/cranelift/codegen/meta/src/lib.rs @@ -8,8 +8,8 @@ mod gen_registers; mod gen_settings; mod gen_types; -mod base; mod constant_hash; +mod shared; mod srcgen; mod unique_table; diff --git a/cranelift/codegen/meta/src/shared/mod.rs b/cranelift/codegen/meta/src/shared/mod.rs new file mode 100644 index 0000000000..bdd9a14f2c --- /dev/null +++ b/cranelift/codegen/meta/src/shared/mod.rs @@ -0,0 +1,4 @@ +//! Shared definitions for the Cranelift intermediate language. + +pub mod settings; +pub mod types; diff --git a/cranelift/codegen/meta/src/base/settings.rs b/cranelift/codegen/meta/src/shared/settings.rs similarity index 100% rename from cranelift/codegen/meta/src/base/settings.rs rename to cranelift/codegen/meta/src/shared/settings.rs diff --git a/cranelift/codegen/meta/src/base/types.rs b/cranelift/codegen/meta/src/shared/types.rs similarity index 100% rename from cranelift/codegen/meta/src/base/types.rs rename to cranelift/codegen/meta/src/shared/types.rs