Skip to content

Commit fdfde4c

Browse files
committed
Moved bitset size into ruby generated script
1 parent 8e962ea commit fdfde4c

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

zjit/src/hir_effect/gen_hir_effect.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def add_union name, effect_names
137137
puts " pub const NumEffectBits: #{$int_label} = #{num_bits};
138138
}"
139139

140+
puts "pub mod effect_types {"
141+
puts " pub type EffectBits = #{$int_label};"
142+
puts "}"
143+
140144
puts "pub mod effect_sets {
141145
use super::*;"
142146
$bits.keys.sort.map {|effect_name|

zjit/src/hir_effect/hir_effect.inc.rs

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/hir_effect/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
33
#![allow(non_upper_case_globals)]
44
use crate::hir::{PtrPrintMap};
5-
6-
// We use a type alias for the width of our Effect bitset.
7-
// This width should reflect hir_effect.inc.rs.
8-
type EffectBits = u8;
5+
include!("hir_effect.inc.rs");
96

107
// NOTE: Effect very intentionally does not support Eq or PartialEq; we almost never want to check
118
// bit equality of types in the compiler but instead check subtyping, intersection, union, etc.
@@ -25,7 +22,7 @@ type EffectBits = u8;
2522
/// system. This explicit design with a lattice allows us many bits for effects.
2623
#[derive(Clone, Copy, Debug)]
2724
pub struct EffectSet {
28-
bits: EffectBits
25+
bits: effect_types::EffectBits
2926
}
3027

3128
#[derive(Clone, Copy, Debug)]
@@ -45,9 +42,6 @@ pub struct Effect {
4542
write: EffectSet
4643
}
4744

48-
include!("hir_effect.inc.rs");
49-
50-
5145
/// Print adaptor for [`EffectSet`]. See [`PtrPrintMap`].
5246
pub struct EffectSetPrinter<'a> {
5347
inner: EffectSet,
@@ -104,7 +98,7 @@ impl std::fmt::Display for Effect {
10498
}
10599

106100
impl EffectSet {
107-
const fn from_bits(bits: EffectBits) -> Self {
101+
const fn from_bits(bits: effect_types::EffectBits) -> Self {
108102
Self { bits }
109103
}
110104

0 commit comments

Comments
 (0)