Browse code

ARM: simplify inline asm with 64-bit operands

Signed-off-by: Mans Rullgard <mans@mansr.com>

Mans Rullgard authored on 2011/05/31 00:37:06
Showing 2 changed files
... ...
@@ -59,19 +59,16 @@ static inline av_const int MULH(int a, int b)
59 59
 
60 60
 static inline av_const int64_t MUL64(int a, int b)
61 61
 {
62
-    union { uint64_t x; unsigned hl[2]; } x;
63
-    __asm__ ("smull %0, %1, %2, %3"
64
-             : "=r"(x.hl[0]), "=r"(x.hl[1]) : "r"(a), "r"(b));
65
-    return x.x;
62
+    int64_t x;
63
+    __asm__ ("smull %Q0, %R0, %1, %2" : "=r"(x) : "r"(a), "r"(b));
64
+    return x;
66 65
 }
67 66
 #define MUL64 MUL64
68 67
 
69 68
 static inline av_const int64_t MAC64(int64_t d, int a, int b)
70 69
 {
71
-    union { uint64_t x; unsigned hl[2]; } x = { d };
72
-    __asm__ ("smlal %0, %1, %2, %3"
73
-             : "+r"(x.hl[0]), "+r"(x.hl[1]) : "r"(a), "r"(b));
74
-    return x.x;
70
+    __asm__ ("smlal %Q0, %R0, %1, %2" : "+r"(d) : "r"(a), "r"(b));
71
+    return d;
75 72
 }
76 73
 #define MAC64(d, a, b) ((d) = MAC64(d, a, b))
77 74
 #define MLS64(d, a, b) MAC64(d, -(a), b)
... ...
@@ -55,22 +55,21 @@ static av_always_inline void AV_WN32(void *p, uint32_t v)
55 55
 #define AV_RN64 AV_RN64
56 56
 static av_always_inline uint64_t AV_RN64(const void *p)
57 57
 {
58
-    union { uint64_t v; uint32_t hl[2]; } v;
59
-    __asm__ ("ldr   %0, %2  \n\t"
60
-             "ldr   %1, %3  \n\t"
61
-             : "=&r"(v.hl[0]), "=r"(v.hl[1])
58
+    uint64_t v;
59
+    __asm__ ("ldr   %Q0, %1  \n\t"
60
+             "ldr   %R0, %2  \n\t"
61
+             : "=&r"(v)
62 62
              : "m"(*(const uint32_t*)p), "m"(*((const uint32_t*)p+1)));
63
-    return v.v;
63
+    return v;
64 64
 }
65 65
 
66 66
 #define AV_WN64 AV_WN64
67 67
 static av_always_inline void AV_WN64(void *p, uint64_t v)
68 68
 {
69
-    union { uint64_t v; uint32_t hl[2]; } vv = { v };
70
-    __asm__ ("str  %2, %0  \n\t"
71
-             "str  %3, %1  \n\t"
69
+    __asm__ ("str  %Q2, %0  \n\t"
70
+             "str  %R2, %1  \n\t"
72 71
              : "=m"(*(uint32_t*)p), "=m"(*((uint32_t*)p+1))
73
-             : "r"(vv.hl[0]), "r"(vv.hl[1]));
72
+             : "r"(v));
74 73
 }
75 74
 
76 75
 #endif /* HAVE_INLINE_ASM */