MC: Add AsmLexer::BigNum token for integers greater than 64 bits
[oota-llvm.git] / include / llvm / MC / MCParser / MCAsmLexer.h
index 8edf3a4423f5b7b04b347581ffcc526164cf7d71..ceba3f05e1c9c246e60c1ba0b9230ec3b1117ea6 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef LLVM_MC_MCPARSER_MCASMLEXER_H
 #define LLVM_MC_MCPARSER_MCASMLEXER_H
 
+#include "llvm/ADT/APInt.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/DataTypes.h"
@@ -30,6 +31,7 @@ public:
 
     // Integer values.
     Integer,
+    BigNum, // larger than 64 bits
 
     // Real values.
     Real,
@@ -57,12 +59,14 @@ private:
   /// a memory buffer owned by the source manager.
   StringRef Str;
 
-  int64_t IntVal;
+  APInt IntVal;
 
 public:
   AsmToken() {}
-  AsmToken(TokenKind _Kind, StringRef _Str, int64_t _IntVal = 0)
+  AsmToken(TokenKind _Kind, StringRef _Str, APInt _IntVal)
     : Kind(_Kind), Str(_Str), IntVal(_IntVal) {}
+  AsmToken(TokenKind _Kind, StringRef _Str, int64_t _IntVal = 0)
+    : Kind(_Kind), Str(_Str), IntVal(64, _IntVal, true) {}
 
   TokenKind getKind() const { return Kind; }
   bool is(TokenKind K) const { return Kind == K; }
@@ -99,6 +103,12 @@ public:
   // as a single token, then diagnose as an invalid number).
   int64_t getIntVal() const {
     assert(Kind == Integer && "This token isn't an integer!");
+    return IntVal.getZExtValue();
+  }
+
+  APInt getAPIntVal() const {
+    assert((Kind == Integer || Kind == BigNum) &&
+           "This token isn't an integer!");
     return IntVal;
   }
 };