mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
MC: Clean up MCExpr naming. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238634 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1946,10 +1946,10 @@ void MipsAsmParser::expandLoadAddressSym(
|
||||
unsigned RegNo = DstRegOp.getReg();
|
||||
const MCSymbolRefExpr *Symbol = cast<MCSymbolRefExpr>(SymOp.getExpr());
|
||||
const MCSymbolRefExpr *HiExpr =
|
||||
MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::VK_Mips_ABS_HI, getContext());
|
||||
const MCSymbolRefExpr *LoExpr =
|
||||
MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::VK_Mips_ABS_LO, getContext());
|
||||
if (!Is32BitSym) {
|
||||
// If it's a 64-bit architecture, expand to:
|
||||
@@ -1960,10 +1960,10 @@ void MipsAsmParser::expandLoadAddressSym(
|
||||
// dsll d,d,16
|
||||
// ori d,d,lo16(sym)
|
||||
const MCSymbolRefExpr *HighestExpr =
|
||||
MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::VK_Mips_HIGHEST, getContext());
|
||||
const MCSymbolRefExpr *HigherExpr =
|
||||
MCSymbolRefExpr::Create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::create(Symbol->getSymbol().getName(),
|
||||
MCSymbolRefExpr::VK_Mips_HIGHER, getContext());
|
||||
|
||||
tmpInst.setOpcode(Mips::LUi);
|
||||
@@ -2102,7 +2102,7 @@ void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc,
|
||||
else {
|
||||
if (ExprOffset->getKind() == MCExpr::SymbolRef) {
|
||||
SR = static_cast<const MCSymbolRefExpr *>(ExprOffset);
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
|
||||
SR->getSymbol().getName(), MCSymbolRefExpr::VK_Mips_ABS_HI,
|
||||
getContext());
|
||||
TempInst.addOperand(MCOperand::createExpr(HiExpr));
|
||||
@@ -2133,7 +2133,7 @@ void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc,
|
||||
TempInst.addOperand(MCOperand::createImm(LoOffset));
|
||||
else {
|
||||
if (ExprOffset->getKind() == MCExpr::SymbolRef) {
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create(
|
||||
SR->getSymbol().getName(), MCSymbolRefExpr::VK_Mips_ABS_LO,
|
||||
getContext());
|
||||
TempInst.addOperand(MCOperand::createExpr(LoExpr));
|
||||
@@ -2505,7 +2505,7 @@ bool MipsAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
|
||||
MCSymbol *Sym = getContext().getOrCreateSymbol("$" + Identifier);
|
||||
// Otherwise create a symbol reference.
|
||||
const MCExpr *Res =
|
||||
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext());
|
||||
MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, getContext());
|
||||
|
||||
Operands.push_back(MipsOperand::CreateImm(Res, S, E, *this));
|
||||
return false;
|
||||
@@ -2565,14 +2565,14 @@ const MCExpr *MipsAsmParser::evaluateRelocExpr(const MCExpr *Expr,
|
||||
default:
|
||||
report_fatal_error("unsupported reloc value");
|
||||
}
|
||||
return MCConstantExpr::Create(Val, getContext());
|
||||
return MCConstantExpr::create(Val, getContext());
|
||||
}
|
||||
|
||||
if (const MCSymbolRefExpr *MSRE = dyn_cast<MCSymbolRefExpr>(Expr)) {
|
||||
// It's a symbol, create a symbolic expression from the symbol.
|
||||
StringRef Symbol = MSRE->getSymbol().getName();
|
||||
MCSymbolRefExpr::VariantKind VK = getVariantKind(RelocStr);
|
||||
Res = MCSymbolRefExpr::Create(Symbol, VK, getContext());
|
||||
Res = MCSymbolRefExpr::create(Symbol, VK, getContext());
|
||||
return Res;
|
||||
}
|
||||
|
||||
@@ -2581,17 +2581,17 @@ const MCExpr *MipsAsmParser::evaluateRelocExpr(const MCExpr *Expr,
|
||||
|
||||
// Try to create target expression.
|
||||
if (MipsMCExpr::isSupportedBinaryExpr(VK, BE))
|
||||
return MipsMCExpr::Create(VK, Expr, getContext());
|
||||
return MipsMCExpr::create(VK, Expr, getContext());
|
||||
|
||||
const MCExpr *LExp = evaluateRelocExpr(BE->getLHS(), RelocStr);
|
||||
const MCExpr *RExp = evaluateRelocExpr(BE->getRHS(), RelocStr);
|
||||
Res = MCBinaryExpr::Create(BE->getOpcode(), LExp, RExp, getContext());
|
||||
Res = MCBinaryExpr::create(BE->getOpcode(), LExp, RExp, getContext());
|
||||
return Res;
|
||||
}
|
||||
|
||||
if (const MCUnaryExpr *UN = dyn_cast<MCUnaryExpr>(Expr)) {
|
||||
const MCExpr *UnExp = evaluateRelocExpr(UN->getSubExpr(), RelocStr);
|
||||
Res = MCUnaryExpr::Create(UN->getOpcode(), UnExp, getContext());
|
||||
Res = MCUnaryExpr::create(UN->getOpcode(), UnExp, getContext());
|
||||
return Res;
|
||||
}
|
||||
// Just return the original expression.
|
||||
@@ -2779,7 +2779,7 @@ MipsAsmParser::parseMemOperand(OperandVector &Operands) {
|
||||
Parser.Lex(); // Eat the ')' token.
|
||||
|
||||
if (!IdVal)
|
||||
IdVal = MCConstantExpr::Create(0, getContext());
|
||||
IdVal = MCConstantExpr::create(0, getContext());
|
||||
|
||||
// Replace the register operand with the memory operand.
|
||||
std::unique_ptr<MipsOperand> op(
|
||||
@@ -2790,10 +2790,10 @@ MipsAsmParser::parseMemOperand(OperandVector &Operands) {
|
||||
// Add the memory operand.
|
||||
if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(IdVal)) {
|
||||
int64_t Imm;
|
||||
if (IdVal->EvaluateAsAbsolute(Imm))
|
||||
IdVal = MCConstantExpr::Create(Imm, getContext());
|
||||
if (IdVal->evaluateAsAbsolute(Imm))
|
||||
IdVal = MCConstantExpr::create(Imm, getContext());
|
||||
else if (BE->getLHS()->getKind() != MCExpr::SymbolRef)
|
||||
IdVal = MCBinaryExpr::Create(BE->getOpcode(), BE->getRHS(), BE->getLHS(),
|
||||
IdVal = MCBinaryExpr::create(BE->getOpcode(), BE->getRHS(), BE->getLHS(),
|
||||
getContext());
|
||||
}
|
||||
|
||||
@@ -3010,7 +3010,7 @@ MipsAsmParser::parseInvNum(OperandVector &Operands) {
|
||||
int64_t Val = MCE->getValue();
|
||||
SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
|
||||
Operands.push_back(MipsOperand::CreateImm(
|
||||
MCConstantExpr::Create(0 - Val, getContext()), S, E, *this));
|
||||
MCConstantExpr::create(0 - Val, getContext()), S, E, *this));
|
||||
return MatchOperand_Success;
|
||||
}
|
||||
|
||||
@@ -3034,7 +3034,7 @@ MipsAsmParser::parseLSAImm(OperandVector &Operands) {
|
||||
return MatchOperand_ParseFail;
|
||||
|
||||
int64_t Val;
|
||||
if (!Expr->EvaluateAsAbsolute(Val)) {
|
||||
if (!Expr->evaluateAsAbsolute(Val)) {
|
||||
Error(S, "expected immediate value");
|
||||
return MatchOperand_ParseFail;
|
||||
}
|
||||
@@ -4286,7 +4286,7 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||
reportParseError("expected number after comma");
|
||||
return false;
|
||||
}
|
||||
if (!DummyNumber->EvaluateAsAbsolute(DummyNumberVal)) {
|
||||
if (!DummyNumber->evaluateAsAbsolute(DummyNumberVal)) {
|
||||
reportParseError("expected an absolute expression after comma");
|
||||
return false;
|
||||
}
|
||||
@@ -4366,7 +4366,7 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FrameSize->EvaluateAsAbsolute(FrameSizeVal)) {
|
||||
if (!FrameSize->evaluateAsAbsolute(FrameSizeVal)) {
|
||||
reportParseError("frame size not an absolute expression");
|
||||
return false;
|
||||
}
|
||||
@@ -4427,7 +4427,7 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BitMask->EvaluateAsAbsolute(BitMaskVal)) {
|
||||
if (!BitMask->evaluateAsAbsolute(BitMaskVal)) {
|
||||
reportParseError("bitmask not an absolute expression");
|
||||
return false;
|
||||
}
|
||||
@@ -4448,7 +4448,7 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FrameOffset->EvaluateAsAbsolute(FrameOffsetVal)) {
|
||||
if (!FrameOffset->evaluateAsAbsolute(FrameOffsetVal)) {
|
||||
reportParseError("frame offset not an absolute expression");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
|
||||
const MCSubtargetInfo &STI) const {
|
||||
int64_t Res;
|
||||
|
||||
if (Expr->EvaluateAsAbsolute(Res))
|
||||
if (Expr->evaluateAsAbsolute(Res))
|
||||
return Res;
|
||||
|
||||
MCExpr::ExprKind Kind = Expr->getKind();
|
||||
|
||||
@@ -41,7 +41,7 @@ bool MipsMCExpr::isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK,
|
||||
}
|
||||
|
||||
const MipsMCExpr*
|
||||
MipsMCExpr::Create(MCSymbolRefExpr::VariantKind VK, const MCExpr *Expr,
|
||||
MipsMCExpr::create(MCSymbolRefExpr::VariantKind VK, const MCExpr *Expr,
|
||||
MCContext &Ctx) {
|
||||
VariantKind Kind;
|
||||
switch (VK) {
|
||||
@@ -64,7 +64,7 @@ MipsMCExpr::Create(MCSymbolRefExpr::VariantKind VK, const MCExpr *Expr,
|
||||
return new (Ctx) MipsMCExpr(Kind, Expr);
|
||||
}
|
||||
|
||||
void MipsMCExpr::PrintImpl(raw_ostream &OS) const {
|
||||
void MipsMCExpr::printImpl(raw_ostream &OS) const {
|
||||
switch (Kind) {
|
||||
default: llvm_unreachable("Invalid kind!");
|
||||
case VK_Mips_LO: OS << "%lo"; break;
|
||||
@@ -79,10 +79,10 @@ void MipsMCExpr::PrintImpl(raw_ostream &OS) const {
|
||||
}
|
||||
|
||||
bool
|
||||
MipsMCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
|
||||
MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const {
|
||||
return getSubExpr()->EvaluateAsRelocatable(Res, Layout, Fixup);
|
||||
return getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup);
|
||||
}
|
||||
|
||||
void MipsMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
static bool isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK,
|
||||
const MCBinaryExpr *BE);
|
||||
|
||||
static const MipsMCExpr *Create(MCSymbolRefExpr::VariantKind VK,
|
||||
static const MipsMCExpr *create(MCSymbolRefExpr::VariantKind VK,
|
||||
const MCExpr *Expr, MCContext &Ctx);
|
||||
|
||||
/// getOpcode - Get the kind of this expression.
|
||||
@@ -46,13 +46,13 @@ public:
|
||||
/// getSubExpr - Get the child of this expression.
|
||||
const MCExpr *getSubExpr() const { return Expr; }
|
||||
|
||||
void PrintImpl(raw_ostream &OS) const override;
|
||||
bool EvaluateAsRelocatableImpl(MCValue &Res,
|
||||
void printImpl(raw_ostream &OS) const override;
|
||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const override;
|
||||
void visitUsedExpr(MCStreamer &Streamer) const override;
|
||||
MCSection *FindAssociatedSection() const override {
|
||||
return getSubExpr()->FindAssociatedSection();
|
||||
MCSection *findAssociatedSection() const override {
|
||||
return getSubExpr()->findAssociatedSection();
|
||||
}
|
||||
|
||||
// There are no TLS MipsMCExprs at the moment.
|
||||
|
||||
@@ -564,7 +564,7 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) {
|
||||
ELF::SHF_ALLOC | ELF::SHT_REL);
|
||||
|
||||
const MCSymbolRefExpr *ExprRef =
|
||||
MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context);
|
||||
MCSymbolRefExpr::create(Name, MCSymbolRefExpr::VK_None, Context);
|
||||
|
||||
MCA.registerSection(*Sec);
|
||||
Sec->setAlignment(4);
|
||||
@@ -694,7 +694,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(Mips::LUi);
|
||||
TmpInst.addOperand(MCOperand::createReg(Mips::GP));
|
||||
const MCSymbolRefExpr *HiSym = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *HiSym = MCSymbolRefExpr::create(
|
||||
"_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_HI, MCA.getContext());
|
||||
TmpInst.addOperand(MCOperand::createExpr(HiSym));
|
||||
getStreamer().EmitInstruction(TmpInst, STI);
|
||||
@@ -704,7 +704,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
|
||||
TmpInst.setOpcode(Mips::ADDiu);
|
||||
TmpInst.addOperand(MCOperand::createReg(Mips::GP));
|
||||
TmpInst.addOperand(MCOperand::createReg(Mips::GP));
|
||||
const MCSymbolRefExpr *LoSym = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *LoSym = MCSymbolRefExpr::create(
|
||||
"_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_LO, MCA.getContext());
|
||||
TmpInst.addOperand(MCOperand::createExpr(LoSym));
|
||||
getStreamer().EmitInstruction(TmpInst, STI);
|
||||
@@ -748,9 +748,9 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo,
|
||||
getStreamer().EmitInstruction(Inst, STI);
|
||||
Inst.clear();
|
||||
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create(
|
||||
&Sym, MCSymbolRefExpr::VK_Mips_GPOFF_HI, MCA.getContext());
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::Create(
|
||||
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create(
|
||||
&Sym, MCSymbolRefExpr::VK_Mips_GPOFF_LO, MCA.getContext());
|
||||
|
||||
// lui $gp, %hi(%neg(%gp_rel(funcSym)))
|
||||
|
||||
@@ -778,7 +778,7 @@ void MipsAsmPrinter::EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol) {
|
||||
MCInst I;
|
||||
I.setOpcode(Mips::JAL);
|
||||
I.addOperand(
|
||||
MCOperand::createExpr(MCSymbolRefExpr::Create(Symbol, OutContext)));
|
||||
MCOperand::createExpr(MCSymbolRefExpr::create(Symbol, OutContext)));
|
||||
OutStreamer->EmitInstruction(I, STI);
|
||||
}
|
||||
|
||||
@@ -1028,9 +1028,9 @@ void MipsAsmPrinter::EmitFPCallStub(
|
||||
|
||||
MCSymbol *Tmp = OutContext.createTempSymbol();
|
||||
OutStreamer->EmitLabel(Tmp);
|
||||
const MCSymbolRefExpr *E = MCSymbolRefExpr::Create(Stub, OutContext);
|
||||
const MCSymbolRefExpr *T = MCSymbolRefExpr::Create(Tmp, OutContext);
|
||||
const MCExpr *T_min_E = MCBinaryExpr::CreateSub(T, E, OutContext);
|
||||
const MCSymbolRefExpr *E = MCSymbolRefExpr::create(Stub, OutContext);
|
||||
const MCSymbolRefExpr *T = MCSymbolRefExpr::create(Tmp, OutContext);
|
||||
const MCExpr *T_min_E = MCBinaryExpr::createSub(T, E, OutContext);
|
||||
OutStreamer->EmitELFSize(Stub, T_min_E);
|
||||
TS.emitDirectiveEnd(x);
|
||||
OutStreamer->PopSection();
|
||||
|
||||
@@ -101,7 +101,7 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||
llvm_unreachable("<unknown operand type>");
|
||||
}
|
||||
|
||||
const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::Create(Symbol, Kind, *Ctx);
|
||||
const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::create(Symbol, Kind, *Ctx);
|
||||
|
||||
if (!Offset)
|
||||
return MCOperand::createExpr(MCSym);
|
||||
@@ -109,8 +109,8 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||
// Assume offset is never negative.
|
||||
assert(Offset > 0);
|
||||
|
||||
const MCConstantExpr *OffsetExpr = MCConstantExpr::Create(Offset, *Ctx);
|
||||
const MCBinaryExpr *Add = MCBinaryExpr::CreateAdd(MCSym, OffsetExpr, *Ctx);
|
||||
const MCConstantExpr *OffsetExpr = MCConstantExpr::create(Offset, *Ctx);
|
||||
const MCBinaryExpr *Add = MCBinaryExpr::createAdd(MCSym, OffsetExpr, *Ctx);
|
||||
return MCOperand::createExpr(Add);
|
||||
}
|
||||
|
||||
@@ -155,11 +155,11 @@ MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
|
||||
MCOperand MipsMCInstLower::createSub(MachineBasicBlock *BB1,
|
||||
MachineBasicBlock *BB2,
|
||||
MCSymbolRefExpr::VariantKind Kind) const {
|
||||
const MCSymbolRefExpr *Sym1 = MCSymbolRefExpr::Create(BB1->getSymbol(), *Ctx);
|
||||
const MCSymbolRefExpr *Sym2 = MCSymbolRefExpr::Create(BB2->getSymbol(), *Ctx);
|
||||
const MCBinaryExpr *Sub = MCBinaryExpr::CreateSub(Sym1, Sym2, *Ctx);
|
||||
const MCSymbolRefExpr *Sym1 = MCSymbolRefExpr::create(BB1->getSymbol(), *Ctx);
|
||||
const MCSymbolRefExpr *Sym2 = MCSymbolRefExpr::create(BB2->getSymbol(), *Ctx);
|
||||
const MCBinaryExpr *Sub = MCBinaryExpr::createSub(Sym1, Sym2, *Ctx);
|
||||
|
||||
return MCOperand::createExpr(MipsMCExpr::Create(Kind, Sub, *Ctx));
|
||||
return MCOperand::createExpr(MipsMCExpr::create(Kind, Sub, *Ctx));
|
||||
}
|
||||
|
||||
void MipsMCInstLower::
|
||||
|
||||
Reference in New Issue
Block a user