projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
MC/Mach-O: Implement EmitValue using data fragments + fixups instead of fill fragment.
[oota-llvm.git]
/
lib
/
MC
/
MCExpr.cpp
diff --git
a/lib/MC/MCExpr.cpp
b/lib/MC/MCExpr.cpp
index a19ec19bca5d52b68e8c1fc306e239e4cdb60a68..e419043a771749acc36796fa71f937f01a41139d 100644
(file)
--- a/
lib/MC/MCExpr.cpp
+++ b/
lib/MC/MCExpr.cpp
@@
-15,8
+15,10
@@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#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()) {
switch (getKind()) {
+ case MCExpr::Target:
+ return cast<MCTargetExpr>(this)->PrintImpl(OS);
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
return;
case MCExpr::Constant:
OS << cast<MCConstantExpr>(*this).getValue();
return;
@@
-26,13
+28,10
@@
void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
// Parenthesize names that start with $ so that they don't look like
// absolute names.
// Parenthesize names that start with $ so that they don't look like
// absolute names.
- if (Sym.getName()[0] == '$') {
- OS << '(';
- Sym.print(OS, MAI);
- OS << ')';
- } else {
- Sym.print(OS, MAI);
- }
+ if (Sym.getName()[0] == '$')
+ OS << '(' << Sym << ')';
+ else
+ OS << Sym;
return;
}
return;
}
@@
-45,7
+44,7
@@
void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
case MCUnaryExpr::Not: OS << '~'; break;
case MCUnaryExpr::Plus: OS << '+'; break;
}
case MCUnaryExpr::Not: OS << '~'; break;
case MCUnaryExpr::Plus: OS << '+'; break;
}
-
UE.getSubExpr()->print(OS, MAI
);
+
OS << *UE.getSubExpr(
);
return;
}
return;
}
@@
-54,11
+53,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())) {
// 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 {
} else {
- OS << '(';
- BE.getLHS()->print(OS, MAI);
- OS << ')';
+ OS << '(' << *BE.getLHS() << ')';
}
switch (BE.getOpcode()) {
}
switch (BE.getOpcode()) {
@@
-95,11
+92,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())) {
// 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 {
} else {
- OS << '(';
- BE.getRHS()->print(OS, MAI);
- OS << ')';
+ OS << '(' << *BE.getRHS() << ')';
}
return;
}
}
return;
}
@@
-109,7
+104,7
@@
void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
}
void MCExpr::dump() const {
}
void MCExpr::dump() const {
- print(dbgs()
, 0
);
+ print(dbgs());
dbgs() << '\n';
}
dbgs() << '\n';
}
@@
-138,6
+133,7
@@
const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, MCContext &Ctx) {
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
}
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
}
+void MCTargetExpr::Anchor() {}
/* *** */
/* *** */
@@
-175,6
+171,9
@@
static bool EvaluateSymbolicAdd(const MCValue &LHS, const MCSymbol *RHS_A,
bool MCExpr::EvaluateAsRelocatable(MCValue &Res) const {
switch (getKind()) {
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;
case Constant:
Res = MCValue::get(cast<MCConstantExpr>(this)->getValue());
return true;
@@
-253,8
+252,8
@@
bool MCExpr::EvaluateAsRelocatable(MCValue &Res) const {
}
// FIXME: We need target hooks for the evaluation. It may be limited in
}
// 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()) {
int64_t LHS = LHSValue.getConstant(), RHS = RHSValue.getConstant();
int64_t Result = 0;
switch (ABE->getOpcode()) {