]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
ARM: Use own lj_bswap(). Reduce min. req. version of GCC to 4.2.
authorMike Pall <mike>
Thu, 28 Apr 2011 10:33:31 +0000 (12:33 +0200)
committerMike Pall <mike>
Thu, 28 Apr 2011 10:33:31 +0000 (12:33 +0200)
doc/install.html
src/lj_arch.h
src/lj_def.h

index 12f28d4fd86f984be47ab8caa61ad8a5d8cd704a..de934abc2d45945336500976cd89dbc882ccff68 100644 (file)
@@ -123,8 +123,8 @@ operating system, CPU and compilers:
 </tr>
 <tr class="odd">
 <td class="compatcpu">ARM</td>
-<td class="compatos">GCC 4.3+</td>
-<td class="compatos">GCC 4.3+</td>
+<td class="compatos">GCC 4.2+</td>
+<td class="compatos">GCC 4.2+</td>
 <td class="compatos compatno">&nbsp;</td>
 <td class="compatos compatno">&nbsp;</td>
 </tr>
index 3ddc3e4644aa4a6652f86326b7996800ba58981b..f179cf80a5554eb745786dcd9475d4c2078c5578 100644 (file)
 #if __GNUC__ < 4
 #error "Need at least GCC 4.0 or newer"
 #endif
-#elif LJ_TARGET_ARM || LJ_TARGET_PPC
+#elif LJ_TARGET_ARM
+#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
+#error "Need at least GCC 4.2 or newer"
+#endif
+#elif LJ_TARGET_PPC
 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
 #error "Need at least GCC 4.3 or newer"
 #endif
index b7df86068a64ed3334c5a679ce6c8955479867f5..c60bc118f7f6e1edf5cdd978b8eb96778a3eecf7 100644 (file)
@@ -131,7 +131,29 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
 #define lj_fls(x)      ((uint32_t)(__builtin_clz(x)^31))
 #endif
 
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#if defined(__arm__)
+static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
+{
+  uint32_t r;
+#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\
+    __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
+  __asm__("rev %0, %1" : "=r" (r) : "r" (x));
+  return r;
+#else
+#ifdef __thumb__
+  r = x ^ lj_ror(x, 16);
+#else
+  __asm__("eor %0, %1, %1, ror #16" : "=r" (r) : "r" (x));
+#endif
+  return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8);
+#endif
+}
+
+static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
+{
+  return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32));
+}
+#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
 {
   return (uint32_t)__builtin_bswap32((int32_t)x);