mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
[mips] [IAS] Fix LW with relative label operands.
Summary: Previously, MCSymbolRefExpr::create() was called with a StringRef of the symbol name, which it would then search for in the Symbols StringMap (from MCContext). However, relative labels (which are temporary symbols) are apparently not stored in the Symbols StringMap, so we end up creating a new {$,.L}tmp symbol ({$,.L}tmp00, {$,.L}tmp10 etc.) each time we create an MCSymbolRefExpr by passing in the symbol name as a StringRef. Fortunately, there is a version of MCSymbolRefExpr::create() which takes an MCSymbol* and we already have an MCSymbol* at that point, so we can just pass that in instead of the StringRef. I also removed the local StringRef calls to MCSymbolRefExpr::create() from expandMemInst(), as those cases can be handled by evaluateRelocExpr() anyway. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9938 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239897 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a066970605
commit
e7684db38f
@ -2105,7 +2105,6 @@ bool MipsAsmParser::expandBranchImm(MCInst &Inst, SMLoc IDLoc,
|
||||
void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc,
|
||||
SmallVectorImpl<MCInst> &Instructions,
|
||||
bool isLoad, bool isImmOpnd) {
|
||||
const MCSymbolRefExpr *SR;
|
||||
MCInst TempInst;
|
||||
unsigned ImmOffset, HiOffset, LoOffset;
|
||||
const MCExpr *ExprOffset;
|
||||
@ -2172,16 +2171,8 @@ void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc,
|
||||
if (isImmOpnd)
|
||||
TempInst.addOperand(MCOperand::createImm(HiOffset));
|
||||
else {
|
||||
if (ExprOffset->getKind() == MCExpr::SymbolRef) {
|
||||
SR = static_cast<const MCSymbolRefExpr *>(ExprOffset);
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
|
||||
SR->getSymbol().getName(), MCSymbolRefExpr::VK_Mips_ABS_HI,
|
||||
getContext());
|
||||
TempInst.addOperand(MCOperand::createExpr(HiExpr));
|
||||
} else {
|
||||
const MCExpr *HiExpr = evaluateRelocExpr(ExprOffset, "hi");
|
||||
TempInst.addOperand(MCOperand::createExpr(HiExpr));
|
||||
}
|
||||
const MCExpr *HiExpr = evaluateRelocExpr(ExprOffset, "hi");
|
||||
TempInst.addOperand(MCOperand::createExpr(HiExpr));
|
||||
}
|
||||
// Add the instruction to the list.
|
||||
Instructions.push_back(TempInst);
|
||||
@ -2204,15 +2195,8 @@ void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc,
|
||||
if (isImmOpnd)
|
||||
TempInst.addOperand(MCOperand::createImm(LoOffset));
|
||||
else {
|
||||
if (ExprOffset->getKind() == MCExpr::SymbolRef) {
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create(
|
||||
SR->getSymbol().getName(), MCSymbolRefExpr::VK_Mips_ABS_LO,
|
||||
getContext());
|
||||
TempInst.addOperand(MCOperand::createExpr(LoExpr));
|
||||
} else {
|
||||
const MCExpr *LoExpr = evaluateRelocExpr(ExprOffset, "lo");
|
||||
TempInst.addOperand(MCOperand::createExpr(LoExpr));
|
||||
}
|
||||
const MCExpr *LoExpr = evaluateRelocExpr(ExprOffset, "lo");
|
||||
TempInst.addOperand(MCOperand::createExpr(LoExpr));
|
||||
}
|
||||
Instructions.push_back(TempInst);
|
||||
TempInst.clear();
|
||||
@ -2642,7 +2626,7 @@ const MCExpr *MipsAsmParser::evaluateRelocExpr(const MCExpr *Expr,
|
||||
|
||||
if (const MCSymbolRefExpr *MSRE = dyn_cast<MCSymbolRefExpr>(Expr)) {
|
||||
// It's a symbol, create a symbolic expression from the symbol.
|
||||
StringRef Symbol = MSRE->getSymbol().getName();
|
||||
const MCSymbol *Symbol = &MSRE->getSymbol();
|
||||
MCSymbolRefExpr::VariantKind VK = getVariantKind(RelocStr);
|
||||
Res = MCSymbolRefExpr::create(Symbol, VK, getContext());
|
||||
return Res;
|
||||
|
@ -55,6 +55,12 @@
|
||||
# CHECK: sw $10, %lo(symbol)($1) # encoding: [A,A,0x2a,0xac]
|
||||
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
||||
|
||||
lw $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: lw $8, %lo($tmp0)($8) # encoding: [A,A,0x08,0x8d]
|
||||
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
|
||||
|
||||
lw $10, 655483($4)
|
||||
# CHECK: lui $10, 10 # encoding: [0x0a,0x00,0x0a,0x3c]
|
||||
# CHECK: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01]
|
||||
@ -145,3 +151,6 @@
|
||||
# CHECK: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
|
||||
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
||||
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
||||
|
||||
1:
|
||||
add $4, $4, $4
|
||||
|
Loading…
Reference in New Issue
Block a user