[llvm-dev] Inline ASM ARM syntax to load immediate values with integrated assembler
Emmanuel Blot via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 31 08:48:44 PDT 2018
Hi,
What would be the proper syntax in a C file, using inline assembly, to
load a immediate value into an ARM register using clang & integrated
assembler?
The following syntax is rejected by LLVM:
// clang -target armv7em-none-eabi -mthumb
#define CONSTANT 0x1234
void __attribute__((naked))
foo(void)
{
asm volatile (
"ldr r0, =%0 \n"
:
:
"X" (CONSTANT)
:
"r0"
);
}
“X” transforms the constant into a “#1234”, and LLVM does not seem to
accept “=#1234” syntax. I think the proper syntax should be “ldr r0,
=0x1234”, but I’ve been unable to find a constraint string that would
emit the constant w/o the dash prefix.
The “=%0” syntax is accepted by GCC - I’m not sure it is valid,
although I’m still looking for a comprehensive reference document for
such a syntax.
“mov r0, %0” could work for small encodable value, but not for the
whole 32-bit range where the pseudo-instruction “ldr r0, =constant" is
required.
Thanks.
More information about the llvm-dev
mailing list