Skip to content

Commit d6e2331

Browse files
committed
Improved comments.
1 parent 41e9ae9 commit d6e2331

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/loader/settings.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,25 @@ pub struct ReturnInfosToCopy<'a> {
4040
pub dest: &'a ReturnInfo,
4141
}
4242

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.
4444
///
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.
4746
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.
4849
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.
4953
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.
5057
ReferenceConstant {
5158
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.
5262
must_collapse: Cell<bool>,
5363
},
5464
}
@@ -83,7 +93,8 @@ pub trait Settings<'a> {
8393
/// This can be used for ISAs that support immediate operands on
8494
/// certain instructions.
8595
///
86-
/// Default implementation returns None, meaning no constant collapsing.
96+
/// Default implementation returns None, meaning no constant collapsing
97+
/// is performed.
8798
fn get_const_collapse_processor(&self) -> Option<impl Fn(&Op, &[MaybeConstant])> {
8899
None::<fn(&Op, &[MaybeConstant])>
89100
}

0 commit comments

Comments
 (0)