diff options
author | David Woodhouse <dwmw2@infradead.org> | 2014-02-01 16:20:54 +0000 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2014-02-01 16:20:54 +0000 |
commit | aac8e4e3f332c8be2b1049f892549a367d902919 (patch) | |
tree | 8b40650f4f8cbc788cde162373d937d0db2b304d /include | |
parent | 115fd30b245065324193baefe418cd7e6b429488 (diff) | |
download | llvm-aac8e4e3f332c8be2b1049f892549a367d902919.tar.gz llvm-aac8e4e3f332c8be2b1049f892549a367d902919.tar.bz2 llvm-aac8e4e3f332c8be2b1049f892549a367d902919.tar.xz |
MC: Add AsmLexer::BigNum token for integers greater than 64 bits
This will be needed for .octa support, but we don't want to just use the
existing AsmLexer::Integer for it and then have to litter all its users
with explicit checks for the size, and make them use the new get APIntVal()
method.
So let the lexer produce an AsmLexer::Integer as before for numbers which
are small enough — which appears to cover what was previously a nasty
special case handling of numbers which don't fit in int64_t but *do* fit
in uint64_t.
Where the number is too large even for that, produce an AsmLexer::BigNum
instead. We do nothing with these except complain about them for now,
but that will be changed shortly...
Based on a patch from PaX Team <pageexec@freemail.hu>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200613 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCParser/MCAsmLexer.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h index 8edf3a4423..ceba3f05e1 100644 --- a/include/llvm/MC/MCParser/MCAsmLexer.h +++ b/include/llvm/MC/MCParser/MCAsmLexer.h @@ -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; } }; |