Mercurial > hg > CbC > CbC_llvm
comparison lib/TableGen/TGLexer.h @ 77:54457678186b LLVM3.6
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | afa8332a0e37 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
9 // | 9 // |
10 // This class represents the Lexer for tablegen files. | 10 // This class represents the Lexer for tablegen files. |
11 // | 11 // |
12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
13 | 13 |
14 #ifndef TGLEXER_H | 14 #ifndef LLVM_LIB_TABLEGEN_TGLEXER_H |
15 #define TGLEXER_H | 15 #define LLVM_LIB_TABLEGEN_TGLEXER_H |
16 | 16 |
17 #include "llvm/ADT/StringRef.h" | |
17 #include "llvm/Support/DataTypes.h" | 18 #include "llvm/Support/DataTypes.h" |
18 #include "llvm/Support/SMLoc.h" | 19 #include "llvm/Support/SMLoc.h" |
19 #include <cassert> | 20 #include <cassert> |
20 #include <map> | 21 #include <map> |
21 #include <string> | 22 #include <string> |
22 | 23 |
23 namespace llvm { | 24 namespace llvm { |
24 class MemoryBuffer; | |
25 class SourceMgr; | 25 class SourceMgr; |
26 class SMLoc; | 26 class SMLoc; |
27 class Twine; | 27 class Twine; |
28 | 28 |
29 namespace tgtok { | 29 namespace tgtok { |
45 // Keywords. | 45 // Keywords. |
46 Bit, Bits, Class, Code, Dag, Def, Foreach, Defm, Field, In, Int, Let, List, | 46 Bit, Bits, Class, Code, Dag, Def, Foreach, Defm, Field, In, Int, Let, List, |
47 MultiClass, String, | 47 MultiClass, String, |
48 | 48 |
49 // !keywords. | 49 // !keywords. |
50 XConcat, XADD, XSRA, XSRL, XSHL, XStrConcat, XCast, XSubst, | 50 XConcat, XADD, XAND, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast, |
51 XForEach, XHead, XTail, XEmpty, XIf, XEq, | 51 XSubst, XForEach, XHead, XTail, XEmpty, XIf, XEq, |
52 | 52 |
53 // Integer value. | 53 // Integer value. |
54 IntVal, | 54 IntVal, |
55 | |
56 // Binary constant. Note that these are sized according to the number of | |
57 // bits given. | |
58 BinaryIntVal, | |
55 | 59 |
56 // String valued tokens. | 60 // String valued tokens. |
57 Id, StrVal, VarName, CodeFragment | 61 Id, StrVal, VarName, CodeFragment |
58 }; | 62 }; |
59 } | 63 } |
61 /// TGLexer - TableGen Lexer class. | 65 /// TGLexer - TableGen Lexer class. |
62 class TGLexer { | 66 class TGLexer { |
63 SourceMgr &SrcMgr; | 67 SourceMgr &SrcMgr; |
64 | 68 |
65 const char *CurPtr; | 69 const char *CurPtr; |
66 const MemoryBuffer *CurBuf; | 70 StringRef CurBuf; |
67 | 71 |
68 // Information about the current token. | 72 // Information about the current token. |
69 const char *TokStart; | 73 const char *TokStart; |
70 tgtok::TokKind CurCode; | 74 tgtok::TokKind CurCode; |
71 std::string CurStrVal; // This is valid for ID, STRVAL, VARNAME, CODEFRAGMENT | 75 std::string CurStrVal; // This is valid for ID, STRVAL, VARNAME, CODEFRAGMENT |
72 int64_t CurIntVal; // This is valid for INTVAL. | 76 int64_t CurIntVal; // This is valid for INTVAL. |
73 | 77 |
74 /// CurBuffer - This is the current buffer index we're lexing from as managed | 78 /// CurBuffer - This is the current buffer index we're lexing from as managed |
75 /// by the SourceMgr object. | 79 /// by the SourceMgr object. |
76 int CurBuffer; | 80 unsigned CurBuffer; |
77 | 81 |
78 public: | 82 public: |
79 typedef std::map<std::string, SMLoc> DependenciesMapTy; | 83 typedef std::map<std::string, SMLoc> DependenciesMapTy; |
80 private: | 84 private: |
81 /// Dependencies - This is the list of all included files. | 85 /// Dependencies - This is the list of all included files. |
103 } | 107 } |
104 int64_t getCurIntVal() const { | 108 int64_t getCurIntVal() const { |
105 assert(CurCode == tgtok::IntVal && "This token isn't an integer"); | 109 assert(CurCode == tgtok::IntVal && "This token isn't an integer"); |
106 return CurIntVal; | 110 return CurIntVal; |
107 } | 111 } |
112 std::pair<int64_t, unsigned> getCurBinaryIntVal() const { | |
113 assert(CurCode == tgtok::BinaryIntVal && | |
114 "This token isn't a binary integer"); | |
115 return std::make_pair(CurIntVal, (CurPtr - TokStart)-2); | |
116 } | |
108 | 117 |
109 SMLoc getLoc() const; | 118 SMLoc getLoc() const; |
110 | 119 |
111 private: | 120 private: |
112 /// LexToken - Read the next token and return its code. | 121 /// LexToken - Read the next token and return its code. |