freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] [PATCH] Fix thumb2 inline assembly under LLVM.


From: Chongyu Zhu
Subject: [ft-devel] [PATCH] Fix thumb2 inline assembly under LLVM.
Date: Mon, 23 Sep 2013 16:59:47 +0800

When using 'ADD' with an immediate operand, the instruction
is actually 'ADD Rd, Rn, #<imm12>', that is, the maximum of
the immediate operand cannot exceed 4095. It will fail to
compile with LLVM.

However, in GCC, due to some legacy compatibility considerations,
'ADD.W' will be automatically emitted when the immediate operand
is larger than 4095.
---
 builds/unix/ftconfig.in            | 4 ++++
 include/freetype/config/ftconfig.h | 4 ++++
 src/truetype/ttinterp.c            | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index d2f3cd5..d355bd3 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -419,7 +419,11 @@ FT_BEGIN_HEADER
     __asm__ __volatile__ (
       "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
       "mov    %0, %2, asr #31\n\t"      /* %0  = (hi >> 31) */
+#ifdef __clang__
+      "add.w  %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#else /* __clang__ */
       "add    %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#endif /* __clang__ */
       "adds   %1, %1, %0\n\t"           /* %1 += %0 */
       "adc    %2, %2, #0\n\t"           /* %2 += carry */
       "mov    %0, %1, lsr #16\n\t"      /* %0  = %1 >> 16 */
diff --git a/include/freetype/config/ftconfig.h 
b/include/freetype/config/ftconfig.h
index 9c32256..98d02ef 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -386,7 +386,11 @@ FT_BEGIN_HEADER
     __asm__ __volatile__ (
       "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
       "mov    %0, %2, asr #31\n\t"      /* %0  = (hi >> 31) */
+#ifdef __clang__
+      "add.w  %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#else /* __clang__ */
       "add    %0, %0, #0x8000\n\t"      /* %0 += 0x8000 */
+#endif /* __clang__ */
       "adds   %1, %1, %0\n\t"           /* %1 += %0 */
       "adc    %2, %2, #0\n\t"           /* %2 += carry */
       "mov    %0, %1, lsr #16\n\t"      /* %0  = %1 >> 16 */
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 14854d9..a296f2a 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -1470,7 +1470,11 @@
     __asm__ __volatile__ (
       "smull  %1, %2, %4, %3\n\t"       /* (lo=%1,hi=%2) = a*b */
       "mov    %0, %2, asr #31\n\t"      /* %0  = (hi >> 31) */
+#ifdef __clang__
+      "add.w  %0, %0, #0x2000\n\t"      /* %0 += 0x2000 */
+#else /* __clang__ */
       "add    %0, %0, #0x2000\n\t"      /* %0 += 0x2000 */
+#endif /* __clang__ */
       "adds   %1, %1, %0\n\t"           /* %1 += %0 */
       "adc    %2, %2, #0\n\t"           /* %2 += carry */
       "mov    %0, %1, lsr #14\n\t"      /* %0  = %1 >> 16 */
-- 
1.8.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]