David Peixotto
2013-Dec-10 22:12 UTC
[LLVMdev] Support for delayed constants in ARM integrated assembler
I have some assembly code that uses .equ to set a symbol to a computed constant. It works in GCC but not LLVM. I am not sure about the correct terminology, but here is an example: .syntax unified .set size, end - start add r0, r0, #size start: .space 0x10 end: GCC will compile this to `add r0, r0, #16`. Compiling with llvm-mc gives: set.s:4:13: error: invalid operand for instruction add r0, r0, #size ^ It works for llvm-mc if the #size is set to a constant (e.g. .set size, 0x10). I took a quick shot at implementing this for llvm. I had some success by allowing an MCExpr to impersonate a constant and then using a MCFixup to write the actual constant value later. I am not sure if this is the best approach for implementing this feature. What do others think? Is this a feature we can support for ARM? Can we (should we?) do it in a target-independent way? (filed bug http://llvm.org/bugs/show_bug.cgi?id=18202) -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Renato Golin
2013-Dec-11 10:44 UTC
[LLVMdev] Support for delayed constants in ARM integrated assembler
Hi David, I agree we should support this. I've added a few more cases in the bug itself. cheers, --renato On 10 December 2013 22:12, David Peixotto <dpeixott at codeaurora.org> wrote:> I have some assembly code that uses .equ to set a symbol to a computed > constant. It works in GCC but not LLVM. I am not sure about the correct > terminology, but here is an example: > > .syntax unified > .set size, end - start > add r0, r0, #size > > start: > .space 0x10 > end: > > GCC will compile this to `add r0, r0, #16`. Compiling with llvm-mc gives: > > set.s:4:13: error: invalid operand for instruction > add r0, r0, #size > ^ > It works for llvm-mc if the #size is set to a constant (e.g. .set size, > 0x10). > > I took a quick shot at implementing this for llvm. I had some success by > allowing an MCExpr to impersonate a constant and then using a MCFixup to > write the actual constant value later. I am not sure if this is the best > approach for implementing this feature. > > What do others think? Is this a feature we can support for ARM? Can we > (should we?) do it in a target-independent way? > > (filed bug http://llvm.org/bugs/show_bug.cgi?id=18202) > -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted > by The Linux Foundation > > > >
Possibly Parallel Threads
- [LLVMdev] Implementing the ldr pseudo instruction in ARM integrated assembler
- [LLVMdev] Implementing the ldr pseudo instruction in ARM integrated assembler
- [LLVMdev] Add support for ldr pseudo instruction in ARM integrated assembler
- [LLVMdev] Add support for ldr pseudo instruction in ARM integrated assembler
- [LLVMdev] Add support for ldr pseudo instruction in ARM integrated assembler