Skip to content

Clang's assembler doesn't ignore extraneous "#" characters in ARM inline assembly. #20491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
llvmbot opened this issue Jun 24, 2014 · 2 comments
Labels
backend:ARM bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2014

Bugzilla Link 20117
Version trunk
OS Linux
Blocks #19300
Reporter LLVM Bugzilla Contributor
CC @kbeyls,@rengolin

Extended Description

I'm using Clang as packaged by Ubuntu: Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)
This doesn't seem to agree with the available options in the 'version' field.


Consider the following test function:

int test(void) {
int out;
asm(" ldr %0, =%1\n" : "=r" (out) : "i" (0x000f0002));
return out;
}

The instruction generated by the inline assembly is "ldr r0, =#983042", since "i" constraints get a leading hash character by default. The GNU assembler ignores this character, but Clang does not:

test.c:4:7: error: unknown token in expression
asm(" ldr %0, =%1\n" : "=r" (out) : "i" (0x000f0002));
^
:1:13: note: instantiated into assembly here
ldr r0, =#983042
^
1 error generated.

GCC has an (undocumented) substitution predicate which causes the hash character to be omitted ("ldr %0, =%c1"), and Clang appears to support this, but this still represents an incompatibility with GCC and therefore might be considered a bug.

@llvmbot
Copy link
Member Author

llvmbot commented Jun 24, 2014

I'm using Clang as packaged by Ubuntu: Ubuntu clang version 3.5-1ubuntu1
(trunk) (based on LLVM 3.5)
This doesn't seem to agree with the available options in the 'version' field.

Perhaps I was wrong about that, if Ubuntu have packaged a version from Clang's trunk.

@llvmbot
Copy link
Member Author

llvmbot commented Aug 23, 2014

I found that GAS ARM Machine Directive ".syntax unified"
responsible for successful compilation
ldr r0, =#983042

9.4.2.1 Instruction Set Syntax
...
The new, unified syntax, which can be selected via the .syntax directive,
and has the following main features:
Immediate operands do not require a # prefix.
...
So, it's really undocumented.
We have excessive #

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

1 participant