Skip to content

Commit 3b4db1d

Browse files
authored
Improve wasmi_ir2 operators field layouts (#1670)
* change cmp+select operator fields With this change all cmp+selector operators start with a common sequence of fields all of type `Slot`: result, val_true, val_false. * change cmp+branch operator field layout Now all cmp+branch operators start with their common offset: BranchOffset field.
1 parent 5e35884 commit 3b4db1d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crates/ir2/build/op.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ impl CmpBranchOp {
13361336
}
13371337

13381338
pub fn fields(&self) -> [Field; 3] {
1339-
[self.lhs_field(), self.rhs_field(), self.offset_field()]
1339+
[self.offset_field(), self.lhs_field(), self.rhs_field()]
13401340
}
13411341
}
13421342

@@ -1375,10 +1375,10 @@ impl CmpSelectOp {
13751375
pub fn fields(&self) -> [Field; 5] {
13761376
[
13771377
self.result_field(),
1378-
self.lhs_field(),
1379-
self.rhs_field(),
13801378
self.val_true_field(),
13811379
self.val_false_field(),
1380+
self.lhs_field(),
1381+
self.rhs_field(),
13821382
]
13831383
}
13841384
}

crates/ir2/src/decode/op.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ where
7575

7676
#[derive(Copy, Clone)]
7777
pub struct CmpBranchOp<Lhs, Rhs> {
78+
pub offset: BranchOffset,
7879
pub lhs: Lhs,
7980
pub rhs: Rhs,
80-
pub offset: BranchOffset,
8181
}
8282

8383
impl<Lhs, Rhs> Decode for CmpBranchOp<Lhs, Rhs>
@@ -97,10 +97,10 @@ where
9797
#[derive(Copy, Clone)]
9898
pub struct CmpSelectOp<Lhs, Rhs> {
9999
pub result: Slot,
100-
pub lhs: Lhs,
101-
pub rhs: Rhs,
102100
pub val_true: Slot,
103101
pub val_false: Slot,
102+
pub lhs: Lhs,
103+
pub rhs: Rhs,
104104
}
105105

106106
impl<Lhs, Rhs> Decode for CmpSelectOp<Lhs, Rhs>
@@ -111,10 +111,10 @@ where
111111
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
112112
Ok(Self {
113113
result: Decode::decode(decoder)?,
114-
lhs: Decode::decode(decoder)?,
115-
rhs: Decode::decode(decoder)?,
116114
val_true: Decode::decode(decoder)?,
117115
val_false: Decode::decode(decoder)?,
116+
lhs: Decode::decode(decoder)?,
117+
rhs: Decode::decode(decoder)?,
118118
})
119119
}
120120
}

0 commit comments

Comments
 (0)