#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::Target:
+ return cast<MCTargetExpr>(this)->PrintImpl(OS);
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
return;
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';
}
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
}
+void MCTargetExpr::Anchor() {}
/* *** */
bool MCExpr::EvaluateAsRelocatable(MCValue &Res) const {
switch (getKind()) {
+ case Target:
+ return cast<MCTargetExpr>(this)->EvaluateAsRelocatableImpl(Res);
+
case Constant:
Res = MCValue::get(cast<MCConstantExpr>(this)->getValue());
return true;
}
// FIXME: We need target hooks for the evaluation. It may be limited in
- // width, and gas defines the result of comparisons differently from Apple
- // as (the result is sign extended).
+ // width, and gas defines the result of comparisons and right shifts
+ // differently from Apple as.
int64_t LHS = LHSValue.getConstant(), RHS = RHSValue.getConstant();
int64_t Result = 0;
switch (ABE->getOpcode()) {