Share constants between codegen and the meta crate;
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use cranelift_codegen_shared::constants;
|
||||
use cranelift_entity::{entity_impl, EntityRef, PrimaryMap};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
@@ -364,19 +365,21 @@ impl IsaRegsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// This limit should be coordinated with the `RegClassMask` and `RegClassIndex` types in
|
||||
// isa/registers.rs of the non-meta code.
|
||||
assert!(self.classes.len() <= 32, "Too many register classes");
|
||||
assert!(
|
||||
self.classes.len() <= constants::MAX_NUM_REG_CLASSES,
|
||||
"Too many register classes"
|
||||
);
|
||||
|
||||
// The maximum number of top-level register classes which have pressure tracking should be
|
||||
// kept in sync with the MAX_TRACKED_TOPRCS constant in isa/registers.rs of the non-meta
|
||||
// code.
|
||||
let num_toplevel = self
|
||||
.classes
|
||||
.values()
|
||||
.filter(|x| x.toprc == x.index && self.banks.get(x.bank).unwrap().pressure_tracking)
|
||||
.count();
|
||||
assert!(num_toplevel <= 4, "Too many top-level register classes");
|
||||
|
||||
assert!(
|
||||
num_toplevel <= constants::MAX_TRACKED_TOP_RCS,
|
||||
"Too many top-level register classes"
|
||||
);
|
||||
|
||||
IsaRegs::new(self.banks, self.classes)
|
||||
}
|
||||
|
||||
@@ -1,24 +1,9 @@
|
||||
//! Cranelift ValueType hierarchy
|
||||
|
||||
// Temporary disabled: Unused at the moment.
|
||||
// use std::collections::HashMap;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::shared::types as shared_types;
|
||||
|
||||
// Numbering scheme for value types:
|
||||
//
|
||||
// 0: Void
|
||||
// 0x01-0x6f: Special types
|
||||
// 0x70-0x7d: Lane types
|
||||
// 0x7e-0x7f: Reference types
|
||||
// 0x80-0xff: Vector types
|
||||
//
|
||||
// Vector types are encoded with the lane type in the low 4 bits and log2(lanes)
|
||||
// in the high 4 bits, giving a range of 2-256 lanes.
|
||||
static LANE_BASE: u8 = 0x70;
|
||||
static REFERENCE_BASE: u8 = 0x7E;
|
||||
use cranelift_codegen_shared::constants;
|
||||
|
||||
// Rust name prefix used for the `rust_name` method.
|
||||
static _RUST_NAME_PREFIX: &'static str = "ir::types::";
|
||||
@@ -208,7 +193,7 @@ impl LaneType {
|
||||
|
||||
/// Find the unique number associated with this lane type.
|
||||
pub fn number(self) -> u8 {
|
||||
LANE_BASE
|
||||
constants::LANE_BASE
|
||||
+ match self {
|
||||
LaneType::BoolType(shared_types::Bool::B1) => 0,
|
||||
LaneType::BoolType(shared_types::Bool::B8) => 1,
|
||||
@@ -579,7 +564,7 @@ impl ReferenceType {
|
||||
|
||||
/// Find the unique number associated with this reference type.
|
||||
pub fn number(self) -> u8 {
|
||||
REFERENCE_BASE
|
||||
constants::REFERENCE_BASE
|
||||
+ match self {
|
||||
ReferenceType(shared_types::Reference::R32) => 0,
|
||||
ReferenceType(shared_types::Reference::R64) => 1,
|
||||
|
||||
Reference in New Issue
Block a user