[PATCH] D39062: [MIPS] Don't assert when attempting to expand ld/sd macro with symbol reference
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 05:14:48 PDT 2017
arichardson added inline comments.
================
Comment at: test/MC/Mips/macro-sd.s:15-16
+# These are not expected to work:
+sd $6, fenvp # ERR: macro-sd.s:[[@LINE]]:1: error: offset for sd macro is not an immediate
+ld $6, fenvp # ERR: macro-sd.s:[[@LINE]]:1: error: offset for ld macro is not an immediate
+.else
----------------
sdardis wrote:
> GAS actually accepts this syntax. Rather than rejecting it, we could improve the parser to accept symbols for this macro.
>
> GAS expands the macro like so for static:
>
> 0: 3c010000 lui at,0x0
> 0: R_MIPS_HI16 fenvp
> 4: ac260000 sw a2,0(at)
> 4: R_MIPS_LO16 fenvp
> 8: ac270004 sw a3,4(at)
>
> and for PIC:
>
> 0: 8f810000 lw at,0(gp)
> 0: R_MIPS_GOT16 fenvp
> 4: ac260000 sw a2,0(at)
> 8: ac270004 sw a3,4(at)
>
>
> If you look at parseMemOperand, you'll see some special handling for la and dla, and some generic handling which produces a operand which becomes malformed when rendered. (It's supposed to be register zero but it isn't). If the operand was parsed+rendered properly, the expansion for SDMacro and LDMacro could be extended to generate the initial offset in $at.
>
> Could you take a look at that approach?
I had a quick look at this but it is not entirely clear to me what parseMemOperand() should be creating in the case of a symbol reference. It gives a MCSymbolReference which should be correct? Or do I need to convert it to a Mips specific expression?
I also noticed that the `sd`, `sw` operations with a symbol reference produce wrong values when used in N64: They only give one %hi/%lo which might not be enough to address the target symbol (this is actually the real issue I was investigating when I found this crash).
https://reviews.llvm.org/D39062
More information about the llvm-commits
mailing list