@@ -442,6 +442,13 @@ static inline void
"adc %3, %0"
: "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
: "rm"(b0), "rm"(b1), "rm"(b2), "0"(a0), "1"(a1), "2"(a2));
+#elif defined(__aarch64__)
+ asm("adds %2, %x5, %x8\n\t"
+ "adcs %1, %x4, %x7\n\t"
+ "adc %0, %x3, %x6"
+ : "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
+ : "rZ"(a0), "rZ"(a1), "rZ"(a2), "rZ"(b0), "rZ"(b1), "rZ"(b2)
+ : "cc");
#else
uint64_t z0, z1, z2;
int8_t carry0, carry1;
@@ -507,6 +514,13 @@ static inline void
"sbb %3, %0"
: "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
: "rm"(b0), "rm"(b1), "rm"(b2), "0"(a0), "1"(a1), "2"(a2));
+#elif defined(__aarch64__)
+ asm("subs %2, %x5, %x8\n\t"
+ "sbcs %1, %x4, %x7\n\t"
+ "sbc %0, %x3, %x6"
+ : "=&r"(*z0Ptr), "=&r"(*z1Ptr), "=&r"(*z2Ptr)
+ : "rZ"(a0), "rZ"(a1), "rZ"(a2), "rZ"(b0), "rZ"(b1), "rZ"(b2)
+ : "cc");
#else
uint64_t z0, z1, z2;
int8_t borrow0, borrow1;
@@ -7358,6 +7358,18 @@ static void sub256(UInt256 *r, UInt256 *a, UInt256 *b)
: "=&r"(r->w[0]), "=&r"(r->w[1]), "=&r"(r->w[2]), "=&r"(r->w[3])
: "rme"(b->w[0]), "rme"(b->w[1]), "rme"(b->w[2]), "rme"(b->w[3]),
"0"(a->w[0]), "1"(a->w[1]), "2"(a->w[2]), "3"(a->w[3]));
+#elif defined(__aarch64__)
+ asm("subs %[r3], %x[a3], %x[b3]\n\t"
+ "sbcs %[r2], %x[a2], %x[b2]\n\t"
+ "sbcs %[r1], %x[a1], %x[b1]\n\t"
+ "sbc %[r0], %x[a0], %x[b0]"
+ : [r0] "=&r"(r->w[0]), [r1] "=&r"(r->w[1]),
+ [r2] "=&r"(r->w[2]), [r3] "=&r"(r->w[3])
+ : [a0] "rZ"(a->w[0]), [a1] "rZ"(a->w[1]),
+ [a2] "rZ"(a->w[2]), [a3] "rZ"(a->w[3]),
+ [b0] "rZ"(b->w[0]), [b1] "rZ"(b->w[1]),
+ [b2] "rZ"(b->w[2]), [b3] "rZ"(b->w[3])
+ : "cc");
#else
bool borrow = false;
@@ -7388,6 +7400,13 @@ static void neg256(UInt256 *a)
: "=&r"(a->w[0]), "=&r"(a->w[1]), "=&r"(a->w[2]), "+rm"(a->w[3])
: "rme"(a->w[0]), "rme"(a->w[1]), "rme"(a->w[2]),
"0"(0), "1"(0), "2"(0));
+#elif defined(__aarch64__)
+ asm("negs %3, %3\n\t"
+ "ngcs %2, %2\n\t"
+ "ngcs %1, %1\n\t"
+ "ngc %0, %0"
+ : "+r"(a->w[0]), "+r"(a->w[1]), "+r"(a->w[2]), "+r"(a->w[3])
+ : : "cc");
#else
/*
* Recall that -X - 1 = ~X, and that since this is negation,
@@ -7430,6 +7449,14 @@ static void add256(UInt256 *a, UInt256 *b)
"adc %4, %0"
: "+r"(a->w[0]), "+r"(a->w[1]), "+r"(a->w[2]), "+r"(a->w[3])
: "rme"(b->w[0]), "rme"(b->w[1]), "rme"(b->w[2]), "rme"(b->w[3]));
+#elif defined(__aarch64__)
+ asm("adds %3, %3, %x7\n\t"
+ "adcs %2, %2, %x6\n\t"
+ "adcs %1, %1, %x5\n\t"
+ "adc %0, %0, %x4"
+ : "+r"(a->w[0]), "+r"(a->w[1]), "+r"(a->w[2]), "+r"(a->w[3])
+ : "rZ"(b->w[0]), "rZ"(b->w[1]), "rZ"(b->w[2]), "rZ"(b->w[3])
+ : "cc");
#else
bool carry = false;
The compiler cannot chain more than two additions together. Use inline assembly for 3 or 4 additions. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- include/fpu/softfloat-macros.h | 14 ++++++++++++++ fpu/softfloat.c | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)