[PATCH] D80028: [AArch64] Support expression results as immediate values in mov

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 12:05:59 PDT 2020


efriedma added inline comments.


================
Comment at: llvm/test/MC/AArch64/mov-invalid-expression-as-immediate.s:9
+// CHECK: mov x0, 1b - 0b
+// CHECK: ^
----------------
jcai19 wrote:
> efriedma wrote:
> > jcai19 wrote:
> > > efriedma wrote:
> > > > Please also add a testcase for something like `mov x0, 0b`, where the value can't be resolved in the assembler.
> > > This is actually interesting.  GAS assembled the following code 
> > > 
> > > 0:
> > > .skip 4
> > > 1:
> > > mov x0, 1b
> > > 
> > > into 
> > > 
> > > mov	x0, #0x4 
> > > 
> > > With the proposed change, IAS would calculate the offset (4) correctly but discard it as it considers the expression 1b unresolved, and generate the following code.
> > > 
> > > mov	x0, #0x0
> > > 
> > > What's the expected outcome here? Is subtraction between two symbols the only valid expressions we should accept? Thanks.
> > Converting the address of a label to constant without a relocation is clearly a bug; we shouldn't try to reproduce that behavior.
> > 
> > I think I'd prefer to be conservative and forbid expressions that would require a relocation in the object file, at least for now.  (The user can spell it out with movz/movk if the actually want a relocation.)
> It seems IAS currently replaces all the labels that it cannot fully resolve with 0, like the following example.
> 
> $ cat foo.s
> movz x13, #:abs_g0_s:some_label
> 
> $ llvm-mc -triple=aarch64 -filetype=obj --debug-only=asm-matcher foo.s -o foo.o
> $ aarch64-linux-gnu-objdump -d  foo.o
> foo.o:     file format elf64-littleaarch64
> 
> 
> Disassembly of section .text:
> 
> 0000000000000000 <.text>:
>    0:	d280000d 	mov	x13, #0x0                   	// #0
> 
> Adding the proposed check seemed to break all such cases. Shall we address that in a separate change?
> 
It's not zero, it's a relocation. objdump -dr output:

  0000000000000000 <.text>:
     0:   d280000d        mov     x13, #0x0                       // #0
                          0: R_AARCH64_MOVW_SABS_G0       some_label

I'm suggesting that we forbid emitting relocations specifically for the alias "mov", and allow them if someone requests them with "movz" etc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80028/new/

https://reviews.llvm.org/D80028





More information about the llvm-commits mailing list