Merged ASM format fixes in bn_mul.h

This commit is contained in:
Paul Bakker 2014-01-22 14:21:35 +01:00
commit a7eac95cc6

View file

@ -168,98 +168,120 @@
#if defined(__amd64__) || defined (__x86_64__) #if defined(__amd64__) || defined (__x86_64__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "movq %0, %%rsi " :: "m" (s)); \ asm( \
asm( "movq %0, %%rdi " :: "m" (d)); \ " \
asm( "movq %0, %%rcx " :: "m" (c)); \ movq %3, %%rsi; \
asm( "movq %0, %%rbx " :: "m" (b)); \ movq %4, %%rdi; \
asm( "xorq %r8, %r8 " ); movq %5, %%rcx; \
movq %6, %%rbx; \
xorq %%r8, %%r8; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "movq (%rsi),%rax " ); \ " \
asm( "mulq %rbx " ); \ movq (%%rsi), %%rax; \
asm( "addq $8, %rsi " ); \ mulq %%rbx; \
asm( "addq %rcx, %rax " ); \ addq $8, %%rsi; \
asm( "movq %r8, %rcx " ); \ addq %%rcx, %%rax; \
asm( "adcq $0, %rdx " ); \ movq %%r8, %%rcx; \
asm( "nop " ); \ adcq $0, %%rdx; \
asm( "addq %rax, (%rdi) " ); \ nop; \
asm( "adcq %rdx, %rcx " ); \ addq %%rax, (%%rdi); \
asm( "addq $8, %rdi " ); adcq %%rdx, %%rcx; \
addq $8, %%rdi; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "movq %%rcx, %0 " : "=m" (c)); \ " \
asm( "movq %%rdi, %0 " : "=m" (d)); \ movq %%rcx, %0; \
asm( "movq %%rsi, %0 " : "=m" (s) :: \ movq %%rdi, %1; \
"rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" ); movq %%rsi, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \
);
#endif /* AMD64 */ #endif /* AMD64 */
#if defined(__mc68020__) || defined(__mcpu32__) #if defined(__mc68020__) || defined(__mcpu32__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "movl %0, %%a2 " :: "m" (s)); \ asm( \
asm( "movl %0, %%a3 " :: "m" (d)); \ " \
asm( "movl %0, %%d3 " :: "m" (c)); \ movl %3, %%a2; \
asm( "movl %0, %%d2 " :: "m" (b)); \ movl %4, %%a3; \
asm( "moveq #0, %d0 " ); movl %5, %%d3; \
movl %6, %%d2; \
moveq #0, %%d0; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "movel %a2@+, %d1 " ); \ " \
asm( "mulul %d2, %d4:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addl %d3, %d1 " ); \ mulul %%d2, %%d4:%%d1; \
asm( "addxl %d0, %d4 " ); \ addl %%d3, %%d1; \
asm( "moveq #0, %d3 " ); \ addxl %%d0, %%d4; \
asm( "addl %d1, %a3@+ " ); \ moveq #0, %%d3; \
asm( "addxl %d4, %d3 " ); addl %%d1, %%a3@+; \
addxl %%d4, %%d3; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "movl %%d3, %0 " : "=m" (c)); \ " \
asm( "movl %%a3, %0 " : "=m" (d)); \ movl %%d3, %0; \
asm( "movl %%a2, %0 " : "=m" (s) :: \ movl %%a3, %1; \
"d0", "d1", "d2", "d3", "d4", "a2", "a3" ); movl %%a2, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "d0", "d1", "d2", "d3", "d4", "a2", "a3" \
);
#define MULADDC_HUIT \ #define MULADDC_HUIT \
asm( "movel %a2@+, %d1 " ); \ " \
asm( "mulul %d2, %d4:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d3, %d1 " ); \ mulul %%d2, %%d4:%%d1; \
asm( "addxl %d0, %d4 " ); \ addxl %%d3, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d4; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d3:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d4, %d1 " ); \ mulul %%d2, %%d3:%%d1; \
asm( "addxl %d0, %d3 " ); \ addxl %%d4, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d3; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d4:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d3, %d1 " ); \ mulul %%d2, %%d4:%%d1; \
asm( "addxl %d0, %d4 " ); \ addxl %%d3, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d4; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d3:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d4, %d1 " ); \ mulul %%d2, %%d3:%%d1; \
asm( "addxl %d0, %d3 " ); \ addxl %%d4, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d3; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d4:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d3, %d1 " ); \ mulul %%d2, %%d4:%%d1; \
asm( "addxl %d0, %d4 " ); \ addxl %%d3, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d4; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d3:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d4, %d1 " ); \ mulul %%d2, %%d3:%%d1; \
asm( "addxl %d0, %d3 " ); \ addxl %%d4, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d3; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d4:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d3, %d1 " ); \ mulul %%d2, %%d4:%%d1; \
asm( "addxl %d0, %d4 " ); \ addxl %%d3, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d4; \
asm( "movel %a2@+, %d1 " ); \ addl %%d1, %%a3@+; \
asm( "mulul %d2, %d3:%d1 " ); \ movel %%a2@+, %%d1; \
asm( "addxl %d4, %d1 " ); \ mulul %%d2, %%d3:%%d1; \
asm( "addxl %d0, %d3 " ); \ addxl %%d4, %%d1; \
asm( "addl %d1, %a3@+ " ); \ addxl %%d0, %%d3; \
asm( "addxl %d0, %d3 " ); addl %%d1, %%a3@+; \
addxl %%d0, %%d3; \
"
#endif /* MC68000 */ #endif /* MC68000 */
@ -269,62 +291,83 @@
#if defined(__MACH__) && defined(__APPLE__) #if defined(__MACH__) && defined(__APPLE__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "ld r3, %0 " :: "m" (s)); \ asm( \
asm( "ld r4, %0 " :: "m" (d)); \ " \
asm( "ld r5, %0 " :: "m" (c)); \ ld r3, %3; \
asm( "ld r6, %0 " :: "m" (b)); \ ld r4, %4; \
asm( "addi r3, r3, -8 " ); \ ld r5, %5; \
asm( "addi r4, r4, -8 " ); \ ld r6, %6; \
asm( "addic r5, r5, 0 " ); addi r3, r3, -8; \
addi r4, r4, -8; \
addic r5, r5, 0; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "ldu r7, 8(r3) " ); \ " \
asm( "mulld r8, r7, r6 " ); \ ldu r7, 8(r3); \
asm( "mulhdu r9, r7, r6 " ); \ mulld r8, r7, r6; \
asm( "adde r8, r8, r5 " ); \ mulhdu r9, r7, r6; \
asm( "ld r7, 8(r4) " ); \ adde r8, r8, r5; \
asm( "addze r5, r9 " ); \ ld r7, 8(r4); \
asm( "addc r8, r8, r7 " ); \ addze r5, r9; \
asm( "stdu r8, 8(r4) " ); addc r8, r8, r7; \
stdu r8, 8(r4); \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "addze r5, r5 " ); \ " \
asm( "addi r4, r4, 8 " ); \ addze r5, r5; \
asm( "addi r3, r3, 8 " ); \ addi r4, r4, 8; \
asm( "std r5, %0 " : "=m" (c)); \ addi r3, r3, 8; \
asm( "std r4, %0 " : "=m" (d)); \ std r5, %0; \
asm( "std r3, %0 " : "=m" (s) :: \ std r4, %1; \
"r3", "r4", "r5", "r6", "r7", "r8", "r9" ); std r3, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
);
#else #else
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "ld %%r3, %0 " :: "m" (s)); \ asm( \
asm( "ld %%r4, %0 " :: "m" (d)); \ " \
asm( "ld %%r5, %0 " :: "m" (c)); \ ld %%r3, %3; \
asm( "ld %%r6, %0 " :: "m" (b)); \ ld %%r4, %4; \
asm( "addi %r3, %r3, -8 " ); \ ld %%r5, %5; \
asm( "addi %r4, %r4, -8 " ); \ ld %%r6, %6; \
asm( "addic %r5, %r5, 0 " ); addi %%r3, %%r3, -8; \
addi %%r4, %%r4, -8; \
addic %%r5, %%r5, 0; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "ldu %r7, 8(%r3) " ); \ " \
asm( "mulld %r8, %r7, %r6 " ); \ ldu %%r7, 8(%%r3); \
asm( "mulhdu %r9, %r7, %r6 " ); \ mulld %%r8, %%r7, %%r6; \
asm( "adde %r8, %r8, %r5 " ); \ mulhdu %%r9, %%r7, %%r6; \
asm( "ld %r7, 8(%r4) " ); \ adde %%r8, %%r8, %%r5; \
asm( "addze %r5, %r9 " ); \ ld %%r7, 8(%%r4); \
asm( "addc %r8, %r8, %r7 " ); \ addze %%r5, %%r9; \
asm( "stdu %r8, 8(%r4) " ); addc %%r8, %%r8, %%r7; \
stdu %%r8, 8(%%r4); \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "addze %r5, %r5 " ); \ " \
asm( "addi %r4, %r4, 8 " ); \ addze %%r5, %%r5; \
asm( "addi %r3, %r3, 8 " ); \ addi %%r4, %%r4, 8; \
asm( "std %%r5, %0 " : "=m" (c)); \ addi %%r3, %%r3, 8; \
asm( "std %%r4, %0 " : "=m" (d)); \ std %%r5, %0; \
asm( "std %%r3, %0 " : "=m" (s) :: \ std %%r4, %1; \
"r3", "r4", "r5", "r6", "r7", "r8", "r9" ); std %%r3, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
);
#endif #endif
@ -333,62 +376,82 @@
#if defined(__MACH__) && defined(__APPLE__) #if defined(__MACH__) && defined(__APPLE__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "lwz r3, %0 " :: "m" (s)); \ asm( \
asm( "lwz r4, %0 " :: "m" (d)); \ " \
asm( "lwz r5, %0 " :: "m" (c)); \ lwz r3, %3; \
asm( "lwz r6, %0 " :: "m" (b)); \ lwz r4, %4; \
asm( "addi r3, r3, -4 " ); \ lwz r5, %5; \
asm( "addi r4, r4, -4 " ); \ lwz r6, %6; \
asm( "addic r5, r5, 0 " ); addi r3, r3, -4; \
addi r4, r4, -4; \
addic r5, r5, 0; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "lwzu r7, 4(r3) " ); \ " \
asm( "mullw r8, r7, r6 " ); \ lwzu r7, 4(r3); \
asm( "mulhwu r9, r7, r6 " ); \ mullw r8, r7, r6; \
asm( "adde r8, r8, r5 " ); \ mulhwu r9, r7, r6; \
asm( "lwz r7, 4(r4) " ); \ adde r8, r8, r5; \
asm( "addze r5, r9 " ); \ lwz r7, 4(r4); \
asm( "addc r8, r8, r7 " ); \ addze r5, r9; \
asm( "stwu r8, 4(r4) " ); addc r8, r8, r7; \
stwu r8, 4(r4); \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "addze r5, r5 " ); \ " \
asm( "addi r4, r4, 4 " ); \ addze r5, r5; \
asm( "addi r3, r3, 4 " ); \ addi r4, r4, 4; \
asm( "stw r5, %0 " : "=m" (c)); \ addi r3, r3, 4; \
asm( "stw r4, %0 " : "=m" (d)); \ stw r5, %0; \
asm( "stw r3, %0 " : "=m" (s) :: \ stw r4, %1; \
"r3", "r4", "r5", "r6", "r7", "r8", "r9" ); stw r3, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
);
#else #else
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "lwz %%r3, %0 " :: "m" (s)); \ asm( \
asm( "lwz %%r4, %0 " :: "m" (d)); \ " \
asm( "lwz %%r5, %0 " :: "m" (c)); \ lwz %%r3, %3; \
asm( "lwz %%r6, %0 " :: "m" (b)); \ lwz %%r4, %4; \
asm( "addi %r3, %r3, -4 " ); \ lwz %%r5, %5; \
asm( "addi %r4, %r4, -4 " ); \ lwz %%r6, %6; \
asm( "addic %r5, %r5, 0 " ); addi %%r3, %%r3, -4; \
addi %%r4, %%r4, -4; \
addic %%r5, %%r5, 0; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "lwzu %r7, 4(%r3) " ); \ " \
asm( "mullw %r8, %r7, %r6 " ); \ lwzu %%r7, 4(%%r3); \
asm( "mulhwu %r9, %r7, %r6 " ); \ mullw %%r8, %%r7, %%r6; \
asm( "adde %r8, %r8, %r5 " ); \ mulhwu %%r9, %%r7, %%r6; \
asm( "lwz %r7, 4(%r4) " ); \ adde %%r8, %%r8, %%r5; \
asm( "addze %r5, %r9 " ); \ lwz %%r7, 4(%%r4); \
asm( "addc %r8, %r8, %r7 " ); \ addze %%r5, %%r9; \
asm( "stwu %r8, 4(%r4) " ); addc %%r8, %%r8, %%r7; \
stwu %%r8, 4(%%r4); \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "addze %r5, %r5 " ); \ " \
asm( "addi %r4, %r4, 4 " ); \ addze %%r5, %%r5; \
asm( "addi %r3, %r3, 4 " ); \ addi %%r4, %%r4, 4; \
asm( "stw %%r5, %0 " : "=m" (c)); \ addi %%r3, %%r3, 4; \
asm( "stw %%r4, %0 " : "=m" (d)); \ stw %%r5, %0; \
asm( "stw %%r3, %0 " : "=m" (s) :: \ stw %%r4, %1; \
"r3", "r4", "r5", "r6", "r7", "r8", "r9" ); stw %%r3, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
);
#endif #endif
@ -477,72 +540,92 @@
#if defined(__microblaze__) || defined(microblaze) #if defined(__microblaze__) || defined(microblaze)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "lwi r3, %0 " :: "m" (s)); \ asm( \
asm( "lwi r4, %0 " :: "m" (d)); \ " \
asm( "lwi r5, %0 " :: "m" (c)); \ lwi r3, %3; \
asm( "lwi r6, %0 " :: "m" (b)); \ lwi r4, %4; \
asm( "andi r7, r6, 0xffff" ); \ lwi r5, %5; \
asm( "bsrli r6, r6, 16 " ); lwi r6, %6; \
andi r7, r6, 0xffff; \
bsrli r6, r6, 16; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "lhui r8, r3, 0 " ); \ " \
asm( "addi r3, r3, 2 " ); \ lhui r8, r3, 0; \
asm( "lhui r9, r3, 0 " ); \ addi r3, r3, 2; \
asm( "addi r3, r3, 2 " ); \ lhui r9, r3, 0; \
asm( "mul r10, r9, r6 " ); \ addi r3, r3, 2; \
asm( "mul r11, r8, r7 " ); \ mul r10, r9, r6; \
asm( "mul r12, r9, r7 " ); \ mul r11, r8, r7; \
asm( "mul r13, r8, r6 " ); \ mul r12, r9, r7; \
asm( "bsrli r8, r10, 16 " ); \ mul r13, r8, r6; \
asm( "bsrli r9, r11, 16 " ); \ bsrli r8, r10, 16; \
asm( "add r13, r13, r8 " ); \ bsrli r9, r11, 16; \
asm( "add r13, r13, r9 " ); \ add r13, r13, r8; \
asm( "bslli r10, r10, 16 " ); \ add r13, r13, r9; \
asm( "bslli r11, r11, 16 " ); \ bslli r10, r10, 16; \
asm( "add r12, r12, r10 " ); \ bslli r11, r11, 16; \
asm( "addc r13, r13, r0 " ); \ add r12, r12, r10; \
asm( "add r12, r12, r11 " ); \ addc r13, r13, r0; \
asm( "addc r13, r13, r0 " ); \ add r12, r12, r11; \
asm( "lwi r10, r4, 0 " ); \ addc r13, r13, r0; \
asm( "add r12, r12, r10 " ); \ lwi r10, r4, 0; \
asm( "addc r13, r13, r0 " ); \ add r12, r12, r10; \
asm( "add r12, r12, r5 " ); \ addc r13, r13, r0; \
asm( "addc r5, r13, r0 " ); \ add r12, r12, r5; \
asm( "swi r12, r4, 0 " ); \ addc r5, r13, r0; \
asm( "addi r4, r4, 4 " ); swi r12, r4, 0; \
addi r4, r4, 4; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "swi r5, %0 " : "=m" (c)); \ " \
asm( "swi r4, %0 " : "=m" (d)); \ swi r5, %0; \
asm( "swi r3, %0 " : "=m" (s) :: \ swi r4, %1; \
"r3", "r4" , "r5" , "r6" , "r7" , "r8" , \ swi r3, %2; \
"r9", "r10", "r11", "r12", "r13" ); " \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "r3", "r4" "r5", "r6", "r7", "r8", \
"r9", "r10", "r11", "r12", "r13" \
);
#endif /* MicroBlaze */ #endif /* MicroBlaze */
#if defined(__tricore__) #if defined(__tricore__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "ld.a %%a2, %0 " :: "m" (s)); \ asm( \
asm( "ld.a %%a3, %0 " :: "m" (d)); \ " \
asm( "ld.w %%d4, %0 " :: "m" (c)); \ ld.a %%a2, %3; \
asm( "ld.w %%d1, %0 " :: "m" (b)); \ ld.a %%a3, %4; \
asm( "xor %d5, %d5 " ); ld.w %%d4, %5; \
ld.w %%d1, %6; \
xor %%d5, %%d5; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "ld.w %d0, [%a2+] " ); \ " \
asm( "madd.u %e2, %e4, %d0, %d1 " ); \ ld.w %%d0, [%%a2+]; \
asm( "ld.w %d0, [%a3] " ); \ madd.u %%e2, %%e4, %%d0, %%d1; \
asm( "addx %d2, %d2, %d0 " ); \ ld.w %%d0, [%%a3]; \
asm( "addc %d3, %d3, 0 " ); \ addx %%d2, %%d2, %%d0; \
asm( "mov %d4, %d3 " ); \ addc %%d3, %%d3, 0; \
asm( "st.w [%a3+], %d2 " ); mov %%d4, %%d3; \
st.w [%%a3+], %%d2; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "st.w %0, %%d4 " : "=m" (c)); \ " \
asm( "st.a %0, %%a3 " : "=m" (d)); \ st.w %0, %%d4; \
asm( "st.a %0, %%a2 " : "=m" (s) :: \ st.a %1, %%a3; \
"d0", "d1", "e2", "d4", "a2", "a3" ); st.a %2, %%a2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "d0", "d1", "e2", "d4", "a2", "a3" \
);
#endif /* TriCore */ #endif /* TriCore */
@ -650,63 +733,82 @@
#if defined(__alpha__) #if defined(__alpha__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "ldq $1, %0 " :: "m" (s)); \ asm( \
asm( "ldq $2, %0 " :: "m" (d)); \ " \
asm( "ldq $3, %0 " :: "m" (c)); \ ldq $1, %3; \
asm( "ldq $4, %0 " :: "m" (b)); ldq $2, %4; \
ldq $3, %5; \
ldq $4, %6; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "ldq $6, 0($1) " ); \ " \
asm( "addq $1, 8, $1 " ); \ ldq $6, 0($1); \
asm( "mulq $6, $4, $7 " ); \ addq $1, 8, $1; \
asm( "umulh $6, $4, $6 " ); \ mulq $6, $4, $7; \
asm( "addq $7, $3, $7 " ); \ umulh $6, $4, $6; \
asm( "cmpult $7, $3, $3 " ); \ addq $7, $3, $7; \
asm( "ldq $5, 0($2) " ); \ cmpult $7, $3, $3; \
asm( "addq $7, $5, $7 " ); \ ldq $5, 0($2); \
asm( "cmpult $7, $5, $5 " ); \ addq $7, $5, $7; \
asm( "stq $7, 0($2) " ); \ cmpult $7, $5, $5; \
asm( "addq $2, 8, $2 " ); \ stq $7, 0($2); \
asm( "addq $6, $3, $3 " ); \ addq $2, 8, $2; \
asm( "addq $5, $3, $3 " ); addq $6, $3, $3; \
addq $5, $3, $3; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "stq $3, %0 " : "=m" (c)); \ " \
asm( "stq $2, %0 " : "=m" (d)); \ stq $3, %0; \
asm( "stq $1, %0 " : "=m" (s) :: \ stq $2, %1; \
"$1", "$2", "$3", "$4", "$5", "$6", "$7" ); stq $1, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "$1", "$2", "$3", "$4", "$5", "$6", "$7" \
);
#endif /* Alpha */ #endif /* Alpha */
#if defined(__mips__) #if defined(__mips__)
#define MULADDC_INIT \ #define MULADDC_INIT \
asm( "lw $10, %0 " :: "m" (s)); \ asm( \
asm( "lw $11, %0 " :: "m" (d)); \ " \
asm( "lw $12, %0 " :: "m" (c)); \ lw $10, %3; \
asm( "lw $13, %0 " :: "m" (b)); lw $11, %4; \
lw $12, %5; \
lw $13, %6; \
"
#define MULADDC_CORE \ #define MULADDC_CORE \
asm( "lw $14, 0($10) " ); \ " \
asm( "multu $13, $14 " ); \ lw $14, 0($10); \
asm( "addi $10, $10, 4 " ); \ multu $13, $14; \
asm( "mflo $14 " ); \ addi $10, $10, 4; \
asm( "mfhi $9 " ); \ mflo $14; \
asm( "addu $14, $12, $14 " ); \ mfhi $9; \
asm( "lw $15, 0($11) " ); \ addu $14, $12, $14; \
asm( "sltu $12, $14, $12 " ); \ lw $15, 0($11); \
asm( "addu $15, $14, $15 " ); \ sltu $12, $14, $12; \
asm( "sltu $14, $15, $14 " ); \ addu $15, $14, $15; \
asm( "addu $12, $12, $9 " ); \ sltu $14, $15, $14; \
asm( "sw $15, 0($11) " ); \ addu $12, $12, $9; \
asm( "addu $12, $12, $14 " ); \ sw $15, 0($11); \
asm( "addi $11, $11, 4 " ); addu $12, $12, $14; \
addi $11, $11, 4; \
"
#define MULADDC_STOP \ #define MULADDC_STOP \
asm( "sw $12, %0 " : "=m" (c)); \ " \
asm( "sw $11, %0 " : "=m" (d)); \ sw $12, %0; \
asm( "sw $10, %0 " : "=m" (s) :: \ sw $11, %1; \
"$9", "$10", "$11", "$12", "$13", "$14", "$15" ); sw $10, %2; \
" \
: "=m" (c), "=m" (d), "=m" (s) \
: "m" (s), "m" (d), "m" (c), "m" (b) \
: "$9", "$10", "$11", "$12", "$13", "$14", "$15" \
);
#endif /* MIPS */ #endif /* MIPS */
#endif /* GNUC */ #endif /* GNUC */