summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCInst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCInst.cpp')
-rw-r--r--llvm/lib/MC/MCInst.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCInst.cpp b/llvm/lib/MC/MCInst.cpp
index f6d1d3cffca..5f026dc6b26 100644
--- a/llvm/lib/MC/MCInst.cpp
+++ b/llvm/lib/MC/MCInst.cpp
@@ -10,6 +10,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInstPrinter.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@@ -35,6 +36,23 @@ void MCOperand::print(raw_ostream &OS) const {
OS << ">";
}
+bool MCOperand::evaluateAsConstantImm(int64_t &Imm) const {
+ if (isImm()) {
+ Imm = getImm();
+ return true;
+ }
+ return false;
+}
+
+bool MCOperand::isBareSymbolRef() const {
+ assert(isExpr() &&
+ "isBareSymbolRef expects only expressions");
+ const MCExpr *Expr = getExpr();
+ MCExpr::ExprKind Kind = getExpr()->getKind();
+ return Kind == MCExpr::SymbolRef &&
+ cast<MCSymbolRefExpr>(Expr)->getKind() == MCSymbolRefExpr::VK_None;
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void MCOperand::dump() const {
print(dbgs());
OpenPOWER on IntegriCloud