[PATCH] D16925: [mips] Support LA expansion in PIC mode

Matthew Fortune via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 12:47:47 PST 2016


mpf added a subscriber: mpf.

================
Comment at: lib/Target/Mips/AsmParser/MipsAsmParser.cpp:2485
@@ +2484,3 @@
+            IDLoc, Instructions);
+    if(Sym->isInSection() && !Sym->isExternal())
+       emitRRX(Mips::ADDiu, TmpReg, TmpReg, MCOperand::createExpr(LoExpr),
----------------
The problem here is that you do not know whether a symbol is going to have global or local linkage until the end of the module as the .global directive may appear later. In order to do this you will need to track which symbols are referred to during macro expansion and then at the end of the file check that all the symbols still have the same linkage. If any have changed then raise an error. The restriction you will end up with in LLVM is that a global symbol must be globalized before the first reference to it.

The test cases are:

= global =
.text
foo:
la $4, bar

= local =
.data
bar:
.word 1
.text
foo:
la $4, bar

= global =
.data
.global bar
bar:
.word 1
.text
foo:
la $4, bar


= local (but an error for LLVM) =
.text
foo:
la $4, bar
.data
bar:
.word 1

= global (but an error for LLVM) =
.data
bar:
.word 1
.text
foo:
la $4, bar
.global bar

If the cases which work are sufficient for the codebases you need to support then this is relatively easy to implement. If you need the last two cases to work then there will be a significant amount of framework required as I understand.


http://reviews.llvm.org/D16925





More information about the llvm-commits mailing list