[LLVMdev] Implementing the ldr pseudo instruction in ARM integrated assembler

David Peixotto dpeixott at codeaurora.org
Fri Nov 1 11:16:27 PDT 2013


In an earlier email[1] I proposed adding support for the ldr
pseud-instruction to the ARM integrated assembler. After some discussion the
overall consensus seemed to be that it was worth adding. One concern was
that we needed to have adequate testing. I promised to provide more details
on what the behavior should be and provide some tests before starting the
implementation. The FileCheck-ified tests are attached to this email. They
currently pass when using gcc to assemble the test.

Here are the specific behaviors that are checked in the test:

1. Check that constants that fit into imm12 are converted to mov
    ldr r0, =0x3
2. Check that large constants are converted to ldr from constant pool
    ldr r0, =0x103
3. Duplicate constants should be merged to the same constant pool location
    ldr r0, =0x103
    ...
    ldr r0, =0x103
4. A section defined in multiple pieces is merged and uses a single constant
pool
    For example,
    
    .section e, "ax", %progbits
      f6:
        ldr r0, =0x103
    .section f, "ax", %progbits
      f7: add r0, r0, r0
    .section e, "ax", %progbits
      f8:
        add r0, r0, r0
        ldr r0, =0x105

    should only produce one constant pool for section e.

5. Check that symbols can be loaded using ldr pseudo
  ldr r0, =foo

6. Check that ldr pseudo can be used with expressions
  ldr r0, =0x101+6
  ldr r0, =bar+4

7. Check that it is used correctly in a macro
    .macro useit_in_a_macro
      ldr r0, =0x101
      ldr r0, =bar
    .endm
    .section k, "ax", %progbits
    f14:
      useit_in_a_macro

8. Check that an error is issued when the constant pool would be placed too
far away
  ldr r0, =0x101
  @... lots of instructions
  Error: invalid literal constant: pool needs to be closer

I have not yet looked into the code to see where/how this feature can be
implemented. Any pointers or feedback is welcome. I've filed a Bug[2] to
track this issue.

[1]: http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-October/066808.html
[2]: http://llvm.org/bugs/show_bug.cgi?id=17769

-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
by The Linux Foundation



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldr_pseudo.s
Type: application/octet-stream
Size: 4328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131101/f3dd6cc3/attachment.obj>


More information about the llvm-dev mailing list