Improve the presentation of assembly blocks
Uncrustify indents ``` asm("foo" HELLO "bar" "wibble"); ``` but we would like ``` asm("foo" HELLO "bar" "wibble"); ``` Make "bar" an argument of the macro HELLO, which makes the indentation from uncrustify match the semantics (everything should be aligned to the same column). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
d0f9b0bacc
commit
4e20144882
1 changed files with 118 additions and 118 deletions
|
@ -69,13 +69,13 @@ int mbedtls_aesni_has_support(unsigned int what)
|
|||
* Operand macros are in gas order (src, dst) as opposed to Intel order
|
||||
* (dst, src) in order to blend better into the surrounding assembly code.
|
||||
*/
|
||||
#define AESDEC ".byte 0x66,0x0F,0x38,0xDE,"
|
||||
#define AESDECLAST ".byte 0x66,0x0F,0x38,0xDF,"
|
||||
#define AESENC ".byte 0x66,0x0F,0x38,0xDC,"
|
||||
#define AESENCLAST ".byte 0x66,0x0F,0x38,0xDD,"
|
||||
#define AESIMC ".byte 0x66,0x0F,0x38,0xDB,"
|
||||
#define AESKEYGENA ".byte 0x66,0x0F,0x3A,0xDF,"
|
||||
#define PCLMULQDQ ".byte 0x66,0x0F,0x3A,0x44,"
|
||||
#define AESDEC(regs) ".byte 0x66,0x0F,0x38,0xDE," regs "\n\t"
|
||||
#define AESDECLAST(regs) ".byte 0x66,0x0F,0x38,0xDF," regs "\n\t"
|
||||
#define AESENC(regs) ".byte 0x66,0x0F,0x38,0xDC," regs "\n\t"
|
||||
#define AESENCLAST(regs) ".byte 0x66,0x0F,0x38,0xDD," regs "\n\t"
|
||||
#define AESIMC(regs) ".byte 0x66,0x0F,0x38,0xDB," regs "\n\t"
|
||||
#define AESKEYGENA(regs, imm) ".byte 0x66,0x0F,0x3A,0xDF," regs "," imm "\n\t"
|
||||
#define PCLMULQDQ(regs, imm) ".byte 0x66,0x0F,0x3A,0x44," regs "," imm "\n\t"
|
||||
|
||||
#define xmm0_xmm0 "0xC0"
|
||||
#define xmm0_xmm1 "0xC8"
|
||||
|
@ -103,22 +103,22 @@ int mbedtls_aesni_crypt_ecb(mbedtls_aes_context *ctx,
|
|||
|
||||
"1: \n\t" // encryption loop
|
||||
"movdqu (%1), %%xmm1 \n\t" // load round key
|
||||
AESENC xmm1_xmm0 "\n\t" // do round
|
||||
AESENC(xmm1_xmm0) // do round
|
||||
"add $16, %1 \n\t" // point to next round key
|
||||
"subl $1, %0 \n\t" // loop
|
||||
"jnz 1b \n\t"
|
||||
"movdqu (%1), %%xmm1 \n\t" // load round key
|
||||
AESENCLAST xmm1_xmm0 "\n\t" // last round
|
||||
AESENCLAST(xmm1_xmm0) // last round
|
||||
"jmp 3f \n\t"
|
||||
|
||||
"2: \n\t" // decryption loop
|
||||
"movdqu (%1), %%xmm1 \n\t"
|
||||
AESDEC xmm1_xmm0 "\n\t" // do round
|
||||
AESDEC(xmm1_xmm0) // do round
|
||||
"add $16, %1 \n\t"
|
||||
"subl $1, %0 \n\t"
|
||||
"jnz 2b \n\t"
|
||||
"movdqu (%1), %%xmm1 \n\t" // load round key
|
||||
AESDECLAST xmm1_xmm0 "\n\t" // last round
|
||||
AESDECLAST(xmm1_xmm0) // last round
|
||||
|
||||
"3: \n\t"
|
||||
"movdqu %%xmm0, (%4) \n\t" // export output
|
||||
|
@ -157,10 +157,10 @@ void mbedtls_aesni_gcm_mult(unsigned char c[16],
|
|||
"movdqa %%xmm1, %%xmm2 \n\t" // copy of b1:b0
|
||||
"movdqa %%xmm1, %%xmm3 \n\t" // same
|
||||
"movdqa %%xmm1, %%xmm4 \n\t" // same
|
||||
PCLMULQDQ xmm0_xmm1 ",0x00 \n\t" // a0*b0 = c1:c0
|
||||
PCLMULQDQ xmm0_xmm2 ",0x11 \n\t" // a1*b1 = d1:d0
|
||||
PCLMULQDQ xmm0_xmm3 ",0x10 \n\t" // a0*b1 = e1:e0
|
||||
PCLMULQDQ xmm0_xmm4 ",0x01 \n\t" // a1*b0 = f1:f0
|
||||
PCLMULQDQ(xmm0_xmm1, "0x00") // a0*b0 = c1:c0
|
||||
PCLMULQDQ(xmm0_xmm2, "0x11") // a1*b1 = d1:d0
|
||||
PCLMULQDQ(xmm0_xmm3, "0x10") // a0*b1 = e1:e0
|
||||
PCLMULQDQ(xmm0_xmm4, "0x01") // a1*b0 = f1:f0
|
||||
"pxor %%xmm3, %%xmm4 \n\t" // e1+f1:e0+f0
|
||||
"movdqa %%xmm4, %%xmm3 \n\t" // same
|
||||
"psrldq $8, %%xmm4 \n\t" // 0:e1+f1
|
||||
|
@ -255,7 +255,7 @@ void mbedtls_aesni_inverse_key(unsigned char *invkey,
|
|||
|
||||
for (fk -= 16, ik += 16; fk > fwdkey; fk -= 16, ik += 16) {
|
||||
asm ("movdqu (%0), %%xmm0 \n\t"
|
||||
AESIMC xmm0_xmm0 "\n\t"
|
||||
AESIMC(xmm0_xmm0)
|
||||
"movdqu %%xmm0, (%1) \n\t"
|
||||
:
|
||||
: "r" (fk), "r" (ik)
|
||||
|
@ -300,16 +300,16 @@ static void aesni_setkey_enc_128(unsigned char *rk,
|
|||
|
||||
/* Main "loop" */
|
||||
"2: \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x01 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x02 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x04 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x08 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x10 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x20 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x40 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x80 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x1B \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm0_xmm1 ",0x36 \n\tcall 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x01") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x02") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x04") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x08") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x10") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x20") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x40") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x80") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x1B") "call 1b \n\t"
|
||||
AESKEYGENA(xmm0_xmm1, "0x36") "call 1b \n\t"
|
||||
:
|
||||
: "r" (rk), "r" (key)
|
||||
: "memory", "cc", "0");
|
||||
|
@ -358,14 +358,14 @@ static void aesni_setkey_enc_192(unsigned char *rk,
|
|||
"ret \n\t"
|
||||
|
||||
"2: \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x08 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x10 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x20 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x40 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x80 \n\tcall 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x01") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x02") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x04") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x08") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x10") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x20") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x40") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x80") "call 1b \n\t"
|
||||
|
||||
:
|
||||
: "r" (rk), "r" (key)
|
||||
|
@ -408,7 +408,7 @@ static void aesni_setkey_enc_256(unsigned char *rk,
|
|||
|
||||
/* Set xmm2 to stuff:Y:stuff:stuff with Y = subword( r11 )
|
||||
* and proceed to generate next round key from there */
|
||||
AESKEYGENA xmm0_xmm2 ",0x00 \n\t"
|
||||
AESKEYGENA(xmm0_xmm2, "0x00")
|
||||
"pshufd $0xaa, %%xmm2, %%xmm2 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
|
@ -426,13 +426,13 @@ static void aesni_setkey_enc_256(unsigned char *rk,
|
|||
* see definition of mbedtls_aes_context.buf
|
||||
*/
|
||||
"2: \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x08 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x10 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x20 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x40 \n\tcall 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x01") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x02") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x04") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x08") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x10") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x20") "call 1b \n\t"
|
||||
AESKEYGENA(xmm1_xmm2, "0x40") "call 1b \n\t"
|
||||
:
|
||||
: "r" (rk), "r" (key)
|
||||
: "memory", "cc", "0");
|
||||
|
|
Loading…
Reference in a new issue