ARM: trivial assembly fixes to enable LLVM as
Subsystems (2)
v2 cover ARM: trivial assembly fixes to enable LLVM as
This patchset is a starting point to enable LLVM integrated assembler and contains some trivial changes. With this patchset the LLVM integrated assembler can be used to assemble almost all C files.
Changes since v1:
- Explicitly use unified syntax for inline assembly where necessary
Stefan Agner (3):
ARM: fix argument count to match macro definition
ARM: uaccess: use unified assembler language syntax
ARM: spinlock: use unified assembler language syntax
arch/arm/include/asm/spinlock.h | 3 ++- arch/arm/include/asm/uaccess.h | 3 ++- arch/arm/lib/copy_template.S | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 3/3 ARM: spinlock: use unified assembler language syntax
Convert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified.
This allows to use LLVM's integrated assembler.
---
Changes since v1:
- Explicitly use unified syntax for inline assembly
arch/arm/include/asm/spinlock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/spinlock.h +2 -1
@@ -210,11 +210,12 @@ static inline void arch_read_lock(arch_rwlock_t *rw)prefetchw (&rw->lock); __asm__ __volatile__( +" .syntax unified\n" "1: ldrex %0, [%2]\n" " adds %0, %0, #1\n" " strexpl %1, %0, [%2]\n" WFE("mi") -" rsbpls %0, %1, #0\n" +" rsbspl %0, %1, #0\n" " bmi 1b" : "=&r" (tmp), "=&r" (tmp2) : "r" (&rw->lock)
Signature · 1 line
2.20.1
PATCH v2 2/3 ARM: uaccess: use unified assembler language syntax
In reply to Stefan AgnerConvert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified.
This allows to use LLVM's integrated assembler.
---
Changes since v1:
- Explicitly use unified syntax for inline assembly
arch/arm/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/uaccess.h +2 -1
@@ -86,7 +86,8 @@ static inline void set_fs(mm_segment_t fs)#define __range_ok (addr, size) ({ \ unsigned long flag, roksum; \ __chk_user_ptr(addr); \ - __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \ + __asm__(".syntax unified\n" \ + "adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \ : "=&r" (flag), "=&r" (roksum) \ : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \ : "cc"); \
Signature · 1 line
2.20.1
PATCH v2 1/3 ARM: fix argument count to match macro definition
In reply to Stefan AgnerThe macro str8w takes 10 arguments, abort being the 10th. In this particular instantiation the abort argument is passed as 11th argument leading to an error when using LLVM's integrated assembler:
<instantiation>:46:47: error: too many positional arguments
str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f
^
arch/arm/lib/copy_template.S:277:5: note: while in macro instantiation
18: forward_copy_shift pull=24 push=8
^The argument is not used in the macro hence this does not change code generation.
--- arch/arm/lib/copy_template.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/lib/copy_template.S +1 -1
@@ -241,7 +241,7 @@ orr r9, r9, ip, lspush #\push mov ip, ip, lspull #\pull orr ip, ip, lr, lspush #\push - str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f + str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, abort=19f bge 12b PLD( cmn r2, #96 ) PLD( bge 13b )
Signature · 1 line
2.20.1
Re: [PATCH v2 1/3] ARM: fix argument count to match macro definition
Quoted 11 lines · Stefan Agner
The macro str8w takes 10 arguments, abort being the 10th. In this particular instantiation the abort argument is passed as 11th argument leading to an error when using LLVM's integrated assembler:
<instantiation>:46:47: error: too many positional argumentsstr8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f ^ arch/arm/lib/copy_template.S:277:5: note: while in macro instantiation 18: forward_copy_shift pull=24 push=8 ^
Quoted 4 lines
The argument is not used in the macro hence this does not change code generation.
Signed-off-by Stefan Agner <[email protected]>
Quoted 21 lines
--- arch/arm/lib/copy_template.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/lib/copy_template.S +1
-1@@ -241,7 +241,7 @@ orr r9, r9, ip, lspush #\push mov ip, ip, lspull #\pull orr ip, ip, lr, lspush #\push - str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f + str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, abort=19f bge 12b PLD( cmn r2, #96 ) PLD( bge 13b )Signature · 1 line
2.20.1
Re: [PATCH v2 2/3] ARM: uaccess: use unified assembler language syntax
In reply to Stefan AgnerQuoted 21 lines · Stefan Agner
Convert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified.
This allows to use LLVM's integrated assembler.
Signed-off-by Stefan Agner <[email protected]>---
Changes since v1:
- Explicitly use unified syntax for inline assemblyarch/arm/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm/include/asm/uaccess.h +0
-0
arch/arm/include/asm/uaccess.h static inline void set_fs(mm_segment_t fs) · line 90
Quoted 6 lines
arch/arm/include/asm/uaccess.h +2
-1@@ -86,7 +86,8 @@ static inline void set_fs(mm_segment_t fs)#define __range_ok (addr, size) ({ \ unsigned long flag, roksum; \ __chk_user_ptr(addr); \ - __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \ + __asm__(".syntax unified\n" \ + "adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \
Instead of sprinkling ".syntax unified" around, you could consider including <asm/unified.h> when needed.
Nicolas
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 3/3] ARM: spinlock: use unified assembler language syntax
In reply to Stefan AgnerQuoted 6 lines · Stefan Agner
Convert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified.
This allows to use LLVM's integrated assembler.
Same comment as for patch 2/3.
Quoted 32 lines
Signed-off-by Stefan Agner <[email protected]>---
Changes since v1:
- Explicitly use unified syntax for inline assemblyarch/arm/include/asm/spinlock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm/include/asm/spinlock.h +2
-1@@ -210,11 +210,12 @@ static inline void arch_read_lock(arch_rwlock_t *rw)prefetchw (&rw->lock); __asm__ __volatile__( +" .syntax unified\n" "1: ldrex %0, [%2]\n" " adds %0, %0, #1\n" " strexpl %1, %0, [%2]\n" WFE("mi") -" rsbpls %0, %1, #0\n" +" rsbspl %0, %1, #0\n" " bmi 1b" : "=&r" (tmp), "=&r" (tmp2) : "r" (&rw->lock)Signature · 1 line
2.20.1
Re: [PATCH v2 2/3] ARM: uaccess: use unified assembler language syntax
In reply to Nicolas PitreQuoted 18 lines · Nicolas Pitre
Quoted 16 lines · Stefan Agner
Convert the conditional infix to a postfix to make sure this inline assembly is unified syntax. Since gcc assumes non-unified syntax when emitting ARM instructions, make sure to define the syntax as unified.
This allows to use LLVM's integrated assembler.
Signed-off-by Stefan Agner <[email protected]>---
Changes since v1:
- Explicitly use unified syntax for inline assemblyarch/arm/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
arch/arm/include/asm/uaccess.h static inline void set_fs(mm_segment_t fs) · line 90
Quoted 11 lines
arch/arm/include/asm/uaccess.h +2
-1@@ -86,7 +86,8 @@ static inline void set_fs(mm_segment_t fs)#define __range_ok (addr, size) ({ \ unsigned long flag, roksum; \ __chk_user_ptr(addr); \ - __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \ + __asm__(".syntax unified\n" \ + "adds %1, %2, %3; sbcscc %1, %1, %0; movcc %0, #0" \Instead of sprinkling ".syntax unified" around, you could consider including <
asm/unified.h> when needed.
This seems not to help in this case. When I include <asm/unified.h> at the beginning of uaccess.h GCC still seems to emit ".syntax unified".
I guess this is since we are dealing with inline assembly. As far as I understand its really gcc which emits a ".syntax divided" by default when compiling ARM mode. There is an option "-masm-syntax-unified" which according to the gcc man page should do what we need, but it seems broken, see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88648
I agree this patch is not particularly pretty, but it is the only solution I found to make this inline assembly work with gcc and Clang.
--
Stefan