[PATCH] [mips] [IAS] Fix expansion of LASym with positive offset.
Toma Tabacu
toma.tabacu at imgtec.com
Mon May 18 05:48:03 PDT 2015
Rebased.
http://reviews.llvm.org/D9344
Files:
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
test/MC/Mips/mips-expansions.s
Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp
===================================================================
--- lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -1942,27 +1942,20 @@
MCInst tmpInst;
unsigned RegNo = DstRegOp.getReg();
- const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymOp.getExpr());
- const MCSymbolRefExpr *HiExpr =
- MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
- MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
- const MCSymbolRefExpr *LoExpr =
- MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
- MCSymbolRefExpr::VK_Mips_ABS_LO, getContext());
+
+ const MCExpr *HiExpr = evaluateRelocExpr(SymOp.getExpr(), "hi");
+ const MCExpr *LoExpr = evaluateRelocExpr(SymOp.getExpr(), "lo");
+
if (!Is32BitSym) {
// If it's a 64-bit architecture, expand to:
// la d,sym => lui d,highest(sym)
// ori d,d,higher(sym)
// dsll d,d,16
// ori d,d,hi16(sym)
// dsll d,d,16
// ori d,d,lo16(sym)
- const MCSymbolRefExpr *HighestExpr =
- MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
- MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
- const MCSymbolRefExpr *HigherExpr =
- MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
- MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
+ const MCExpr *HighestExpr = evaluateRelocExpr(SymOp.getExpr(), "highest");
+ const MCExpr *HigherExpr = evaluateRelocExpr(SymOp.getExpr(), "higher");
tmpInst.setOpcode(Mips::LUi);
tmpInst.addOperand(MCOperand::createReg(RegNo));
Index: test/MC/Mips/mips-expansions.s
===================================================================
--- test/MC/Mips/mips-expansions.s
+++ test/MC/Mips/mips-expansions.s
@@ -25,6 +25,23 @@
# fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
# CHECK: ori $8, $8, %lo(symbol) # encoding: [A,A,0x08,0x35]
# fixup A - offset: 0, value: symbol at ABS_LO, kind: fixup_Mips_LO16
+# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
+# CHECK: ori $8, $8, %lo(symbol+1) # encoding: [0x01'A',A,0x08,0x35]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_LO, kind: fixup_Mips_LO16
+# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
+# CHECK: ori $8, $8, %lo(symbol-32766) # encoding: [0x02'A',0x80'A',0x08,0x35]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_LO, kind: fixup_Mips_LO16
+# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
+# CHECK: ori $8, $8, %lo(symbol+2) # encoding: [0x02'A',A,0x08,0x35]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_LO, kind: fixup_Mips_LO16
+# CHECK: lui $8, %hi(symbol+1) # encoding: [0x01'A',A,0x08,0x3c]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
+# CHECK: ori $8, $8, %lo(symbol+4369) # encoding: [0x11'A',0x11'A',0x08,0x35]
+# CHECK: # fixup A - offset: 0, value: symbol at ABS_LO, kind: fixup_Mips_LO16
+
# CHECK: lui $10, %hi(symbol) # encoding: [A,A,0x0a,0x3c]
# CHECK: # fixup A - offset: 0, value: symbol at ABS_HI, kind: fixup_Mips_HI16
# CHECK: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01]
@@ -70,6 +87,10 @@
la $a0, 20($a1)
la $7,65538($8)
la $t0, symbol
+ la $8, symbol+1
+ la $8, symbol+32770
+ la $8, symbol+65538
+ la $8, symbol+0x11111
.set noat
lw $t2, symbol($a0)
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9344.25959.patch
Type: text/x-patch
Size: 4210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150518/51d428da/attachment.bin>
More information about the llvm-commits
mailing list