//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "mcexpr"
#include "llvm/MC/MCExpr.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/Target/TargetAsmBackend.h"
using namespace llvm;
+namespace {
+namespace stats {
+STATISTIC(MCExprEvaluate, "Number of MCExpr evaluations");
+}
+}
+
void MCExpr::print(raw_ostream &OS) const {
switch (getKind()) {
case MCExpr::Target:
return Create(Ctx.GetOrCreateSymbol(Name), Kind, Ctx);
}
-const MCSymbolRefExpr *MCSymbolRefExpr::CreateTemp(StringRef Name,
- VariantKind Kind,
- MCContext &Ctx) {
- return Create(Ctx.GetOrCreateTemporarySymbol(Name), Kind, Ctx);
-}
-
StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
switch (Kind) {
default:
bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
const MCAsmLayout *Layout) const {
+ ++stats::MCExprEvaluate;
+
switch (getKind()) {
case Target:
return cast<MCTargetExpr>(this)->EvaluateAsRelocatableImpl(Res, Layout);
Layout->getAssembler().getSymbolData(Res.getSymA()->getSymbol());
MCSymbolData &B =
Layout->getAssembler().getSymbolData(Res.getSymB()->getSymbol());
- Res = MCValue::get(+ A.getFragment()->getAddress() + A.getOffset()
- - B.getFragment()->getAddress() - B.getOffset()
+ Res = MCValue::get(+ Layout->getSymbolAddress(&A)
+ - Layout->getSymbolAddress(&B)
+ Res.getConstant());
}