/// @name Utility Methods
/// @{
- void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
+ void print(raw_ostream &OS) const;
void dump() const;
/// @}
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 {
PersonalityRef = CreateLabelDiff(PersonalityRef, "personalityref_addr",
Index);
- O << MAI->getData32bitsDirective();
- PersonalityRef->print(O, MAI);
+ O << MAI->getData32bitsDirective() << *PersonalityRef;
Asm->EOL("Personality");
Asm->EmitInt8(LSDAEncoding);
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.
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,
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) {
#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();
case MCUnaryExpr::Not: OS << '~'; break;
case MCUnaryExpr::Plus: OS << '+'; break;
}
- UE.getSubExpr()->print(OS, MAI);
+ OS << *UE.getSubExpr();
return;
}
// 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()) {
// 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;
}
}
void MCExpr::dump() const {
- print(dbgs(), 0);
+ print(dbgs());
dbgs() << '\n';
}
else if (isImm())
OS << "Imm:" << getImm();
else if (isExpr()) {
- OS << "Expr:(";
- getExpr()->print(OS, MAI);
- OS << ")";
+ OS << "Expr:(" << *getExpr() << ")";
} else
OS << "UNDEFINED";
OS << ">";
} 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();
}
}
O << Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
O << '#' << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << '#';
- Op.getExpr()->print(O, &MAI);
+ O << '#' << *Op.getExpr();
}
}
// 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())
O << (int)Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
O << '$' << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- O << '$';
- Op.getExpr()->print(O, &MAI);
+ O << '$' << *Op.getExpr();
}
}
O << DispVal;
} else {
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
- DispSpec.getExpr()->print(O, &MAI);
+ O << *DispSpec.getExpr();
}
if (IndexReg.getReg() || BaseReg.getReg()) {
O << Op.getImm();
else {
assert(Op.isExpr() && "unknown pcrel immediate operand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
O << Op.getImm();
} else {
assert(Op.isExpr() && "unknown operand kind in printOperand");
- Op.getExpr()->print(O, &MAI);
+ O << *Op.getExpr();
}
}
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())) {