summaryrefslogtreecommitdiff
path: root/lib/MC
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-03 05:46:51 +0000
committerChris Lattner <sabre@nondot.org>2009-09-03 05:46:51 +0000
commit684c593d05db0bd277268fc9d8c05bce138c745a (patch)
treebd14333e8ed905f9665b6df0ed1165d19b77acf8 /lib/MC
parent5c5ce5cef4a9f09f5b25e08df1e0dd6c79908c0f (diff)
downloadllvm-684c593d05db0bd277268fc9d8c05bce138c745a.tar.gz
llvm-684c593d05db0bd277268fc9d8c05bce138c745a.tar.bz2
llvm-684c593d05db0bd277268fc9d8c05bce138c745a.tar.xz
Thread an MCAsmInfo pointer through the various MC printing APIs,
and fix a few things using << on MCSymbols to use ->print(). No functionality change other than unbreaking my previous patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80890 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAsmStreamer.cpp31
-rw-r--r--lib/MC/MCExpr.cpp12
-rw-r--r--lib/MC/MCInst.cpp12
-rw-r--r--lib/MC/MCSymbol.cpp4
-rw-r--r--lib/MC/MCValue.cpp8
5 files changed, 38 insertions, 29 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index cc77c6f8ac..17c591b01c 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -101,7 +101,8 @@ void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
assert(CurSection && "Cannot emit before setting section!");
- OS << Symbol << ":\n";
+ Symbol->print(OS, &MAI);
+ OS << ":\n";
Symbol->setSection(*CurSection);
}
@@ -118,8 +119,9 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
"Cannot define a symbol twice!");
- OS << Symbol << " = ";
- Value->print(OS);
+ Symbol->print(OS, &MAI);
+ OS << " = ";
+ Value->print(OS, &MAI);
OS << '\n';
}
@@ -140,17 +142,22 @@ void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
case WeakReference: OS << ".weak_reference"; break;
}
- OS << ' ' << Symbol << '\n';
+ OS << ' ';
+ Symbol->print(OS, &MAI);
+ OS << '\n';
}
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
- OS << ".desc" << ' ' << Symbol << ',' << DescValue << '\n';
+ OS << ".desc" << ' ';
+ Symbol->print(OS, &MAI);
+ OS << ',' << DescValue << '\n';
}
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
unsigned ByteAlignment) {
- OS << ".comm";
- OS << ' ' << Symbol << ',' << Size;
+ OS << ".comm ";
+ Symbol->print(OS, &MAI);
+ OS << ',' << Size;
if (ByteAlignment != 0)
OS << ',' << Log2_32(ByteAlignment);
OS << '\n';
@@ -166,7 +173,9 @@ void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
if (Symbol != NULL) {
- OS << ',' << Symbol << ',' << Size;
+ OS << ',';
+ Symbol->print(OS, &MAI);
+ OS << ',' << Size;
if (ByteAlignment != 0)
OS << ',' << Log2_32(ByteAlignment);
}
@@ -192,7 +201,7 @@ void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size) {
}
OS << ' ';
- truncateToSize(Value, Size)->print(OS);
+ truncateToSize(Value, Size)->print(OS, &MAI);
OS << '\n';
}
@@ -248,7 +257,7 @@ void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
unsigned char Value) {
// FIXME: Verify that Offset is associated with the current section.
OS << ".org ";
- Offset->print(OS);
+ Offset->print(OS, &MAI);
OS << ", " << (unsigned) Value << '\n';
}
@@ -281,7 +290,7 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
// Otherwise fall back to a structural printing for now. Eventually we should
// always have access to the target specific printer.
- Inst.print(OS);
+ Inst.print(OS, &MAI);
OS << '\n';
}
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index bc4241560e..9a1b641fb4 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -14,14 +14,14 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-void MCExpr::print(raw_ostream &OS) const {
+void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
switch (getKind()) {
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
return;
case MCExpr::SymbolRef:
- cast<MCSymbolRefExpr>(*this).getSymbol().print(OS);
+ cast<MCSymbolRefExpr>(*this).getSymbol().print(OS, MAI);
return;
case MCExpr::Unary: {
@@ -33,14 +33,14 @@ void MCExpr::print(raw_ostream &OS) const {
case MCUnaryExpr::Not: OS << '~'; break;
case MCUnaryExpr::Plus: OS << '+'; break;
}
- UE.getSubExpr()->print(OS);
+ UE.getSubExpr()->print(OS, MAI);
return;
}
case MCExpr::Binary: {
const MCBinaryExpr &BE = cast<MCBinaryExpr>(*this);
OS << '(';
- BE.getLHS()->print(OS);
+ BE.getLHS()->print(OS, MAI);
OS << ' ';
switch (BE.getOpcode()) {
default: assert(0 && "Invalid opcode!");
@@ -64,7 +64,7 @@ void MCExpr::print(raw_ostream &OS) const {
case MCBinaryExpr::Xor: OS << '^'; break;
}
OS << ' ';
- BE.getRHS()->print(OS);
+ BE.getRHS()->print(OS, MAI);
OS << ')';
return;
}
@@ -74,7 +74,7 @@ void MCExpr::print(raw_ostream &OS) const {
}
void MCExpr::dump() const {
- print(errs());
+ print(errs(), 0);
errs() << '\n';
}
diff --git a/lib/MC/MCInst.cpp b/lib/MC/MCInst.cpp
index ec061463b7..f19056bc9a 100644
--- a/lib/MC/MCInst.cpp
+++ b/lib/MC/MCInst.cpp
@@ -13,7 +13,7 @@
using namespace llvm;
-void MCOperand::print(raw_ostream &OS) const {
+void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
OS << "<MCOperand ";
if (!isValid())
OS << "INVALID";
@@ -26,7 +26,7 @@ void MCOperand::print(raw_ostream &OS) const {
<< getMBBLabelBlock() << ")";
else if (isExpr()) {
OS << "Expr:(";
- getExpr()->print(OS);
+ getExpr()->print(OS, MAI);
OS << ")";
} else
OS << "UNDEFINED";
@@ -34,20 +34,20 @@ void MCOperand::print(raw_ostream &OS) const {
}
void MCOperand::dump() const {
- print(errs());
+ print(errs(), 0);
errs() << "\n";
}
-void MCInst::print(raw_ostream &OS) const {
+void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
OS << "<MCInst " << getOpcode();
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
OS << " ";
- getOperand(i).print(OS);
+ getOperand(i).print(OS, MAI);
}
OS << ">";
}
void MCInst::dump() const {
- print(errs());
+ print(errs(), 0);
errs() << "\n";
}
diff --git a/lib/MC/MCSymbol.cpp b/lib/MC/MCSymbol.cpp
index 3c9894b691..3b1a41d48d 100644
--- a/lib/MC/MCSymbol.cpp
+++ b/lib/MC/MCSymbol.cpp
@@ -41,7 +41,7 @@ static inline bool NeedsQuoting(const StringRef &Str) {
return false;
}
-void MCSymbol::print(raw_ostream &OS) const {
+void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
if (NeedsQuoting(getName()))
OS << '"' << getName() << '"';
else
@@ -49,5 +49,5 @@ void MCSymbol::print(raw_ostream &OS) const {
}
void MCSymbol::dump() const {
- print(errs());
+ print(errs(), 0);
}
diff --git a/lib/MC/MCValue.cpp b/lib/MC/MCValue.cpp
index c7923da764..69bd10c8e6 100644
--- a/lib/MC/MCValue.cpp
+++ b/lib/MC/MCValue.cpp
@@ -12,17 +12,17 @@
using namespace llvm;
-void MCValue::print(raw_ostream &OS) const {
+void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
if (isAbsolute()) {
OS << getConstant();
return;
}
- getSymA()->print(OS);
+ getSymA()->print(OS, MAI);
if (getSymB()) {
OS << " - ";
- getSymB()->print(OS);
+ getSymB()->print(OS, MAI);
}
if (getConstant())
@@ -30,5 +30,5 @@ void MCValue::print(raw_ostream &OS) const {
}
void MCValue::dump() const {
- print(errs());
+ print(errs(), 0);
}