Skip to content

Commit

Permalink
o1vm/riscv32: remove unused divmod
Browse files Browse the repository at this point in the history
As for mul_hi_lo(_signed), the method is splitted as there are individual
instructions for div and mod.
  • Loading branch information
dannywillems committed Nov 20, 2024
1 parent bf08bdf commit d7e039d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 47 deletions.
13 changes: 0 additions & 13 deletions o1vm/src/interpreters/riscv32im/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,6 @@ impl<Fp: Field> InterpreterEnv for Env<Fp> {
self.variable(position)
}

unsafe fn divmod(
&mut self,
_x: &Self::Variable,
_y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position,
) -> (Self::Variable, Self::Variable) {
(
self.variable(position_quotient),
self.variable(position_remainder),
)
}

unsafe fn count_leading_zeros(
&mut self,
_x: &Self::Variable,
Expand Down
16 changes: 0 additions & 16 deletions o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,22 +1299,6 @@ pub trait InterpreterEnv {
position: Self::Position,
) -> Self::Variable;

/// Returns `(x / y, x % y)`, storing the results in `position_quotient` and
/// `position_remainder` respectively.
///
/// # Safety
///
/// There are no constraints on the returned values; callers must manually add constraints to
/// ensure that the pair of returned values correspond to the given values `x` and `y`, and
/// that they fall within the desired range.
unsafe fn divmod(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position,
) -> (Self::Variable, Self::Variable);

/// Returns the number of leading 0s in `x`, storing the result in `position`.
///
/// # Safety
Expand Down
18 changes: 0 additions & 18 deletions o1vm/src/interpreters/riscv32im/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,24 +542,6 @@ impl<Fp: Field> InterpreterEnv for Env<Fp> {
res
}

unsafe fn divmod(
&mut self,
x: &Self::Variable,
y: &Self::Variable,
position_quotient: Self::Position,
position_remainder: Self::Position,
) -> (Self::Variable, Self::Variable) {
let x: u32 = (*x).try_into().unwrap();
let y: u32 = (*y).try_into().unwrap();
let q = x / y;
let r = x % y;
let q = q as u64;
let r = r as u64;
self.write_column(position_quotient, q);
self.write_column(position_remainder, r);
(q, r)
}

unsafe fn count_leading_zeros(
&mut self,
x: &Self::Variable,
Expand Down

0 comments on commit d7e039d

Please sign in to comment.