diff options
author | Jason Gross <jgross@mit.edu> | 2016-09-22 14:49:26 -0400 |
---|---|---|
committer | Jason Gross <jgross@mit.edu> | 2016-09-22 17:21:59 -0400 |
commit | 32d98fc732fe9f9be911552c7fa7cb8947e55096 (patch) | |
tree | c486f2ea59c4ad1257b814474d745b78f521bbe7 /src/BoundedArithmetic/ArchitectureToZLike.v | |
parent | f7e7c340ab08de79db745db5d2b699dd99dc407a (diff) |
Drop CSE from Fancy Machine
By being careful about building the expressions in the first place, we
no longer need it, and can rely on dead code elimination.
Diffstat (limited to 'src/BoundedArithmetic/ArchitectureToZLike.v')
-rw-r--r-- | src/BoundedArithmetic/ArchitectureToZLike.v | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/BoundedArithmetic/ArchitectureToZLike.v b/src/BoundedArithmetic/ArchitectureToZLike.v index e37932192..939265c1e 100644 --- a/src/BoundedArithmetic/ArchitectureToZLike.v +++ b/src/BoundedArithmetic/ArchitectureToZLike.v @@ -13,11 +13,12 @@ Section fancy_machine_p256_montgomery_foundation. Local Notation n := (2 * n_over_two). Context (ops : fancy_machine.instructions n) (modulus : Z). - Global Instance ZLikeOps_of_ArchitectureBoundedOps (smaller_bound_exp : Z) + Local Instance ZLikeOps_of_ArchitectureBoundedOps_Factored (smaller_bound_exp : Z) + ldi_modulus ldi_0 : ZLikeOps (2^n) (2^smaller_bound_exp) modulus := { LargeT := tuple fancy_machine.W 2; SmallT := fancy_machine.W; - modulus_digits := ldi modulus; + modulus_digits := ldi_modulus; decode_large := decode; decode_small := decode; Mod_SmallBound v := fst v; @@ -28,6 +29,10 @@ Section fancy_machine_p256_montgomery_foundation. Mul x y := muldw x y; CarryAdd x y := adc x y false; CarrySubSmall x y := subc x y false; - ConditionalSubtract b x := let v := selc b (ldi modulus) (ldi 0) in snd (subc x v false); - ConditionalSubtractModulus y := addm y (ldi 0) (ldi modulus) }. + ConditionalSubtract b x := let v := selc b (ldi_modulus) (ldi_0) in snd (subc x v false); + ConditionalSubtractModulus y := addm y (ldi_0) (ldi_modulus) }. + + Global Instance ZLikeOps_of_ArchitectureBoundedOps (smaller_bound_exp : Z) + : ZLikeOps (2^n) (2^smaller_bound_exp) modulus := + @ZLikeOps_of_ArchitectureBoundedOps_Factored smaller_bound_exp (ldi modulus) (ldi 0). End fancy_machine_p256_montgomery_foundation. |