@@ -40,15 +40,25 @@ pub struct ReturnInfosToCopy<'a> {
40
40
pub dest : & ' a ReturnInfo ,
41
41
}
42
42
43
- /// Indicates whether a Wasm input is a constant, and if so, its value.
43
+ /// Indicates whether the input for a Wasm node is a constant, and if so, its value.
44
44
///
45
- /// The `must_collapse` cell can be mutated to indicate that the constant
46
- /// should be collapsed into the instruction, if the ISA supports it.
45
+ /// This is part of the interface for constant collapsing optimization.
47
46
pub enum MaybeConstant {
47
+ /// The corresponding input is a reference to a non-constant node,
48
+ /// and we don't know the value at compile time.
48
49
NonConstant ,
50
+ /// The corresponding input is a constant already set to be collapsed into the instruction.
51
+ /// Can not happen in the default Womir pipeline, as the constant collapsing optimization
52
+ /// pass is executed only once. This is defined for completeness.
49
53
CollapsedConstant ( WasmValue ) ,
54
+ /// The corresponding input is a reference to a constant node,
55
+ /// and we know its value at compile time. The user may choose to collapse
56
+ /// the value into the node, severing the dependency on the constant node.
50
57
ReferenceConstant {
51
58
value : WasmValue ,
59
+ /// This Cell value can be mutated to true indicate that the constant
60
+ /// should be collapsed into the instruction, and the ISA supports it.
61
+ /// Initially false.
52
62
must_collapse : Cell < bool > ,
53
63
} ,
54
64
}
@@ -83,7 +93,8 @@ pub trait Settings<'a> {
83
93
/// This can be used for ISAs that support immediate operands on
84
94
/// certain instructions.
85
95
///
86
- /// Default implementation returns None, meaning no constant collapsing.
96
+ /// Default implementation returns None, meaning no constant collapsing
97
+ /// is performed.
87
98
fn get_const_collapse_processor ( & self ) -> Option < impl Fn ( & Op , & [ MaybeConstant ] ) > {
88
99
None :: < fn ( & Op , & [ MaybeConstant ] ) >
89
100
}
0 commit comments