Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
asm_macros.hpp File Reference

Go to the source code of this file.

Macros

#define CLEAR_FLAGS(empty_reg)    "xorq " empty_reg ", " empty_reg " \n\t"
 
#define LOAD_FIELD_ELEMENT(a, lolo, lohi, hilo, hihi)
 
#define STORE_FIELD_ELEMENT(r, lolo, lohi, hilo, hihi)
 
#define ADD(b)
 
#define SUB(b)
 
#define ADD_REDUCE(b, modulus_0, modulus_1, modulus_2, modulus_3)
 
#define REDUCE_FIELD_ELEMENT(neg_modulus_0, neg_modulus_1, neg_modulus_2, neg_modulus_3)
 
#define SQR(a)
 
#define MUL(a1, a2, a3, a4, b)
 
#define MUL_256(a, b, r)
 

Macro Definition Documentation

◆ ADD

#define ADD (   b)
Value:
"addq 0(" b "), %%r12 \n\t" \
"adcq 8(" b "), %%r13 \n\t" \
"adcq 16(" b "), %%r14 \n\t" \
"adcq 24(" b "), %%r15 \n\t"
FF b

Take a 4-limb field element, in (r12, r13, r14, r15), and add 4-limb field element pointed to by a

Definition at line 42 of file asm_macros.hpp.

◆ ADD_REDUCE

#define ADD_REDUCE (   b,
  modulus_0,
  modulus_1,
  modulus_2,
  modulus_3 
)
Value:
"addq 0(" b "), %%r12 \n\t" \
"adcq 8(" b "), %%r13 \n\t" \
"adcq 16(" b "), %%r14 \n\t" \
"adcq 24(" b "), %%r15 \n\t" \
"movq %%r12, %%r8 \n\t" \
"movq %%r13, %%r9 \n\t" \
"movq %%r14, %%r10 \n\t" \
"movq %%r15, %%r11 \n\t" \
"addq " modulus_0 ", %%r12 \n\t" \
"adcq " modulus_1 ", %%r13 \n\t" \
"adcq " modulus_2 ", %%r14 \n\t" \
"adcq " modulus_3 ", %%r15 \n\t" \
"cmovncq %%r8, %%r12 \n\t" \
"cmovncq %%r9, %%r13 \n\t" \
"cmovncq %%r10, %%r14 \n\t" \
"cmovncq %%r11, %%r15 \n\t"

Take a 4-limb field element, in (r12, r13, r14, r15), add 4-limb field element pointed to by b, and reduce modulo p

Definition at line 63 of file asm_macros.hpp.

◆ CLEAR_FLAGS

#define CLEAR_FLAGS (   empty_reg)     "xorq " empty_reg ", " empty_reg " \n\t"

Definition at line 13 of file asm_macros.hpp.

◆ LOAD_FIELD_ELEMENT

#define LOAD_FIELD_ELEMENT (   a,
  lolo,
  lohi,
  hilo,
  hihi 
)
Value:
"movq 0(" a "), " lolo " \n\t" \
"movq 8(" a "), " lohi " \n\t" \
"movq 16(" a "), " hilo " \n\t" \
"movq 24(" a "), " hihi " \n\t"
FF a

Load 4-limb field element, pointed to by a, into registers (lolo, lohi, hilo, hihi)

Definition at line 20 of file asm_macros.hpp.

◆ MUL

#define MUL (   a1,
  a2,
  a3,
  a4,
  b 
)

Compute Montgomery multiplication of a, b. Result is stored, in (%r12, %r13, %r14, %r15), in preparation for being stored in "r"

Definition at line 241 of file asm_macros.hpp.

◆ MUL_256

#define MUL_256 (   a,
  b,
 
)

Compute 256-bit multiplication of a, b. Result is stored, r. // in (%r12, %r13, %r14, %r15), in preparation for being stored in "r"

Definition at line 400 of file asm_macros.hpp.

◆ REDUCE_FIELD_ELEMENT

#define REDUCE_FIELD_ELEMENT (   neg_modulus_0,
  neg_modulus_1,
  neg_modulus_2,
  neg_modulus_3 
)
Value:
/* Duplicate `r` */ \
"movq %%r12, %%r8 \n\t" \
"movq %%r13, %%r9 \n\t" \
"movq %%r14, %%r10 \n\t" \
"movq %%r15, %%r11 \n\t" \
"addq " neg_modulus_0 ", %%r12 \n\t" /* r'[0] -= modulus.data[0] */ \
"adcq " neg_modulus_1 ", %%r13 \n\t" /* r'[1] -= modulus.data[1] */ \
"adcq " neg_modulus_2 ", %%r14 \n\t" /* r'[2] -= modulus.data[2] */ \
"adcq " neg_modulus_3 ", %%r15 \n\t" /* r'[3] -= modulus.data[3] */ \
\
/* if r does not need to be reduced, overflow flag is 1 */ \
/* set r' = r if this flag is set */ \
"cmovncq %%r8, %%r12 \n\t" \
"cmovncq %%r9, %%r13 \n\t" \
"cmovncq %%r10, %%r14 \n\t" \
"cmovncq %%r11, %%r15 \n\t"

Take a 4-limb integer, r, in (r12, r13, r14, r15) and conditionally subtract modulus, if r > p.

Definition at line 87 of file asm_macros.hpp.

◆ SQR

#define SQR (   a)

Compute Montgomery squaring of a Result is stored, in (%r12, %r13, %r14, %r15), in preparation for being stored in "r"

Definition at line 109 of file asm_macros.hpp.

◆ STORE_FIELD_ELEMENT

#define STORE_FIELD_ELEMENT (   r,
  lolo,
  lohi,
  hilo,
  hihi 
)
Value:
"movq " lolo ", 0(" r ") \n\t" \
"movq " lohi ", 8(" r ") \n\t" \
"movq " hilo ", 16(" r ") \n\t" \
"movq " hihi ", 24(" r ") \n\t"

Store 4-limb field element located in registers (lolo, lohi, hilo, hihi), into memory pointed to by r

Definition at line 31 of file asm_macros.hpp.

◆ SUB

#define SUB (   b)
Value:
"subq 0(" b "), %%r12 \n\t" \
"sbbq 8(" b "), %%r13 \n\t" \
"sbbq 16(" b "), %%r14 \n\t" \
"sbbq 24(" b "), %%r15 \n\t"

Take a 4-limb field element, in (r12, r13, r14, r15), and subtract 4-limb field element pointed to by b

Definition at line 52 of file asm_macros.hpp.