mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
add scaffolding for target-specific MCExprs.
llvm-svn: 95559
This commit is contained in:
parent
983b171d40
commit
b3fe7597f5
@ -29,7 +29,8 @@ public:
|
||||
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 @@ public:
|
||||
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
|
||||
|
@ -17,6 +17,8 @@ using namespace llvm;
|
||||
|
||||
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 @@ const MCSymbolRefExpr *MCSymbolRefExpr::Create(StringRef Name, MCContext &Ctx) {
|
||||
return Create(Ctx.GetOrCreateSymbol(Name), Ctx);
|
||||
}
|
||||
|
||||
MCTargetExpr::~MCTargetExpr() {}
|
||||
|
||||
/* *** */
|
||||
|
||||
@ -168,6 +171,9 @@ static bool EvaluateSymbolicAdd(const MCValue &LHS, const MCSymbol *RHS_A,
|
||||
|
||||
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;
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
|
||||
const MCExpr *AddValueSymbols(const MCExpr *Value) {
|
||||
switch (Value->getKind()) {
|
||||
case MCExpr::Target: assert(0 && "Can't handle target exprs yet!");
|
||||
case MCExpr::Constant:
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user