blob: 390544d8c3d99f4f1a6b641e59a01e39b32137ef [file] [log] [blame]
Chris Lattner32eecb02006-02-14 05:14:46 +00001/*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===//
2//
3// 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.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the flex scanner for LLVM assembly languages files.
11//
12//===----------------------------------------------------------------------===*/
13
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"
29#include "llvm/Module.h"
Chris Lattner8e008322007-05-22 06:47:55 +000030#include "llvm/Support/MathExtras.h"
Chris Lattner32eecb02006-02-14 05:14:46 +000031#include <list>
32#include "llvmAsmParser.h"
33#include <cctype>
34#include <cstdlib>
35
36void set_scan_file(FILE * F){
37 yy_switch_to_buffer(yy_create_buffer( F, YY_BUF_SIZE ) );
38}
39void set_scan_string (const char * str) {
40 yy_scan_string (str);
41}
42
Reid Spencer3ed469c2006-11-02 20:25:50 +000043// Construct a token value for a non-obsolete token
Chris Lattner32eecb02006-02-14 05:14:46 +000044#define RET_TOK(type, Enum, sym) \
Reid Spencera132e042006-12-03 05:46:11 +000045 llvmAsmlval.type = Instruction::Enum; \
46 return sym
47
Reid Spencer3ed469c2006-11-02 20:25:50 +000048// Construct a token value for an obsolete token
Reid Spencera132e042006-12-03 05:46:11 +000049#define RET_TY(CTYPE, SYM) \
50 llvmAsmlval.PrimType = CTYPE;\
Reid Spencer481169e2006-12-01 00:33:46 +000051 return SYM
Chris Lattner32eecb02006-02-14 05:14:46 +000052
53namespace llvm {
54
55// TODO: All of the static identifiers are figured out by the lexer,
56// these should be hashed to reduce the lexer size
57
58
59// atoull - Convert an ascii string of decimal digits into the unsigned long
60// long representation... this does not have to do input error checking,
61// because we know that the input will be matched by a suitable regex...
62//
63static uint64_t atoull(const char *Buffer) {
64 uint64_t Result = 0;
65 for (; *Buffer; Buffer++) {
66 uint64_t OldRes = Result;
67 Result *= 10;
68 Result += *Buffer-'0';
69 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000070 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner32eecb02006-02-14 05:14:46 +000071 }
72 return Result;
73}
74
75static uint64_t HexIntToVal(const char *Buffer) {
76 uint64_t Result = 0;
77 for (; *Buffer; ++Buffer) {
78 uint64_t OldRes = Result;
79 Result *= 16;
80 char C = *Buffer;
81 if (C >= '0' && C <= '9')
82 Result += C-'0';
83 else if (C >= 'A' && C <= 'F')
84 Result += C-'A'+10;
85 else if (C >= 'a' && C <= 'f')
86 Result += C-'a'+10;
87
88 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000089 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner32eecb02006-02-14 05:14:46 +000090 }
91 return Result;
92}
93
94
95// HexToFP - Convert the ascii string in hexidecimal format to the floating
96// point representation of it.
97//
98static double HexToFP(const char *Buffer) {
Chris Lattner8e008322007-05-22 06:47:55 +000099 return BitsToDouble(HexIntToVal(Buffer)); // Cast Hex constant to double
Chris Lattner32eecb02006-02-14 05:14:46 +0000100}
101
102
103// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000104// appropriate character.
Reid Spencere2aa9612007-05-22 19:08:16 +0000105char *UnEscapeLexed(char *Buffer, char* EndBuffer) {
Chris Lattner32eecb02006-02-14 05:14:46 +0000106 char *BOut = Buffer;
107 for (char *BIn = Buffer; *BIn; ) {
Reid Spencere2aa9612007-05-22 19:08:16 +0000108 if (BIn[0] == '\\') {
109 if (BIn < EndBuffer-1 && BIn[1] == '\\') {
110 *BOut++ = '\\'; // Two \ becomes one
111 BIn += 2;
112 } else if (BIn < EndBuffer-2 && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
113 char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
114 *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
115 BIn[3] = Tmp; // Restore character
116 BIn += 3; // Skip over handled chars
117 ++BOut;
118 } else {
119 *BOut++ = *BIn++;
120 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000121 } else {
122 *BOut++ = *BIn++;
123 }
124 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000125 return BOut;
126}
127
128} // End llvm namespace
129
130using namespace llvm;
131
132#define YY_NEVER_INTERACTIVE 1
133%}
134
135
136
137/* Comments start with a ; and go till end of line */
138Comment ;.*
139
Reid Spencer41dff5e2007-01-26 08:05:27 +0000140/* Local Values and Type identifiers start with a % sign */
141LocalVarName %[-a-zA-Z$._][-a-zA-Z$._0-9]*
142
143/* Global Value identifiers start with an @ sign */
144GlobalVarName @[-a-zA-Z$._][-a-zA-Z$._0-9]*
Chris Lattner32eecb02006-02-14 05:14:46 +0000145
146/* Label identifiers end with a colon */
147Label [-a-zA-Z$._0-9]+:
148QuoteLabel \"[^\"]+\":
149
150/* Quoted names can contain any character except " and \ */
151StringConstant \"[^\"]*\"
Reid Spencer41dff5e2007-01-26 08:05:27 +0000152AtStringConstant @\"[^\"]*\"
Reid Spencered951ea2007-05-19 07:22:10 +0000153PctStringConstant %\"[^\"]*\"
Reid Spencer41dff5e2007-01-26 08:05:27 +0000154
155/* LocalVarID/GlobalVarID: match an unnamed local variable slot ID. */
156LocalVarID %[0-9]+
157GlobalVarID @[0-9]+
Chris Lattner32eecb02006-02-14 05:14:46 +0000158
Reid Spencer41dff5e2007-01-26 08:05:27 +0000159/* Integer types are specified with i and a bitwidth */
Reid Spencer4db20632007-01-12 07:28:27 +0000160IntegerType i[0-9]+
Reid Spencera54b7cb2007-01-12 07:05:14 +0000161
Reid Spencer41dff5e2007-01-26 08:05:27 +0000162/* E[PN]Integer: match positive and negative literal integer values. */
Chris Lattner32eecb02006-02-14 05:14:46 +0000163PInteger [0-9]+
164NInteger -[0-9]+
165
166/* FPConstant - A Floating point constant.
167 */
168FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
169
170/* HexFPConstant - Floating point constant represented in IEEE format as a
171 * hexadecimal number for when exponential notation is not precise enough.
172 */
173HexFPConstant 0x[0-9A-Fa-f]+
174
175/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
176 * it to deal with 64 bit numbers.
177 */
178HexIntConstant [us]0x[0-9A-Fa-f]+
Reid Spencer38c91a92007-02-28 02:24:54 +0000179
Reid Spencerd8e616b2007-07-31 03:55:56 +0000180/* WSNL - shorthand for whitespace followed by newline */
181WSNL [ \r\t]*$
Chris Lattner32eecb02006-02-14 05:14:46 +0000182%%
183
184{Comment} { /* Ignore comments for now */ }
185
186begin { return BEGINTOK; }
187end { return ENDTOK; }
188true { return TRUETOK; }
189false { return FALSETOK; }
190declare { return DECLARE; }
Reid Spencer6fd36ab2006-12-29 20:35:03 +0000191define { return DEFINE; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000192global { return GLOBAL; }
193constant { return CONSTANT; }
194internal { return INTERNAL; }
195linkonce { return LINKONCE; }
196weak { return WEAK; }
197appending { return APPENDING; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000198dllimport { return DLLIMPORT; }
199dllexport { return DLLEXPORT; }
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000200hidden { return HIDDEN; }
Anton Korobeynikov6f9896f2007-04-29 18:35:00 +0000201protected { return PROTECTED; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000202extern_weak { return EXTERN_WEAK; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000203external { return EXTERNAL; }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000204thread_local { return THREAD_LOCAL; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000205zeroinitializer { return ZEROINITIALIZER; }
206\.\.\. { return DOTDOTDOT; }
207undef { return UNDEF; }
208null { return NULL_TOK; }
209to { return TO; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000210tail { return TAIL; }
211target { return TARGET; }
212triple { return TRIPLE; }
213deplibs { return DEPLIBS; }
Chris Lattner1ae022f2006-10-22 06:08:13 +0000214datalayout { return DATALAYOUT; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000215volatile { return VOLATILE; }
216align { return ALIGN; }
217section { return SECTION; }
Anton Korobeynikov77d0f972007-04-25 14:29:12 +0000218alias { return ALIAS; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000219module { return MODULE; }
220asm { return ASM_TOK; }
221sideeffect { return SIDEEFFECT; }
222
223cc { return CC_TOK; }
224ccc { return CCC_TOK; }
225fastcc { return FASTCC_TOK; }
226coldcc { return COLDCC_TOK; }
Anton Korobeynikovbcb97702006-09-17 20:25:45 +0000227x86_stdcallcc { return X86_STDCALLCC_TOK; }
228x86_fastcallcc { return X86_FASTCALLCC_TOK; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000229
Reid Spencerb8f85052007-07-31 03:50:36 +0000230signext { return SIGNEXT; }
231zeroext { return ZEROEXT; }
Reid Spencer832254e2007-02-02 02:16:23 +0000232inreg { return INREG; }
233sret { return SRET; }
Reid Spencer67d8ed92007-03-22 02:14:08 +0000234nounwind { return NOUNWIND; }
235noreturn { return NORETURN; }
Chris Lattnerce5f24e2007-07-05 17:26:49 +0000236noalias { return NOALIAS; }
Reid Spencerb8f85052007-07-31 03:50:36 +0000237byval { return BYVAL; }
238nest { return NEST; }
239sext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
240 return SIGNEXT; }
241zext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
242 return ZEROEXT; }
Reid Spencer832254e2007-02-02 02:16:23 +0000243
Reid Spencera132e042006-12-03 05:46:11 +0000244void { RET_TY(Type::VoidTy, VOID); }
Reid Spencera132e042006-12-03 05:46:11 +0000245float { RET_TY(Type::FloatTy, FLOAT); }
246double { RET_TY(Type::DoubleTy,DOUBLE);}
Dale Johannesen320fc8a2007-08-03 01:03:46 +0000247x86_fp80 { RET_TY(Type::X86_FP80Ty, X86_FP80);}
248fp128 { RET_TY(Type::FP128Ty, FP128);}
249ppc_fp128 { RET_TY(Type::PPC_FP128Ty, PPC_FP128);}
Reid Spencera132e042006-12-03 05:46:11 +0000250label { RET_TY(Type::LabelTy, LABEL); }
Chris Lattner32eecb02006-02-14 05:14:46 +0000251type { return TYPE; }
252opaque { return OPAQUE; }
Reid Spencera54b7cb2007-01-12 07:05:14 +0000253{IntegerType} { uint64_t NumBits = atoull(yytext+1);
254 if (NumBits < IntegerType::MIN_INT_BITS ||
255 NumBits > IntegerType::MAX_INT_BITS)
256 GenerateError("Bitwidth for integer type out of range!");
257 const Type* Ty = IntegerType::get(NumBits);
258 RET_TY(Ty, INTTYPE);
259 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000260
261add { RET_TOK(BinaryOpVal, Add, ADD); }
262sub { RET_TOK(BinaryOpVal, Sub, SUB); }
263mul { RET_TOK(BinaryOpVal, Mul, MUL); }
Reid Spencer3ed469c2006-11-02 20:25:50 +0000264udiv { RET_TOK(BinaryOpVal, UDiv, UDIV); }
265sdiv { RET_TOK(BinaryOpVal, SDiv, SDIV); }
266fdiv { RET_TOK(BinaryOpVal, FDiv, FDIV); }
Reid Spencer3ed469c2006-11-02 20:25:50 +0000267urem { RET_TOK(BinaryOpVal, URem, UREM); }
268srem { RET_TOK(BinaryOpVal, SRem, SREM); }
269frem { RET_TOK(BinaryOpVal, FRem, FREM); }
Reid Spencer832254e2007-02-02 02:16:23 +0000270shl { RET_TOK(BinaryOpVal, Shl, SHL); }
271lshr { RET_TOK(BinaryOpVal, LShr, LSHR); }
272ashr { RET_TOK(BinaryOpVal, AShr, ASHR); }
Chris Lattner32eecb02006-02-14 05:14:46 +0000273and { RET_TOK(BinaryOpVal, And, AND); }
274or { RET_TOK(BinaryOpVal, Or , OR ); }
275xor { RET_TOK(BinaryOpVal, Xor, XOR); }
Reid Spencera132e042006-12-03 05:46:11 +0000276icmp { RET_TOK(OtherOpVal, ICmp, ICMP); }
277fcmp { RET_TOK(OtherOpVal, FCmp, FCMP); }
Reid Spencer832254e2007-02-02 02:16:23 +0000278
Reid Spencer6e18b7d2006-12-03 06:59:29 +0000279eq { return EQ; }
280ne { return NE; }
281slt { return SLT; }
282sgt { return SGT; }
283sle { return SLE; }
284sge { return SGE; }
285ult { return ULT; }
286ugt { return UGT; }
287ule { return ULE; }
288uge { return UGE; }
289oeq { return OEQ; }
290one { return ONE; }
291olt { return OLT; }
292ogt { return OGT; }
293ole { return OLE; }
294oge { return OGE; }
295ord { return ORD; }
296uno { return UNO; }
297ueq { return UEQ; }
298une { return UNE; }
Chris Lattner32eecb02006-02-14 05:14:46 +0000299
300phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
301call { RET_TOK(OtherOpVal, Call, CALL); }
Reid Spencer3da59db2006-11-27 01:05:10 +0000302trunc { RET_TOK(CastOpVal, Trunc, TRUNC); }
303zext { RET_TOK(CastOpVal, ZExt, ZEXT); }
304sext { RET_TOK(CastOpVal, SExt, SEXT); }
305fptrunc { RET_TOK(CastOpVal, FPTrunc, FPTRUNC); }
306fpext { RET_TOK(CastOpVal, FPExt, FPEXT); }
307uitofp { RET_TOK(CastOpVal, UIToFP, UITOFP); }
308sitofp { RET_TOK(CastOpVal, SIToFP, SITOFP); }
309fptoui { RET_TOK(CastOpVal, FPToUI, FPTOUI); }
310fptosi { RET_TOK(CastOpVal, FPToSI, FPTOSI); }
311inttoptr { RET_TOK(CastOpVal, IntToPtr, INTTOPTR); }
312ptrtoint { RET_TOK(CastOpVal, PtrToInt, PTRTOINT); }
313bitcast { RET_TOK(CastOpVal, BitCast, BITCAST); }
Chris Lattner32eecb02006-02-14 05:14:46 +0000314select { RET_TOK(OtherOpVal, Select, SELECT); }
Chris Lattner32eecb02006-02-14 05:14:46 +0000315va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); }
316ret { RET_TOK(TermOpVal, Ret, RET); }
317br { RET_TOK(TermOpVal, Br, BR); }
318switch { RET_TOK(TermOpVal, Switch, SWITCH); }
319invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
320unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
321unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
322
323malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
324alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
325free { RET_TOK(MemOpVal, Free, FREE); }
326load { RET_TOK(MemOpVal, Load, LOAD); }
327store { RET_TOK(MemOpVal, Store, STORE); }
328getelementptr { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
329
330extractelement { RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); }
331insertelement { RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); }
Chris Lattnerd5efe842006-04-08 01:18:56 +0000332shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
Chris Lattner32eecb02006-02-14 05:14:46 +0000333
334
Reid Spencer41dff5e2007-01-26 08:05:27 +0000335{LocalVarName} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000336 llvmAsmlval.StrVal = new std::string(yytext+1); // Skip %
Reid Spencer41dff5e2007-01-26 08:05:27 +0000337 return LOCALVAR;
338 }
339{GlobalVarName} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000340 llvmAsmlval.StrVal = new std::string(yytext+1); // Skip @
Reid Spencer41dff5e2007-01-26 08:05:27 +0000341 return GLOBALVAR;
Chris Lattner32eecb02006-02-14 05:14:46 +0000342 }
343{Label} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000344 yytext[yyleng-1] = 0; // nuke colon
345 llvmAsmlval.StrVal = new std::string(yytext);
Chris Lattner32eecb02006-02-14 05:14:46 +0000346 return LABELSTR;
347 }
348{QuoteLabel} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000349 yytext[yyleng-2] = 0; // nuke colon, end quote
Reid Spencere2aa9612007-05-22 19:08:16 +0000350 const char* EndChar = UnEscapeLexed(yytext+1, yytext+yyleng);
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000351 llvmAsmlval.StrVal =
352 new std::string(yytext+1, EndChar - yytext - 1);
Chris Lattner32eecb02006-02-14 05:14:46 +0000353 return LABELSTR;
354 }
355
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000356{StringConstant} { yytext[yyleng-1] = 0; // nuke end quote
Reid Spencere2aa9612007-05-22 19:08:16 +0000357 const char* EndChar = UnEscapeLexed(yytext+1, yytext+yyleng);
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000358 llvmAsmlval.StrVal =
359 new std::string(yytext+1, EndChar - yytext - 1);
Chris Lattner32eecb02006-02-14 05:14:46 +0000360 return STRINGCONSTANT;
361 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000362{AtStringConstant} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000363 yytext[yyleng-1] = 0; // nuke end quote
Reid Spencere2aa9612007-05-22 19:08:16 +0000364 const char* EndChar =
365 UnEscapeLexed(yytext+2, yytext+yyleng);
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000366 llvmAsmlval.StrVal =
367 new std::string(yytext+2, EndChar - yytext - 2);
Reid Spencer41dff5e2007-01-26 08:05:27 +0000368 return ATSTRINGCONSTANT;
369 }
Reid Spencered951ea2007-05-19 07:22:10 +0000370{PctStringConstant} {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000371 yytext[yyleng-1] = 0; // nuke end quote
Reid Spencere2aa9612007-05-22 19:08:16 +0000372 const char* EndChar =
373 UnEscapeLexed(yytext+2, yytext+yyleng);
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000374 llvmAsmlval.StrVal =
375 new std::string(yytext+2, EndChar - yytext - 2);
Reid Spencered951ea2007-05-19 07:22:10 +0000376 return PCTSTRINGCONSTANT;
377 }
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000378{PInteger} {
379 uint32_t numBits = ((yyleng * 64) / 19) + 1;
380 APInt Tmp(numBits, yytext, yyleng, 10);
Reid Spencer38c91a92007-02-28 02:24:54 +0000381 uint32_t activeBits = Tmp.getActiveBits();
382 if (activeBits > 0 && activeBits < numBits)
383 Tmp.trunc(activeBits);
384 if (Tmp.getBitWidth() > 64) {
385 llvmAsmlval.APIntVal = new APInt(Tmp);
386 return EUAPINTVAL;
387 } else {
388 llvmAsmlval.UInt64Val = Tmp.getZExtValue();
389 return EUINT64VAL;
390 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000391 }
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000392{NInteger} {
393 uint32_t numBits = (((yyleng-1) * 64) / 19) + 2;
394 APInt Tmp(numBits, yytext, yyleng, 10);
Reid Spencer38c91a92007-02-28 02:24:54 +0000395 uint32_t minBits = Tmp.getMinSignedBits();
396 if (minBits > 0 && minBits < numBits)
397 Tmp.trunc(minBits);
398 if (Tmp.getBitWidth() > 64) {
399 llvmAsmlval.APIntVal = new APInt(Tmp);
400 return ESAPINTVAL;
401 } else {
402 llvmAsmlval.SInt64Val = Tmp.getSExtValue();
403 return ESINT64VAL;
404 }
405 }
406
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000407{HexIntConstant} { int len = yyleng - 3;
Reid Spencer38c91a92007-02-28 02:24:54 +0000408 uint32_t bits = len * 4;
409 APInt Tmp(bits, yytext+3, len, 16);
410 uint32_t activeBits = Tmp.getActiveBits();
411 if (activeBits > 0 && activeBits < bits)
412 Tmp.trunc(activeBits);
413 if (Tmp.getBitWidth() > 64) {
414 llvmAsmlval.APIntVal = new APInt(Tmp);
415 return yytext[0] == 's' ? ESAPINTVAL : EUAPINTVAL;
416 } else if (yytext[0] == 's') {
417 llvmAsmlval.SInt64Val = Tmp.getSExtValue();
418 return ESINT64VAL;
419 } else {
420 llvmAsmlval.UInt64Val = Tmp.getZExtValue();
421 return EUINT64VAL;
422 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000423 }
424
Reid Spencer41dff5e2007-01-26 08:05:27 +0000425{LocalVarID} {
Chris Lattner32eecb02006-02-14 05:14:46 +0000426 uint64_t Val = atoull(yytext+1);
427 if ((unsigned)Val != Val)
Reid Spencer61c83e02006-08-18 08:43:06 +0000428 GenerateError("Invalid value number (too large)!");
Chris Lattner32eecb02006-02-14 05:14:46 +0000429 llvmAsmlval.UIntVal = unsigned(Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +0000430 return LOCALVAL_ID;
Chris Lattner32eecb02006-02-14 05:14:46 +0000431 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000432{GlobalVarID} {
433 uint64_t Val = atoull(yytext+1);
434 if ((unsigned)Val != Val)
435 GenerateError("Invalid value number (too large)!");
436 llvmAsmlval.UIntVal = unsigned(Val);
437 return GLOBALVAL_ID;
Chris Lattner32eecb02006-02-14 05:14:46 +0000438 }
439
Dale Johannesen43421b32007-09-06 18:13:44 +0000440{FPConstant} { llvmAsmlval.FPVal = new APFloat(atof(yytext)); return FPVAL; }
441{HexFPConstant} { llvmAsmlval.FPVal = new APFloat(HexToFP(yytext));
442 return FPVAL;
443 }
Chris Lattner32eecb02006-02-14 05:14:46 +0000444
445<<EOF>> {
446 /* Make sure to free the internal buffers for flex when we are
447 * done reading our input!
448 */
449 yy_delete_buffer(YY_CURRENT_BUFFER);
450 return EOF;
451 }
452
453[ \r\t\n] { /* Ignore whitespace */ }
454. { return yytext[0]; }
455
456%%