[llvm] r211714 - Move expression visitation logic up to MCStreamer.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jun 25 08:45:34 PDT 2014
Author: rafael
Date: Wed Jun 25 10:45:33 2014
New Revision: 211714
URL: http://llvm.org/viewvc/llvm-project?rev=211714&view=rev
Log:
Move expression visitation logic up to MCStreamer.
Remove the duplicate from MCRecordStreamer. No functionality change.
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/LTO/LTOModule.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
llvm/trunk/lib/Target/NVPTX/NVPTXMCExpr.h
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Wed Jun 25 10:45:33 2014
@@ -21,7 +21,7 @@ class MCAssembler;
class MCContext;
class MCSection;
class MCSectionData;
-class MCObjectStreamer;
+class MCStreamer;
class MCSymbol;
class MCValue;
class raw_ostream;
@@ -525,7 +525,7 @@ public:
virtual void PrintImpl(raw_ostream &OS) const = 0;
virtual bool EvaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout) const = 0;
- virtual void visitUsedExpr(MCObjectStreamer& Streamer) const = 0;
+ virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
virtual const MCSection *FindAssociatedSection() const = 0;
virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const = 0;
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Wed Jun 25 10:45:33 2014
@@ -79,8 +79,7 @@ protected:
MCDataFragment *getOrCreateDataFragment() const;
public:
- void visitUsedExpr(const MCExpr &Expr);
- void visitUsedSymbol(const MCSymbol &Sym);
+ void visitUsedSymbol(const MCSymbol &Sym) override;
MCAssembler &getAssembler() { return *Assembler; }
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed Jun 25 10:45:33 2014
@@ -214,6 +214,9 @@ protected:
public:
virtual ~MCStreamer();
+ void visitUsedExpr(const MCExpr &Expr);
+ virtual void visitUsedSymbol(const MCSymbol &Sym);
+
void setTargetStreamer(MCTargetStreamer *TS) {
TargetStreamer.reset(TS);
}
Modified: llvm/trunk/lib/LTO/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOModule.cpp (original)
+++ llvm/trunk/lib/LTO/LTOModule.cpp Wed Jun 25 10:45:33 2014
@@ -605,31 +605,8 @@ namespace {
}
}
- // FIXME: mostly copied for the obj streamer.
- void AddValueSymbols(const MCExpr *Value) {
- switch (Value->getKind()) {
- case MCExpr::Target:
- // FIXME: What should we do in here?
- break;
-
- case MCExpr::Constant:
- break;
-
- case MCExpr::Binary: {
- const MCBinaryExpr *BE = cast<MCBinaryExpr>(Value);
- AddValueSymbols(BE->getLHS());
- AddValueSymbols(BE->getRHS());
- break;
- }
-
- case MCExpr::SymbolRef:
- markUsed(cast<MCSymbolRefExpr>(Value)->getSymbol());
- break;
-
- case MCExpr::Unary:
- AddValueSymbols(cast<MCUnaryExpr>(Value)->getSubExpr());
- break;
- }
+ void visitUsedSymbol(const MCSymbol &Sym) override {
+ markUsed(Sym);
}
public:
@@ -650,7 +627,7 @@ namespace {
// Scan for values.
for (unsigned i = Inst.getNumOperands(); i--; )
if (Inst.getOperand(i).isExpr())
- AddValueSymbols(Inst.getOperand(i).getExpr());
+ visitUsedExpr(*Inst.getOperand(i).getExpr());
}
void EmitLabel(MCSymbol *Symbol) override {
MCStreamer::EmitLabel(Symbol);
@@ -659,7 +636,7 @@ namespace {
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override {
// FIXME: should we handle aliases?
markDefined(*Symbol);
- AddValueSymbols(Value);
+ visitUsedExpr(*Value);
}
bool EmitSymbolAttribute(MCSymbol *Symbol,
MCSymbolAttr Attribute) override {
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Wed Jun 25 10:45:33 2014
@@ -87,32 +87,6 @@ void MCObjectStreamer::visitUsedSymbol(c
Assembler->getOrCreateSymbolData(Sym);
}
-void MCObjectStreamer::visitUsedExpr(const MCExpr &Expr) {
- switch (Expr.getKind()) {
- case MCExpr::Target:
- cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
- break;
-
- case MCExpr::Constant:
- break;
-
- case MCExpr::Binary: {
- const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
- visitUsedExpr(*BE.getLHS());
- visitUsedExpr(*BE.getRHS());
- break;
- }
-
- case MCExpr::SymbolRef:
- visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
- break;
-
- case MCExpr::Unary:
- visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
- break;
- }
-}
-
void MCObjectStreamer::EmitCFISections(bool EH, bool Debug) {
MCStreamer::EmitCFISections(EH, Debug);
EmitEHFrame = EH;
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Wed Jun 25 10:45:33 2014
@@ -614,6 +614,35 @@ void MCStreamer::EmitAssignment(MCSymbol
TS->emitAssignment(Symbol, Value);
}
+void MCStreamer::visitUsedSymbol(const MCSymbol &Sym) {
+}
+
+void MCStreamer::visitUsedExpr(const MCExpr &Expr) {
+ switch (Expr.getKind()) {
+ case MCExpr::Target:
+ cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
+ break;
+
+ case MCExpr::Constant:
+ break;
+
+ case MCExpr::Binary: {
+ const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
+ visitUsedExpr(*BE.getLHS());
+ visitUsedExpr(*BE.getRHS());
+ break;
+ }
+
+ case MCExpr::SymbolRef:
+ visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
+ break;
+
+ case MCExpr::Unary:
+ visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
+ break;
+ }
+}
+
void MCStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {}
void MCStreamer::EmitThumbFunc(MCSymbol *Func) {}
void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.cpp Wed Jun 25 10:45:33 2014
@@ -16,7 +16,6 @@
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELF.h"
-#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Object/ELF.h"
@@ -82,7 +81,7 @@ void AArch64MCExpr::PrintImpl(raw_ostrea
OS << *Expr;
}
-void AArch64MCExpr::visitUsedExpr(MCObjectStreamer &Streamer) const {
+void AArch64MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr());
}
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h Wed Jun 25 10:45:33 2014
@@ -147,7 +147,7 @@ public:
void PrintImpl(raw_ostream &OS) const override;
- void visitUsedExpr(MCObjectStreamer &Streamer) const override;
+ void visitUsedExpr(MCStreamer &Streamer) const override;
const MCSection *FindAssociatedSection() const override;
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp Wed Jun 25 10:45:33 2014
@@ -10,7 +10,6 @@
#include "ARMMCExpr.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCObjectStreamer.h"
using namespace llvm;
#define DEBUG_TYPE "armmcexpr"
@@ -42,6 +41,6 @@ ARMMCExpr::EvaluateAsRelocatableImpl(MCV
return false;
}
-void ARMMCExpr::visitUsedExpr(MCObjectStreamer &Streamer) const {
+void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr());
}
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h Wed Jun 25 10:45:33 2014
@@ -59,7 +59,7 @@ public:
void PrintImpl(raw_ostream &OS) const override;
bool EvaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout) const override;
- void visitUsedExpr(MCObjectStreamer &Streamer) const override;
+ void visitUsedExpr(MCStreamer &Streamer) const override;
const MCSection *FindAssociatedSection() const override {
return getSubExpr()->FindAssociatedSection();
}
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp Wed Jun 25 10:45:33 2014
@@ -84,6 +84,6 @@ MipsMCExpr::EvaluateAsRelocatableImpl(MC
return getSubExpr()->EvaluateAsRelocatable(Res, Layout);
}
-void MipsMCExpr::visitUsedExpr(MCObjectStreamer &Streamer) const {
+void MipsMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr());
}
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h Wed Jun 25 10:45:33 2014
@@ -49,7 +49,7 @@ public:
void PrintImpl(raw_ostream &OS) const override;
bool EvaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout) const override;
- void visitUsedExpr(MCObjectStreamer &Streamer) const override;
+ void visitUsedExpr(MCStreamer &Streamer) const override;
const MCSection *FindAssociatedSection() const override {
return getSubExpr()->FindAssociatedSection();
}
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXMCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXMCExpr.h (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXMCExpr.h Wed Jun 25 10:45:33 2014
@@ -66,7 +66,7 @@ public:
const MCAsmLayout *Layout) const override {
return false;
}
- void visitUsedExpr(MCObjectStreamer &Streamer) const override {};
+ void visitUsedExpr(MCStreamer &Streamer) const override {};
const MCSection *FindAssociatedSection() const override {
return nullptr;
}
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp Wed Jun 25 10:45:33 2014
@@ -128,6 +128,6 @@ PPCMCExpr::EvaluateAsRelocatableImpl(MCV
return true;
}
-void PPCMCExpr::visitUsedExpr(MCObjectStreamer &Streamer) const {
+void PPCMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr());
}
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h Wed Jun 25 10:45:33 2014
@@ -79,7 +79,7 @@ public:
void PrintImpl(raw_ostream &OS) const override;
bool EvaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout) const override;
- void visitUsedExpr(MCObjectStreamer &Streamer) const override;
+ void visitUsedExpr(MCStreamer &Streamer) const override;
const MCSection *FindAssociatedSection() const override {
return getSubExpr()->FindAssociatedSection();
}
Modified: llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp Wed Jun 25 10:45:33 2014
@@ -220,6 +220,6 @@ void SparcMCExpr::fixELFSymbolsInTLSFixu
fixELFSymbolsInTLSFixupsImpl(getSubExpr(), Asm);
}
-void SparcMCExpr::visitUsedExpr(MCObjectStreamer &Streamer) const {
+void SparcMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr());
}
Modified: llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h?rev=211714&r1=211713&r2=211714&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h (original)
+++ llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h Wed Jun 25 10:45:33 2014
@@ -88,7 +88,7 @@ public:
void PrintImpl(raw_ostream &OS) const override;
bool EvaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout) const override;
- void visitUsedExpr(MCObjectStreamer &Streamer) const override;
+ void visitUsedExpr(MCStreamer &Streamer) const override;
const MCSection *FindAssociatedSection() const override {
return getSubExpr()->FindAssociatedSection();
}
More information about the llvm-commits
mailing list