mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-03 14:21:30 +00:00
[mips] [IAS] Fix LA with relative label operands.
Summary:
Call MCSymbolRefExpr::create() with a MCSymbol* argument, not with a StringRef
of the Symbol's name, in order to avoid creating invalid temporary symbols for
relative labels (e.g. {$,.L}tmp00, {$,.L}tmp10 etc.).
Reviewers: dsanders
Reviewed By: dsanders
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10498
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239901 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1963,12 +1963,11 @@ bool MipsAsmParser::loadSymbolAddress(const MCExpr *SymExpr, unsigned DstReg,
|
|||||||
|
|
||||||
MCInst tmpInst;
|
MCInst tmpInst;
|
||||||
const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymExpr);
|
const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymExpr);
|
||||||
const MCSymbolRefExpr *HiExpr =
|
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
|
||||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
|
||||||
MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
|
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create(
|
||||||
const MCSymbolRefExpr *LoExpr =
|
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_ABS_LO, getContext());
|
||||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
|
||||||
MCSymbolRefExpr::VK_Mips_ABS_LO, getContext());
|
|
||||||
if (!Is32BitSym) {
|
if (!Is32BitSym) {
|
||||||
// If it's a 64-bit architecture, expand to:
|
// If it's a 64-bit architecture, expand to:
|
||||||
// la d,sym => lui d,highest(sym)
|
// la d,sym => lui d,highest(sym)
|
||||||
@@ -1977,12 +1976,10 @@ bool MipsAsmParser::loadSymbolAddress(const MCExpr *SymExpr, unsigned DstReg,
|
|||||||
// ori d,d,hi16(sym)
|
// ori d,d,hi16(sym)
|
||||||
// dsll d,d,16
|
// dsll d,d,16
|
||||||
// ori d,d,lo16(sym)
|
// ori d,d,lo16(sym)
|
||||||
const MCSymbolRefExpr *HighestExpr =
|
const MCSymbolRefExpr *HighestExpr = MCSymbolRefExpr::create(
|
||||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
|
||||||
MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
|
const MCSymbolRefExpr *HigherExpr = MCSymbolRefExpr::create(
|
||||||
const MCSymbolRefExpr *HigherExpr =
|
&Symbol->getSymbol(), MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
|
||||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
|
||||||
MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
|
|
||||||
|
|
||||||
tmpInst.setOpcode(Mips::LUi);
|
tmpInst.setOpcode(Mips::LUi);
|
||||||
tmpInst.addOperand(MCOperand::createReg(DstReg));
|
tmpInst.addOperand(MCOperand::createReg(DstReg));
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
|
# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
|
||||||
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
|
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
|
||||||
# CHECK: addu $7, $7, $8 # encoding: [0x21,0x38,0xe8,0x00]
|
# CHECK: addu $7, $7, $8 # encoding: [0x21,0x38,0xe8,0x00]
|
||||||
|
la $8, 1f
|
||||||
|
# CHECK: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c]
|
||||||
|
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
|
||||||
|
# CHECK: ori $8, $8, %lo($tmp0) # encoding: [A,A,0x08,0x35]
|
||||||
|
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
|
||||||
la $8, symbol
|
la $8, symbol
|
||||||
# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
|
# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
|
||||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
||||||
|
|||||||
Reference in New Issue
Block a user