llvm-mc: Add MCAsmParser::Parse[Paren]Expression forms which return an MCExpr.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 31 Aug 2009 08:08:17 +0000 (08:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 31 Aug 2009 08:08:17 +0000 (08:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80574 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmParser.h
tools/llvm-mc/AsmParser.cpp
tools/llvm-mc/AsmParser.h

index e0a48f1e9c0f287fd1382a5626b1acb422acb1b8..23c97f58affdaa9e06a60a967c04f2894287dc4e 100644 (file)
@@ -15,6 +15,7 @@
 namespace llvm {
 class MCAsmLexer;
 class MCContext;
+class MCExpr;
 class MCValue;
 class SMLoc;
 class Twine;
@@ -45,6 +46,21 @@ public:
   /// clients.
   virtual bool Error(SMLoc L, const Twine &Msg) = 0;
 
+  /// ParseExpression - Parse an arbitrary expression.
+  ///
+  /// @param Res - The value of the expression. The result is undefined
+  /// on error.
+  /// @result - False on success.
+  virtual bool ParseExpression(const MCExpr *&Res) = 0;
+
+  /// ParseParenExpression - Parse an arbitrary expression, assuming that an
+  /// initial '(' has already been consumed.
+  ///
+  /// @param Res - The value of the expression. The result is undefined
+  /// on error.
+  /// @result - False on success.
+  virtual bool ParseParenExpression(const MCExpr *&Res) = 0;
+
   /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
   /// absolute value.
   ///
index 5d73a9fa5401c042d3adb6cea140c160cbaf92d4..78cab38b4ffc8a324077287e9eaf9173918c2aef 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCValue.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetAsmParser.h"
@@ -258,6 +259,13 @@ bool AsmParser::ParseExpression(const MCExpr *&Res) {
          ParseBinOpRHS(1, Res);
 }
 
+bool AsmParser::ParseParenExpression(const MCExpr *&Res) {
+  if (ParseParenExpr(Res))
+    return true;
+
+  return false;
+}
+
 bool AsmParser::ParseAbsoluteExpression(int64_t &Res) {
   const MCExpr *Expr;
   
index b7082b688d4554ca7fb0cc6bfef182f4e37d2e74..2e328d9f6fd31cf99bdb733a01ac9180e57b03f5 100644 (file)
@@ -70,6 +70,8 @@ public:
 
   virtual bool ParseExpression(const MCExpr *&Res);
 
+  virtual bool ParseParenExpression(const MCExpr *&Res);
+
   virtual bool ParseAbsoluteExpression(int64_t &Res);
 
   virtual bool ParseRelocatableExpression(MCValue &Res);