Skip to content

Commit

Permalink
MIPS/Store32: add missing constraint checking the decomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Apr 23, 2024
1 parent 8f374c6 commit bb0d63f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions optimism/src/mips/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,15 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: ITypeInstructi
},
]
};
// Checking that v is the correct decomposition.
{
let res = value
- v0.clone() * Env::constant(1 << 24)
- v1.clone() * Env::constant(1 << 16)
- v2.clone() * Env::constant(1 << 8)
- v3.clone();
env.is_zero(&res)
};
env.write_memory(&addr, v0);
env.write_memory(&(addr.clone() + Env::constant(1)), v1);
env.write_memory(&(addr.clone() + Env::constant(2)), v2);
Expand Down
7 changes: 4 additions & 3 deletions optimism/src/mips/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ fn test_mips_number_constraints() {
JumpAndLink => assert_num_constraints(&instr, 3),
},
IType(itype) => match itype {
BranchLeqZero | BranchGtZero | BranchLtZero | BranchGeqZero | Store8 | Store16
| Store32 => assert_num_constraints(&instr, 0),
BranchEq | BranchNeq => assert_num_constraints(&instr, 2),
BranchLeqZero | BranchGtZero | BranchLtZero | BranchGeqZero | Store8 | Store16 => {
assert_num_constraints(&instr, 0)
}
BranchEq | BranchNeq | Store32 => assert_num_constraints(&instr, 2),
AddImmediate
| AddImmediateUnsigned
| SetLessThanImmediate
Expand Down

0 comments on commit bb0d63f

Please sign in to comment.