[LLVMdev] Support for delayed constants in ARM integrated assembler

David Peixotto dpeixott at codeaurora.org
Tue Dec 10 14:12:18 PST 2013


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







More information about the llvm-dev mailing list