[PATCH] D39062: [MIPS] Don't assert when attempting to expand ld/sd macro with symbol reference

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 05:07:13 PDT 2017


sdardis 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
----------------
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?


https://reviews.llvm.org/D39062





More information about the llvm-commits mailing list