diff --git a/src/crypto_scalarmult/curve25519/amd64/mulx/curve25519.jinc b/src/crypto_scalarmult/curve25519/amd64/mulx/curve25519.jinc index 280c44f6..7f2d397b 100644 --- a/src/crypto_scalarmult/curve25519/amd64/mulx/curve25519.jinc +++ b/src/crypto_scalarmult/curve25519/amd64/mulx/curve25519.jinc @@ -97,8 +97,8 @@ inline fn __montgomery_ladder4( { stack u64[4] us x2 x3 z3; reg u64[4] z2r; - stack u64 ctrs swapped; - reg u64 ctr; + stack u64 swapped; + #spill_to_mmx reg u64 ctr; (x2,z2r,x3,z3) = __init_points4(u); us = #copy(u); @@ -109,12 +109,12 @@ inline fn __montgomery_ladder4( while { ctr -= 1; - ctrs = ctr; + () = #spill(ctr); (x2, z2r, x3, z3, swapped) = __montgomery_ladder_step4(k, us, x2, z2r, x3, z3, swapped, ctr); - ctr = ctrs; + () = #unspill(ctr); } (ctr > 0) return x2, z2r; diff --git a/src/crypto_scalarmult/curve25519/amd64/mulx/scalarmult.jazz b/src/crypto_scalarmult/curve25519/amd64/mulx/scalarmult.jazz index d6146eca..26ca4ffb 100644 --- a/src/crypto_scalarmult/curve25519/amd64/mulx/scalarmult.jazz +++ b/src/crypto_scalarmult/curve25519/amd64/mulx/scalarmult.jazz @@ -1,37 +1,39 @@ from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc" require "curve25519.jinc" -export fn jade_scalarmult_curve25519_amd64_mulx(reg u64 qp np pp) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_mulx(#spill_to_mmx reg u64 qp np pp) -> reg u64 { reg u64 r; - stack u64 qps; reg u64[4] q n p; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); p = __load4(pp); q = __curve25519_mulx(n, p); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0(); return r; } -export fn jade_scalarmult_curve25519_amd64_mulx_base(reg u64 qp np) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_mulx_base(#spill_to_mmx reg u64 qp np) -> reg u64 { reg u64 r; - stack u64 qps; reg u64[4] q n; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); q = __curve25519_mulx_base(n); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0(); diff --git a/src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc b/src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc index 47c40757..38ddbb8a 100644 --- a/src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc +++ b/src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc @@ -96,8 +96,8 @@ inline fn __montgomery_ladder4( { stack u64[4] us x2 x3 z3; reg u64[4] z2r; - stack u64 ctrs swapped; - reg u64 ctr; + stack u64 swapped; + #spill_to_mmx reg u64 ctr; (x2,z2r,x3,z3) = __init_points4(u); us = #copy(u); @@ -108,12 +108,12 @@ inline fn __montgomery_ladder4( while { ctr -= 1; - ctrs = ctr; + () = #spill(ctr); (x2, z2r, x3, z3, swapped) = __montgomery_ladder_step4(k, us, x2, z2r, x3, z3, swapped, ctr); - ctr = ctrs; + () = #unspill(ctr); } (ctr > 0) return x2, z2r; diff --git a/src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz b/src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz index 7750b8c6..70e3a1f9 100644 --- a/src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz +++ b/src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz @@ -1,37 +1,39 @@ from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc" require "curve25519.jinc" -export fn jade_scalarmult_curve25519_amd64_ref4(reg u64 qp np pp) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_ref4(#spill_to_mmx reg u64 qp np pp) -> reg u64 { reg u64 r; - stack u64 qps; reg u64[4] q n p; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); p = __load4(pp); q = __curve25519_ref4(n, p); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0(); return r; } -export fn jade_scalarmult_curve25519_amd64_ref4_base(reg u64 qp np) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_ref4_base(#spill_to_mmx reg u64 qp np) -> reg u64 { reg u64 r; - stack u64 qps; reg u64[4] q n; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); q = __curve25519_ref4_base(n); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0(); diff --git a/src/crypto_scalarmult/curve25519/amd64/ref5/curve25519.jinc b/src/crypto_scalarmult/curve25519/amd64/ref5/curve25519.jinc index 6963fcde..2a289f2d 100644 --- a/src/crypto_scalarmult/curve25519/amd64/ref5/curve25519.jinc +++ b/src/crypto_scalarmult/curve25519/amd64/ref5/curve25519.jinc @@ -94,8 +94,8 @@ inline fn __montgomery_ladder5( { stack u64[5] us x2 x3 z3; reg u64[5] z2r; - stack u64 ctrs swapped; - reg u64 ctr; + stack u64 swapped; + #spill_to_mmx reg u64 ctr; (x2,z2r,x3,z3) = __init_points5(u); us = #copy(u); @@ -106,12 +106,12 @@ inline fn __montgomery_ladder5( while { ctr -= 1; - ctrs = ctr; + () = #spill(ctr); (x2, z2r, x3, z3, swapped) = __montgomery_ladder_step5(k, us, x2, z2r, x3, z3, swapped, ctr); - ctr = ctrs; + () = #unspill(ctr); } (ctr > 0) return x2, z2r; diff --git a/src/crypto_scalarmult/curve25519/amd64/ref5/scalarmult.jazz b/src/crypto_scalarmult/curve25519/amd64/ref5/scalarmult.jazz index 88556ba3..50d2d533 100644 --- a/src/crypto_scalarmult/curve25519/amd64/ref5/scalarmult.jazz +++ b/src/crypto_scalarmult/curve25519/amd64/ref5/scalarmult.jazz @@ -1,37 +1,41 @@ from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc" require "curve25519.jinc" -export fn jade_scalarmult_curve25519_amd64_ref5(reg u64 qp np pp) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_ref5(#spill_to_mmx reg u64 qp np pp) -> reg u64 { reg u64 r; stack u64 qps; reg u64[4] q n p; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); p = __load4(pp); q = __curve25519_ref5(n, p); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0(); return r; } -export fn jade_scalarmult_curve25519_amd64_ref5_base(reg u64 qp np) -> reg u64 +export fn jade_scalarmult_curve25519_amd64_ref5_base(#spill_to_mmx reg u64 qp np) -> reg u64 { reg u64 r; stack u64 qps; reg u64[4] q n; - qps = qp; + _ = #init_msf(); + + () = #spill(qp); n = __load4(np); q = __curve25519_ref5_base(n); - qp = qps; + () = #unspill(qp); __store4(qp, q); ?{}, r = #set0();