[PATCH] [v2] Fix building with Clang on x86-64 and i386

Jussi Kivilinna jussi.kivilinna at mbnet.fi
Tue Nov 27 22:44:13 CET 2012


* cipher/rijndael.c [USE_AESNI] (do_aesni_enc_aligned)
(do_aesni_dec_vec4, do_aesni_cfb, do_aesni_ctr, do_aesni_ctr_4): Add
explicit suffix to 'cmp' instructions.
--

Clang throws errors on missing instruction suffixes, such as:

rijndael.c:1091:39: error: ambiguous instructions require an explicit suffix (could be 'cmpb', 'cmpw', 'cmpl', or 'cmpq')
<inline asm>:39:2: note: instantiated into assembly here
        cmp $1, -44(%rbp)

With this patch building on x86-64 works fine. Other issues still exists on i386,
namely with MPI, which can be overcome with 'clang -fheinous-gnu-extensions'.

[v2]:
 - remove do_aesni_enc_vec4 modification as that function didn't make it to upstream.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
---
 cipher/rijndael.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 860dcf8..0f5e07c 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -742,13 +742,13 @@ do_aesni_enc_aligned (const RIJNDAEL_context *ctx,
                 "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xa0(%[key]), %%xmm1\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xc0(%[key]), %%xmm1\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xd0(%[key]), %%xmm1\n\t"
@@ -796,13 +796,13 @@ do_aesni_dec_aligned (const RIJNDAEL_context *ctx,
                 "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
                 "movdqa 0xa0(%[key]), %%xmm1\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm1_xmm0
                 "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
                 "movdqa 0xc0(%[key]), %%xmm1\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm1_xmm0
                 "movdqa 0xd0(%[key]), %%xmm1\n\t"
@@ -886,7 +886,7 @@ do_aesni_dec_vec4 (const RIJNDAEL_context *ctx)
                 aesdec_xmm0_xmm3
                 aesdec_xmm0_xmm4
                 "movdqa 0xa0(%[key]), %%xmm0\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm0_xmm1
                 aesdec_xmm0_xmm2
@@ -898,7 +898,7 @@ do_aesni_dec_vec4 (const RIJNDAEL_context *ctx)
                 aesdec_xmm0_xmm3
                 aesdec_xmm0_xmm4
                 "movdqa 0xc0(%[key]), %%xmm0\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm0_xmm1
                 aesdec_xmm0_xmm2
@@ -963,13 +963,13 @@ do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
                 "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xa0(%[key]), %%xmm1\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xc0(%[key]), %%xmm1\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xd0(%[key]), %%xmm1\n\t"
@@ -981,7 +981,7 @@ do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
                 "movdqu %[src], %%xmm1\n\t"      /* Save input.  */
                 "pxor %%xmm1, %%xmm0\n\t"        /* xmm0 = input ^ IV  */
 
-                "cmp $1, %[decrypt]\n\t"
+                "cmpl $1, %[decrypt]\n\t"
                 "jz .Ldecrypt_%=\n\t"
                 "movdqa %%xmm0, %[iv]\n\t"       /* [encrypt] Store IV.  */
                 "jmp .Lleave_%=\n"
@@ -1058,13 +1058,13 @@ do_aesni_ctr (const RIJNDAEL_context *ctx,
                 "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xa0(%[key]), %%xmm1\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xc0(%[key]), %%xmm1\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 "movdqa 0xd0(%[key]), %%xmm1\n\t"
@@ -1219,7 +1219,7 @@ do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
                 "movdqa 0xa0(%[key]), %%xmm1\n\t"
-                "cmp $10, %[rounds]\n\t"
+                "cmpl $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
@@ -1231,7 +1231,7 @@ do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
                 "movdqa 0xc0(%[key]), %%xmm1\n\t"
-                "cmp $12, %[rounds]\n\t"
+                "cmpl $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2




More information about the Gcrypt-devel mailing list