Skip to content

Commit 7e62715

Browse files
committed
[RISCV,LoongArch,MC] Replace getSymA()->getSymbol() with getAddSym. NFC
We will replace the MCSymbolRefExpr member in MCValue with MCSymbol. This change reduces dependence on MCSymbolRefExpr. Creating a MCSymbolRefExpr in *AsmBackend::handleAddSubRelocations is not efficient, but it is temporary and will be replaced when MCValue no longer uses MCSymbolRefExpr.
1 parent aeec945 commit 7e62715

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,9 @@ bool LoongArchAsmBackend::handleAddSubRelocations(const MCAssembler &Asm,
497497
default:
498498
llvm_unreachable("unsupported fixup size");
499499
}
500-
MCValue A = MCValue::get(Target.getSymA(), nullptr, Target.getConstant());
500+
MCValue A = MCValue::get(
501+
MCSymbolRefExpr::create(Target.getAddSym(), Asm.getContext()), nullptr,
502+
Target.getConstant());
501503
MCValue B = MCValue::get(
502504
MCSymbolRefExpr::create(Target.getSubSym(), Asm.getContext()));
503505
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, std::get<0>(FK));

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ bool RISCVAsmParser::classifySymbolRef(const MCExpr *Expr,
28052805
bool RISCVAsmParser::isSymbolDiff(const MCExpr *Expr) {
28062806
MCValue Res;
28072807
if (Expr->evaluateAsRelocatable(Res, nullptr)) {
2808-
return Res.getRefKind() == RISCVMCExpr::VK_None && Res.getSymA() &&
2808+
return Res.getRefKind() == RISCVMCExpr::VK_None && Res.getAddSym() &&
28092809
Res.getSubSym();
28102810
}
28112811
return false;

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
599599
}
600600
}
601601

602-
if (!AUIPCTarget.getSymA())
602+
if (!AUIPCTarget.getAddSym())
603603
return false;
604604

605605
const MCSymbolELF &SA = cast<MCSymbolELF>(*AUIPCTarget.getAddSym());
@@ -656,7 +656,9 @@ bool RISCVAsmBackend::handleAddSubRelocations(const MCAssembler &Asm,
656656
default:
657657
llvm_unreachable("unsupported fixup size");
658658
}
659-
MCValue A = MCValue::get(Target.getSymA(), nullptr, Target.getConstant());
659+
MCValue A = MCValue::get(
660+
MCSymbolRefExpr::create(Target.getAddSym(), Asm.getContext()), nullptr,
661+
Target.getConstant());
660662
MCValue B = MCValue::get(
661663
MCSymbolRefExpr::create(Target.getSubSym(), Asm.getContext()));
662664
auto FA = MCFixup::create(

0 commit comments

Comments
 (0)