Skip to content

Commit

Permalink
cond synth: we now distinguish between sign and width in the egg AST
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Dec 19, 2024
1 parent bc308f1 commit 8823f4a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tools/egraphs-cond-synth/src/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ fn analyze_pattern(pat: &PatternAst<Arith>) -> RuleInfo {
fn symbol_from_pattern(pat: &PatternAst<Arith>, a: Id, w: Id, s: Id) -> Option<RuleSymbol> {
if let ENodeOrVar::Var(var) = pat[a] {
let width = width_const_from_pattern(pat, w);
let sign = width_const_from_pattern(pat, s);
let sign = sign_const_from_pattern(pat, s);
Some(RuleSymbol { var, width, sign })
} else {
None
Expand All @@ -487,7 +487,17 @@ fn width_const_from_pattern(pat: &PatternAst<Arith>, id: Id) -> VarOrConst {
match &pat[id] {
ENodeOrVar::ENode(node) => match node {
&Arith::Width(w) => VarOrConst::C(w.into()),
_ => unreachable!("not a width!"),
other => unreachable!("`{other:?}` is not a width!"),
},
ENodeOrVar::Var(var) => VarOrConst::V(*var),
}
}

fn sign_const_from_pattern(pat: &PatternAst<Arith>, id: Id) -> VarOrConst {
match &pat[id] {
ENodeOrVar::ENode(node) => match node {
&Arith::Sign(s) => VarOrConst::C(s.into()),
other => unreachable!("`{other:?}` is not a width!"),
},
ENodeOrVar::Var(var) => VarOrConst::V(*var),
}
Expand Down

0 comments on commit 8823f4a

Please sign in to comment.