[llvm-commits] [llvm] r95559 - in /llvm/trunk: include/llvm/MC/MCExpr.h lib/MC/MCExpr.cpp lib/MC/MCMachOStreamer.cpp
Chris Lattner
sabre at nondot.org
Mon Feb 8 11:41:08 PST 2010
Author: lattner
Date: Mon Feb 8 13:41:07 2010
New Revision: 95559
URL: http://llvm.org/viewvc/llvm-project?rev=95559&view=rev
Log:
add scaffolding for target-specific MCExprs.
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=95559&r1=95558&r2=95559&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Mon Feb 8 13:41:07 2010
@@ -29,7 +29,8 @@
Binary, ///< Binary expressions.
Constant, ///< Constant expressions.
SymbolRef, ///< References to labels and assigned expressions.
- Unary ///< Unary expressions.
+ Unary, ///< Unary expressions.
+ Target ///< Target specific expression.
};
private:
@@ -326,6 +327,28 @@
static bool classof(const MCBinaryExpr *) { return true; }
};
+/// MCTargetExpr - This is an extension point for target-specific MCExpr
+/// subclasses to implement.
+///
+/// NOTE: All subclasses are required to have trivial destructors because
+/// MCExprs are bump pointer allocated and not destructed.
+class MCTargetExpr : public MCExpr {
+ virtual ~MCTargetExpr(); // Not accessible.
+protected:
+ MCTargetExpr() : MCExpr(Target) {}
+
+public:
+
+ virtual void PrintImpl(raw_ostream &OS) const = 0;
+ virtual bool EvaluateAsRelocatableImpl(MCValue &Res) const = 0;
+
+
+ static bool classof(const MCExpr *E) {
+ return E->getKind() == MCExpr::Target;
+ }
+ static bool classof(const MCTargetExpr *) { return true; }
+};
+
} // end namespace llvm
#endif
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=95559&r1=95558&r2=95559&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Mon Feb 8 13:41:07 2010
@@ -17,6 +17,8 @@
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;
@@ -131,6 +133,7 @@
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
}
+MCTargetExpr::~MCTargetExpr() {}
/* *** */
@@ -168,6 +171,9 @@
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;
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=95559&r1=95558&r2=95559&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon Feb 8 13:41:07 2010
@@ -87,6 +87,7 @@
const MCExpr *AddValueSymbols(const MCExpr *Value) {
switch (Value->getKind()) {
+ case MCExpr::Target: assert(0 && "Can't handle target exprs yet!");
case MCExpr::Constant:
break;
More information about the llvm-commits
mailing list