blob: 2f681a6aefb840427a9ed990f0ded9954fe689b7 [file] [log] [blame]
Chris Lattner699f1eb2002-08-14 17:12:33 +00001/*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===//
Misha Brukman5a2a3822005-05-10 22:02:28 +00002//
John Criswell856ba762003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukman5a2a3822005-05-10 22:02:28 +00007//
John Criswell856ba762003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +00009//
10// This file implements the flex scanner for LLVM assembly languages files.
11//
Chris Lattner699f1eb2002-08-14 17:12:33 +000012//===----------------------------------------------------------------------===*/
Chris Lattner00950542001-06-06 20:29:01 +000013
14%option prefix="llvmAsm"
15%option yylineno
16%option nostdinit
17%option never-interactive
18%option batch
19%option noyywrap
20%option nodefault
21%option 8bit
22%option outfile="Lexer.cpp"
23%option ecs
24%option noreject
25%option noyymore
26
27%{
28#include "ParserInternals.h"
Chris Lattnerb9bcbb52003-04-22 19:07:06 +000029#include "llvm/Module.h"
Chris Lattner00950542001-06-06 20:29:01 +000030#include <list>
31#include "llvmAsmParser.h"
Brian Gaeke778fab22003-10-10 19:12:08 +000032#include <cctype>
33#include <cstdlib>
Chris Lattner00950542001-06-06 20:29:01 +000034
Chris Lattner6184feb2005-05-20 03:25:47 +000035void set_scan_file(FILE * F){
36 yy_switch_to_buffer(yy_create_buffer( F, YY_BUF_SIZE ) );
37}
38void set_scan_string (const char * str) {
39 yy_scan_string (str);
40}
41
Reid Spencer1628cec2006-10-26 06:15:43 +000042// Construct a token value for a non-obsolete token
Chris Lattner00950542001-06-06 20:29:01 +000043#define RET_TOK(type, Enum, sym) \
Reid Spencer08de34b2006-12-03 05:45:44 +000044 llvmAsmlval.type = Instruction::Enum; \
45 return sym
46
Reid Spencer1628cec2006-10-26 06:15:43 +000047// Construct a token value for an obsolete token
Reid Spencer08de34b2006-12-03 05:45:44 +000048#define RET_TY(CTYPE, SYM) \
49 llvmAsmlval.PrimType = CTYPE;\
Reid Spencerb78b9082006-11-28 07:28:14 +000050 return SYM
Chris Lattner00950542001-06-06 20:29:01 +000051
Brian Gaeked0fde302003-11-11 22:41:34 +000052namespace llvm {
Chris Lattner00950542001-06-06 20:29:01 +000053
Misha Brukman5a2a3822005-05-10 22:02:28 +000054// TODO: All of the static identifiers are figured out by the lexer,
Chris Lattnere1fe8752001-09-07 16:32:43 +000055// these should be hashed to reduce the lexer size
Chris Lattner00950542001-06-06 20:29:01 +000056
57
58// atoull - Convert an ascii string of decimal digits into the unsigned long
Misha Brukman5a2a3822005-05-10 22:02:28 +000059// long representation... this does not have to do input error checking,
Chris Lattner00950542001-06-06 20:29:01 +000060// because we know that the input will be matched by a suitable regex...
61//
Chris Lattner275da862002-04-07 08:10:41 +000062static uint64_t atoull(const char *Buffer) {
Chris Lattner00950542001-06-06 20:29:01 +000063 uint64_t Result = 0;
64 for (; *Buffer; Buffer++) {
65 uint64_t OldRes = Result;
66 Result *= 10;
67 Result += *Buffer-'0';
Chris Lattner275da862002-04-07 08:10:41 +000068 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000069 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner00950542001-06-06 20:29:01 +000070 }
71 return Result;
72}
73
Chris Lattner3e8ba102003-04-17 22:17:32 +000074static uint64_t HexIntToVal(const char *Buffer) {
Chris Lattner275da862002-04-07 08:10:41 +000075 uint64_t Result = 0;
76 for (; *Buffer; ++Buffer) {
77 uint64_t OldRes = Result;
78 Result *= 16;
79 char C = *Buffer;
80 if (C >= '0' && C <= '9')
81 Result += C-'0';
82 else if (C >= 'A' && C <= 'F')
83 Result += C-'A'+10;
84 else if (C >= 'a' && C <= 'f')
85 Result += C-'a'+10;
86
87 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000088 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner275da862002-04-07 08:10:41 +000089 }
Chris Lattner3e8ba102003-04-17 22:17:32 +000090 return Result;
91}
92
93
94// HexToFP - Convert the ascii string in hexidecimal format to the floating
95// point representation of it.
96//
97static double HexToFP(const char *Buffer) {
Chris Lattnerb55679d2002-04-07 08:31:26 +000098 // Behave nicely in the face of C TBAA rules... see:
99 // http://www.nullstone.com/htmls/category/aliastyp.htm
Chris Lattner7a5a1f72003-04-22 20:20:28 +0000100 union {
101 uint64_t UI;
102 double FP;
103 } UIntToFP;
104 UIntToFP.UI = HexIntToVal(Buffer);
105
106 assert(sizeof(double) == sizeof(uint64_t) &&
107 "Data sizes incompatible on this target!");
108 return UIntToFP.FP; // Cast Hex constant to double
Chris Lattner275da862002-04-07 08:10:41 +0000109}
110
Chris Lattner00950542001-06-06 20:29:01 +0000111
Chris Lattner93750fa2001-07-28 17:48:55 +0000112// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
113// appropriate character. If AllowNull is set to false, a \00 value will cause
114// an exception to be thrown.
115//
116// If AllowNull is set to true, the return value of the function points to the
117// last character of the string in memory.
118//
Chris Lattnerbcafcce2002-07-25 06:17:42 +0000119char *UnEscapeLexed(char *Buffer, bool AllowNull) {
Chris Lattner93750fa2001-07-28 17:48:55 +0000120 char *BOut = Buffer;
121 for (char *BIn = Buffer; *BIn; ) {
122 if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
123 char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
Chris Lattnera8101c12005-01-08 20:07:03 +0000124 *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
Chris Lattner93750fa2001-07-28 17:48:55 +0000125 if (!AllowNull && !*BOut)
Reid Spencer61c83e02006-08-18 08:43:06 +0000126 GenerateError("String literal cannot accept \\00 escape!");
Misha Brukman5a2a3822005-05-10 22:02:28 +0000127
Chris Lattner93750fa2001-07-28 17:48:55 +0000128 BIn[3] = Tmp; // Restore character
129 BIn += 3; // Skip over handled chars
130 ++BOut;
131 } else {
132 *BOut++ = *BIn++;
133 }
134 }
135
136 return BOut;
137}
138
Brian Gaeked0fde302003-11-11 22:41:34 +0000139} // End llvm namespace
140
141using namespace llvm;
142
Chris Lattner00950542001-06-06 20:29:01 +0000143#define YY_NEVER_INTERACTIVE 1
144%}
145
146
147
148/* Comments start with a ; and go till end of line */
149Comment ;.*
150
Chris Lattnere1815642001-07-15 06:35:53 +0000151/* Variable(Value) identifiers start with a % sign */
Chris Lattner9a88d272001-12-04 04:31:30 +0000152VarID %[-a-zA-Z$._][-a-zA-Z$._0-9]*
Chris Lattner00950542001-06-06 20:29:01 +0000153
154/* Label identifiers end with a colon */
Chris Lattner9a88d272001-12-04 04:31:30 +0000155Label [-a-zA-Z$._0-9]+:
Alkis Evlogimenosd82ef512004-12-10 05:40:19 +0000156QuoteLabel \"[^\"]+\":
Chris Lattner00950542001-06-06 20:29:01 +0000157
158/* Quoted names can contain any character except " and \ */
Chris Lattner99e7ab72003-10-18 05:53:13 +0000159StringConstant \"[^\"]*\"
Chris Lattner00950542001-06-06 20:29:01 +0000160
161
162/* [PN]Integer: match positive and negative literal integer values that
163 * are preceeded by a '%' character. These represent unnamed variable slots.
164 */
165EPInteger %[0-9]+
166ENInteger %-[0-9]+
167
168
169/* E[PN]Integer: match positive and negative literal integer values */
170PInteger [0-9]+
171NInteger -[0-9]+
172
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000173/* FPConstant - A Floating point constant.
Chris Lattner275da862002-04-07 08:10:41 +0000174 */
Chris Lattner1e2c6142001-11-01 22:06:08 +0000175FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000176
Chris Lattner275da862002-04-07 08:10:41 +0000177/* HexFPConstant - Floating point constant represented in IEEE format as a
178 * hexadecimal number for when exponential notation is not precise enough.
179 */
180HexFPConstant 0x[0-9A-Fa-f]+
Chris Lattner3e8ba102003-04-17 22:17:32 +0000181
182/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
183 * it to deal with 64 bit numbers.
184 */
185HexIntConstant [us]0x[0-9A-Fa-f]+
Chris Lattner00950542001-06-06 20:29:01 +0000186%%
187
188{Comment} { /* Ignore comments for now */ }
189
190begin { return BEGINTOK; }
Chris Lattner9b02cc32002-05-03 18:23:48 +0000191end { return ENDTOK; }
Chris Lattner91ef4602004-03-31 03:49:47 +0000192true { return TRUETOK; }
193false { return FALSETOK; }
Chris Lattner00950542001-06-06 20:29:01 +0000194declare { return DECLARE; }
Reid Spencerb951bc02006-12-29 20:29:48 +0000195define { return DEFINE; }
Chris Lattner70cc3392001-09-10 07:58:01 +0000196global { return GLOBAL; }
Chris Lattner1781aca2001-09-18 04:00:54 +0000197constant { return CONSTANT; }
Chris Lattnerdda71962001-11-26 18:54:16 +0000198internal { return INTERNAL; }
Chris Lattner4ad02e72003-04-16 20:28:45 +0000199linkonce { return LINKONCE; }
Chris Lattnerf797cab2003-10-10 04:54:02 +0000200weak { return WEAK; }
Chris Lattner4ad02e72003-04-16 20:28:45 +0000201appending { return APPENDING; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000202dllimport { return DLLIMPORT; }
203dllexport { return DLLEXPORT; }
204extern_weak { return EXTERN_WEAK; }
Chris Lattner08c0e6a2002-10-06 22:45:09 +0000205external { return EXTERNAL; }
Chris Lattner00950542001-06-06 20:29:01 +0000206implementation { return IMPLEMENTATION; }
Chris Lattnerf4600482003-06-28 20:01:34 +0000207zeroinitializer { return ZEROINITIALIZER; }
Chris Lattner8b81bf52001-07-25 22:47:46 +0000208\.\.\. { return DOTDOTDOT; }
Chris Lattner16710e92004-10-16 18:17:13 +0000209undef { return UNDEF; }
Chris Lattner1a1cb112001-09-30 22:46:54 +0000210null { return NULL_TOK; }
Chris Lattner5efbbc22001-10-13 06:37:14 +0000211to { return TO; }
Chris Lattnerc28ade42005-05-06 06:20:33 +0000212tail { return TAIL; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000213target { return TARGET; }
Reid Spencer3cd2fe32004-07-25 17:56:00 +0000214triple { return TRIPLE; }
215deplibs { return DEPLIBS; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000216endian { return ENDIAN; }
217pointersize { return POINTERSIZE; }
Chris Lattner10b27112006-10-22 06:07:41 +0000218datalayout { return DATALAYOUT; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000219little { return LITTLE; }
220big { return BIG; }
Chris Lattner15c9c032003-09-08 18:20:29 +0000221volatile { return VOLATILE; }
Chris Lattnerb7d08a52005-11-12 00:11:30 +0000222align { return ALIGN; }
223section { return SECTION; }
Chris Lattner71cdba32006-01-24 00:40:17 +0000224module { return MODULE; }
Chris Lattneree454772006-01-23 23:05:15 +0000225asm { return ASM_TOK; }
Chris Lattneraa2c8532006-01-25 22:26:43 +0000226sideeffect { return SIDEEFFECT; }
Chris Lattner00950542001-06-06 20:29:01 +0000227
Chris Lattnera8e8f162005-05-06 20:27:19 +0000228cc { return CC_TOK; }
229ccc { return CCC_TOK; }
Chris Lattner515906d2006-05-19 21:28:34 +0000230csretcc { return CSRETCC_TOK; }
Chris Lattnera8e8f162005-05-06 20:27:19 +0000231fastcc { return FASTCC_TOK; }
232coldcc { return COLDCC_TOK; }
Anton Korobeynikovbcb97702006-09-17 20:25:45 +0000233x86_stdcallcc { return X86_STDCALLCC_TOK; }
234x86_fastcallcc { return X86_FASTCALLCC_TOK; }
Chris Lattnera8e8f162005-05-06 20:27:19 +0000235
Reid Spencer08de34b2006-12-03 05:45:44 +0000236void { RET_TY(Type::VoidTy, VOID); }
237bool { RET_TY(Type::BoolTy, BOOL); }
238sbyte { RET_TY(Type::SByteTy, SBYTE); }
239ubyte { RET_TY(Type::UByteTy, UBYTE); }
240short { RET_TY(Type::ShortTy, SHORT); }
241ushort { RET_TY(Type::UShortTy,USHORT);}
242int { RET_TY(Type::IntTy, INT); }
243uint { RET_TY(Type::UIntTy, UINT); }
244long { RET_TY(Type::LongTy, LONG); }
245ulong { RET_TY(Type::ULongTy, ULONG); }
246float { RET_TY(Type::FloatTy, FLOAT); }
247double { RET_TY(Type::DoubleTy,DOUBLE);}
248label { RET_TY(Type::LabelTy, LABEL); }
Reid Spencer77f4d862004-07-04 12:17:44 +0000249type { return TYPE; }
Chris Lattner4e4cae82002-04-04 19:22:17 +0000250opaque { return OPAQUE; }
Chris Lattner00950542001-06-06 20:29:01 +0000251
Chris Lattner00950542001-06-06 20:29:01 +0000252add { RET_TOK(BinaryOpVal, Add, ADD); }
253sub { RET_TOK(BinaryOpVal, Sub, SUB); }
254mul { RET_TOK(BinaryOpVal, Mul, MUL); }
Reid Spencer1628cec2006-10-26 06:15:43 +0000255udiv { RET_TOK(BinaryOpVal, UDiv, UDIV); }
256sdiv { RET_TOK(BinaryOpVal, SDiv, SDIV); }
257fdiv { RET_TOK(BinaryOpVal, FDiv, FDIV); }
Reid Spencer0a783f72006-11-02 01:53:59 +0000258urem { RET_TOK(BinaryOpVal, URem, UREM); }
259srem { RET_TOK(BinaryOpVal, SRem, SREM); }
260frem { RET_TOK(BinaryOpVal, FRem, FREM); }
Chris Lattner42c9e772001-10-20 09:32:59 +0000261and { RET_TOK(BinaryOpVal, And, AND); }
262or { RET_TOK(BinaryOpVal, Or , OR ); }
263xor { RET_TOK(BinaryOpVal, Xor, XOR); }
Reid Spencer08de34b2006-12-03 05:45:44 +0000264icmp { RET_TOK(OtherOpVal, ICmp, ICMP); }
265fcmp { RET_TOK(OtherOpVal, FCmp, FCMP); }
Reid Spencer9f746f42006-12-03 06:58:07 +0000266eq { return EQ; }
267ne { return NE; }
268slt { return SLT; }
269sgt { return SGT; }
270sle { return SLE; }
271sge { return SGE; }
272ult { return ULT; }
273ugt { return UGT; }
274ule { return ULE; }
275uge { return UGE; }
276oeq { return OEQ; }
277one { return ONE; }
278olt { return OLT; }
279ogt { return OGT; }
280ole { return OLE; }
281oge { return OGE; }
282ord { return ORD; }
283uno { return UNO; }
284ueq { return UEQ; }
285une { return UNE; }
Chris Lattner00950542001-06-06 20:29:01 +0000286
Chris Lattner3b237fc2003-10-19 21:34:28 +0000287phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
Chris Lattner027dcc52001-07-08 21:10:27 +0000288call { RET_TOK(OtherOpVal, Call, CALL); }
Reid Spencer3da59db2006-11-27 01:05:10 +0000289trunc { RET_TOK(CastOpVal, Trunc, TRUNC); }
290zext { RET_TOK(CastOpVal, ZExt, ZEXT); }
291sext { RET_TOK(CastOpVal, SExt, SEXT); }
292fptrunc { RET_TOK(CastOpVal, FPTrunc, FPTRUNC); }
293fpext { RET_TOK(CastOpVal, FPExt, FPEXT); }
294uitofp { RET_TOK(CastOpVal, UIToFP, UITOFP); }
295sitofp { RET_TOK(CastOpVal, SIToFP, SITOFP); }
296fptoui { RET_TOK(CastOpVal, FPToUI, FPTOUI); }
297fptosi { RET_TOK(CastOpVal, FPToSI, FPTOSI); }
298inttoptr { RET_TOK(CastOpVal, IntToPtr, INTTOPTR); }
299ptrtoint { RET_TOK(CastOpVal, PtrToInt, PTRTOINT); }
300bitcast { RET_TOK(CastOpVal, BitCast, BITCAST); }
Chris Lattner76f0ff32004-03-12 05:51:36 +0000301select { RET_TOK(OtherOpVal, Select, SELECT); }
Chris Lattner027dcc52001-07-08 21:10:27 +0000302shl { RET_TOK(OtherOpVal, Shl, SHL); }
Reid Spencer3822ff52006-11-08 06:47:33 +0000303lshr { RET_TOK(OtherOpVal, LShr, LSHR); }
304ashr { RET_TOK(OtherOpVal, AShr, ASHR); }
Andrew Lenharth558bc882005-06-18 18:34:52 +0000305va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); }
Chris Lattner00950542001-06-06 20:29:01 +0000306ret { RET_TOK(TermOpVal, Ret, RET); }
307br { RET_TOK(TermOpVal, Br, BR); }
308switch { RET_TOK(TermOpVal, Switch, SWITCH); }
Chris Lattner5efbbc22001-10-13 06:37:14 +0000309invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
Chris Lattner36143fc2003-09-08 18:54:55 +0000310unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
Chris Lattner16710e92004-10-16 18:17:13 +0000311unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
Chris Lattner00950542001-06-06 20:29:01 +0000312
313malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
314alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
315free { RET_TOK(MemOpVal, Free, FREE); }
316load { RET_TOK(MemOpVal, Load, LOAD); }
317store { RET_TOK(MemOpVal, Store, STORE); }
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000318getelementptr { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
Chris Lattner00950542001-06-06 20:29:01 +0000319
Robert Bocchino9c62b562006-01-10 19:04:32 +0000320extractelement { RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); }
Robert Bocchino2def1b32006-01-17 20:06:25 +0000321insertelement { RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); }
Chris Lattner4c949082006-04-08 01:18:35 +0000322shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
Robert Bocchino9c62b562006-01-10 19:04:32 +0000323
Chris Lattner00950542001-06-06 20:29:01 +0000324
Chris Lattner93750fa2001-07-28 17:48:55 +0000325{VarID} {
326 UnEscapeLexed(yytext+1);
327 llvmAsmlval.StrVal = strdup(yytext+1); // Skip %
Misha Brukman5a2a3822005-05-10 22:02:28 +0000328 return VAR_ID;
Chris Lattner93750fa2001-07-28 17:48:55 +0000329 }
330{Label} {
Chris Lattner00950542001-06-06 20:29:01 +0000331 yytext[strlen(yytext)-1] = 0; // nuke colon
Chris Lattner93750fa2001-07-28 17:48:55 +0000332 UnEscapeLexed(yytext);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000333 llvmAsmlval.StrVal = strdup(yytext);
334 return LABELSTR;
Chris Lattner00950542001-06-06 20:29:01 +0000335 }
Chris Lattnerc6c97722004-12-10 05:27:29 +0000336{QuoteLabel} {
337 yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
338 UnEscapeLexed(yytext+1);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000339 llvmAsmlval.StrVal = strdup(yytext+1);
340 return LABELSTR;
Chris Lattnerc6c97722004-12-10 05:27:29 +0000341 }
Chris Lattner00950542001-06-06 20:29:01 +0000342
Chris Lattner93750fa2001-07-28 17:48:55 +0000343{StringConstant} { // Note that we cannot unescape a string constant here! The
Misha Brukman5a2a3822005-05-10 22:02:28 +0000344 // string constant might contain a \00 which would not be
Chris Lattner93750fa2001-07-28 17:48:55 +0000345 // understood by the string stuff. It is valid to make a
346 // [sbyte] c"Hello World\00" constant, for example.
347 //
Misha Brukman5a2a3822005-05-10 22:02:28 +0000348 yytext[strlen(yytext)-1] = 0; // nuke end quote
349 llvmAsmlval.StrVal = strdup(yytext+1); // Nuke start quote
350 return STRINGCONSTANT;
Chris Lattner93750fa2001-07-28 17:48:55 +0000351 }
Chris Lattner00950542001-06-06 20:29:01 +0000352
353
354{PInteger} { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
Misha Brukman5a2a3822005-05-10 22:02:28 +0000355{NInteger} {
Chris Lattner00950542001-06-06 20:29:01 +0000356 uint64_t Val = atoull(yytext+1);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000357 // +1: we have bigger negative range
358 if (Val > (uint64_t)INT64_MAX+1)
Reid Spencer61c83e02006-08-18 08:43:06 +0000359 GenerateError("Constant too large for signed 64 bits!");
Misha Brukman5a2a3822005-05-10 22:02:28 +0000360 llvmAsmlval.SInt64Val = -Val;
361 return ESINT64VAL;
Chris Lattner00950542001-06-06 20:29:01 +0000362 }
Chris Lattner3e8ba102003-04-17 22:17:32 +0000363{HexIntConstant} {
Misha Brukman5a2a3822005-05-10 22:02:28 +0000364 llvmAsmlval.UInt64Val = HexIntToVal(yytext+3);
Chris Lattner3e8ba102003-04-17 22:17:32 +0000365 return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
366 }
Chris Lattner00950542001-06-06 20:29:01 +0000367
Chris Lattnera8101c12005-01-08 20:07:03 +0000368{EPInteger} {
369 uint64_t Val = atoull(yytext+1);
370 if ((unsigned)Val != Val)
Reid Spencer61c83e02006-08-18 08:43:06 +0000371 GenerateError("Invalid value number (too large)!");
Chris Lattnera8101c12005-01-08 20:07:03 +0000372 llvmAsmlval.UIntVal = unsigned(Val);
373 return UINTVAL;
374 }
Chris Lattner00950542001-06-06 20:29:01 +0000375{ENInteger} {
376 uint64_t Val = atoull(yytext+2);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000377 // +1: we have bigger negative range
378 if (Val > (uint64_t)INT32_MAX+1)
Reid Spencer61c83e02006-08-18 08:43:06 +0000379 GenerateError("Constant too large for signed 32 bits!");
Chris Lattnera8101c12005-01-08 20:07:03 +0000380 llvmAsmlval.SIntVal = (int)-Val;
Misha Brukman5a2a3822005-05-10 22:02:28 +0000381 return SINTVAL;
Chris Lattner00950542001-06-06 20:29:01 +0000382 }
383
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000384{FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }
Chris Lattner275da862002-04-07 08:10:41 +0000385{HexFPConstant} { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; }
Chris Lattner00950542001-06-06 20:29:01 +0000386
Chris Lattnere1512592004-03-19 23:34:33 +0000387<<EOF>> {
388 /* Make sure to free the internal buffers for flex when we are
389 * done reading our input!
390 */
391 yy_delete_buffer(YY_CURRENT_BUFFER);
392 return EOF;
393 }
394
Chris Lattnera0846a32004-05-27 17:49:14 +0000395[ \r\t\n] { /* Ignore whitespace */ }
Chris Lattnere1fe8752001-09-07 16:32:43 +0000396. { return yytext[0]; }
Chris Lattner00950542001-06-06 20:29:01 +0000397
398%%