summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-18 00:37:40 +0000
committerChris Lattner <sabre@nondot.org>2010-01-18 00:37:40 +0000
commit8cb9a3b13f3226b7e741768b69d26ecd6b5231f1 (patch)
tree512b0fe9b4b5781e1547c555c92db9b42faa9b1e
parent950558aa23dfeb0014b7081f61ab932fe8c6f25c (diff)
downloadllvm-8cb9a3b13f3226b7e741768b69d26ecd6b5231f1.tar.gz
llvm-8cb9a3b13f3226b7e741768b69d26ecd6b5231f1.tar.bz2
llvm-8cb9a3b13f3226b7e741768b69d26ecd6b5231f1.tar.xz
remove the MAI argument to MCExpr::print and switch overthing to use << when printing them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93699 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCExpr.h7
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp3
-rw-r--r--lib/MC/MCAsmStreamer.cpp12
-rw-r--r--lib/MC/MCExpr.cpp18
-rw-r--r--lib/MC/MCInst.cpp4
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp2
-rw-r--r--lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp8
-rw-r--r--lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp7
-rw-r--r--lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp6
9 files changed, 28 insertions, 39 deletions
diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h
index 13d40eca7c..73d5f8ef51 100644
--- a/include/llvm/MC/MCExpr.h
+++ b/include/llvm/MC/MCExpr.h
@@ -51,7 +51,7 @@ public:
/// @name Utility Methods
/// @{
- void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
+ void print(raw_ostream &OS) const;
void dump() const;
/// @}
@@ -75,6 +75,11 @@ public:
static bool classof(const MCExpr *) { return true; }
};
+
+inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
+ E.print(OS);
+ return OS;
+}
//// MCConstantExpr - Represent a constant integer expression.
class MCConstantExpr : public MCExpr {
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index ad6df15c44..8de9bd65ca 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -194,8 +194,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
PersonalityRef = CreateLabelDiff(PersonalityRef, "personalityref_addr",
Index);
- O << MAI->getData32bitsDirective();
- PersonalityRef->print(O, MAI);
+ O << MAI->getData32bitsDirective() << *PersonalityRef;
Asm->EOL("Personality");
Asm->EmitInt8(LSDAEncoding);
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 9e8c7ce59e..4768c62355 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -118,9 +118,7 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
"Cannot define a symbol twice!");
- OS << *Symbol << " = ";
- Value->print(OS, &MAI);
- OS << '\n';
+ OS << *Symbol << " = " << *Value << '\n';
// FIXME: Lift context changes into super class.
// FIXME: Set associated section.
@@ -194,9 +192,7 @@ void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size) {
case 8: OS << ".quad"; break;
}
- OS << ' ';
- truncateToSize(Value, Size)->print(OS, &MAI);
- OS << '\n';
+ OS << ' ' << *truncateToSize(Value, Size) << '\n';
}
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
@@ -250,9 +246,7 @@ void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
unsigned char Value) {
// FIXME: Verify that Offset is associated with the current section.
- OS << ".org ";
- Offset->print(OS, &MAI);
- OS << ", " << (unsigned) Value << '\n';
+ OS << ".org " << *Offset << ", " << (unsigned) Value << '\n';
}
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index 57d02c95f1..1ee1b1bddb 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -15,7 +15,7 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
+void MCExpr::print(raw_ostream &OS) const {
switch (getKind()) {
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
@@ -42,7 +42,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
case MCUnaryExpr::Not: OS << '~'; break;
case MCUnaryExpr::Plus: OS << '+'; break;
}
- UE.getSubExpr()->print(OS, MAI);
+ OS << *UE.getSubExpr();
return;
}
@@ -51,11 +51,9 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
// Only print parens around the LHS if it is non-trivial.
if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
- BE.getLHS()->print(OS, MAI);
+ OS << *BE.getLHS();
} else {
- OS << '(';
- BE.getLHS()->print(OS, MAI);
- OS << ')';
+ OS << '(' << *BE.getLHS() << ')';
}
switch (BE.getOpcode()) {
@@ -92,11 +90,9 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
// Only print parens around the LHS if it is non-trivial.
if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
- BE.getRHS()->print(OS, MAI);
+ OS << *BE.getRHS();
} else {
- OS << '(';
- BE.getRHS()->print(OS, MAI);
- OS << ')';
+ OS << '(' << *BE.getRHS() << ')';
}
return;
}
@@ -106,7 +102,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
}
void MCExpr::dump() const {
- print(dbgs(), 0);
+ print(dbgs());
dbgs() << '\n';
}
diff --git a/lib/MC/MCInst.cpp b/lib/MC/MCInst.cpp
index 7c7a644773..0634c9faf6 100644
--- a/lib/MC/MCInst.cpp
+++ b/lib/MC/MCInst.cpp
@@ -23,9 +23,7 @@ void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
else if (isImm())
OS << "Imm:" << getImm();
else if (isExpr()) {
- OS << "Expr:(";
- getExpr()->print(OS, MAI);
- OS << ")";
+ OS << "Expr:(" << *getExpr() << ")";
} else
OS << "UNDEFINED";
OS << ">";
diff --git a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
index 9fc57e0de5..6885ecb25d 100644
--- a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
@@ -62,7 +62,7 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
} else {
assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
assert(Op.isExpr() && "unknown operand kind in printOperand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
index 0a403c4d29..a480307152 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
@@ -39,7 +39,7 @@ void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) {
O << Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
@@ -53,8 +53,7 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << '#' << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << '#';
- Op.getExpr()->print(O, &MAI);
+ O << '#' << *Op.getExpr();
}
}
@@ -65,8 +64,7 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
// Print displacement first
if (Disp.isExpr()) {
- O << '&';
- Disp.getExpr()->print(O, &MAI);
+ O << '&' << *Disp.getExpr();
} else {
assert(Disp.isImm() && "Expected immediate in displacement field");
if (!Base.getReg())
diff --git a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
index c74b97af30..804dbb927e 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
@@ -55,7 +55,7 @@ void X86ATTInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
O << (int)Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
@@ -68,8 +68,7 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo) {
O << '$' << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << '$';
- Op.getExpr()->print(O, &MAI);
+ O << '$' << *Op.getExpr();
}
}
@@ -84,7 +83,7 @@ void X86ATTInstPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) {
O << DispVal;
} else {
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
- DispSpec.getExpr()->print(O, &MAI);
+ O << *DispSpec.getExpr();
}
if (IndexReg.getReg() || BaseReg.getReg()) {
diff --git a/lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp
index fde5902357..4efb5294fb 100644
--- a/lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp
@@ -52,7 +52,7 @@ void X86IntelInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
O << Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
@@ -72,7 +72,7 @@ void X86IntelInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
@@ -102,7 +102,7 @@ void X86IntelInstPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) {
if (!DispSpec.isImm()) {
if (NeedPlus) O << " + ";
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
- DispSpec.getExpr()->print(O, &MAI);
+ O << *DispSpec.getExpr();
} else {
int64_t DispVal = DispSpec.getImm();
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {