You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now we have some tests for SSA, but they have this form:
// fn main f0 {// b0(v0: u16):// v1 = cast v0 as u32// v2 = cast v0 as u32// constrain v1 v2// }//// After constructing this IR, we run constant folding which should replace the second cast// with a reference to the results to the first. This then allows us to optimize away// the constrain instruction as both inputs are known to be equal.//// The first cast instruction is retained and will be removed in the dead instruction elimination pass.let main_id = Id::test_new(0);// Compiling mainletmut builder = FunctionBuilder::new("main".into(), main_id);let v0 = builder.add_parameter(Type::unsigned(16));let v1 = builder.insert_cast(v0,Type::unsigned(32));let v2 = builder.insert_cast(v0,Type::unsigned(32));
builder.insert_constrain(v1, v2,None);letmut ssa = builder.finish();let main = ssa.main_mut();let instructions = main.dfg[main.entry_block()].instructions();assert_eq!(instructions.len(),3);
Essentially, we have a comment for the SSA function we are testing, then code that programmatically creates this.
This works, but:
it's a slow process, or at least slower than being able to translate the comment to the SSA code
the code that generates the code could potentially be not generating the code it's supposed to generate, or the two could fall out of sync (or we might need to maintain both so that they are in sync)
So, we could introduce some way to go from SSA code into an Ssa object:
let src = " fn main f0 { b0(v0: u16): v1 = cast v0 as u32 v2 = cast v0 as u32 constrain v1 v2 } ";let ssa = Ssa::from_str(src).unwrap();
Happy Case
There's a way to go from SSA source code to an Ssa object.
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered:
Problem
Right now we have some tests for SSA, but they have this form:
Essentially, we have a comment for the SSA function we are testing, then code that programmatically creates this.
This works, but:
So, we could introduce some way to go from SSA code into an
Ssa
object:Happy Case
There's a way to go from SSA source code to an
Ssa
object.Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: