blob: 96804bb75b4edb8eb710897e18d2de4bb87dcef7 [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 Spencer1628cec2006-10-26 06:15:43 +000044 llvmAsmlval.type.opcode = Instruction::Enum; \
45 llvmAsmlval.type.obsolete = false; \
46 return sym
47
48// Construct a token value for an obsolete token
49#define RET_TOK_OBSOLETE(type, Enum, sym) \
50 llvmAsmlval.type.opcode = Instruction::Enum; \
51 llvmAsmlval.type.obsolete = true; \
52 return sym
53
Chris Lattner00950542001-06-06 20:29:01 +000054
Brian Gaeked0fde302003-11-11 22:41:34 +000055namespace llvm {
Chris Lattner00950542001-06-06 20:29:01 +000056
Misha Brukman5a2a3822005-05-10 22:02:28 +000057// TODO: All of the static identifiers are figured out by the lexer,
Chris Lattnere1fe8752001-09-07 16:32:43 +000058// these should be hashed to reduce the lexer size
Chris Lattner00950542001-06-06 20:29:01 +000059
60
61// atoull - Convert an ascii string of decimal digits into the unsigned long
Misha Brukman5a2a3822005-05-10 22:02:28 +000062// long representation... this does not have to do input error checking,
Chris Lattner00950542001-06-06 20:29:01 +000063// because we know that the input will be matched by a suitable regex...
64//
Chris Lattner275da862002-04-07 08:10:41 +000065static uint64_t atoull(const char *Buffer) {
Chris Lattner00950542001-06-06 20:29:01 +000066 uint64_t Result = 0;
67 for (; *Buffer; Buffer++) {
68 uint64_t OldRes = Result;
69 Result *= 10;
70 Result += *Buffer-'0';
Chris Lattner275da862002-04-07 08:10:41 +000071 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000072 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner00950542001-06-06 20:29:01 +000073 }
74 return Result;
75}
76
Chris Lattner3e8ba102003-04-17 22:17:32 +000077static uint64_t HexIntToVal(const char *Buffer) {
Chris Lattner275da862002-04-07 08:10:41 +000078 uint64_t Result = 0;
79 for (; *Buffer; ++Buffer) {
80 uint64_t OldRes = Result;
81 Result *= 16;
82 char C = *Buffer;
83 if (C >= '0' && C <= '9')
84 Result += C-'0';
85 else if (C >= 'A' && C <= 'F')
86 Result += C-'A'+10;
87 else if (C >= 'a' && C <= 'f')
88 Result += C-'a'+10;
89
90 if (Result < OldRes) // Uh, oh, overflow detected!!!
Reid Spencer61c83e02006-08-18 08:43:06 +000091 GenerateError("constant bigger than 64 bits detected!");
Chris Lattner275da862002-04-07 08:10:41 +000092 }
Chris Lattner3e8ba102003-04-17 22:17:32 +000093 return Result;
94}
95
96
97// HexToFP - Convert the ascii string in hexidecimal format to the floating
98// point representation of it.
99//
100static double HexToFP(const char *Buffer) {
Chris Lattnerb55679d2002-04-07 08:31:26 +0000101 // Behave nicely in the face of C TBAA rules... see:
102 // http://www.nullstone.com/htmls/category/aliastyp.htm
Chris Lattner7a5a1f72003-04-22 20:20:28 +0000103 union {
104 uint64_t UI;
105 double FP;
106 } UIntToFP;
107 UIntToFP.UI = HexIntToVal(Buffer);
108
109 assert(sizeof(double) == sizeof(uint64_t) &&
110 "Data sizes incompatible on this target!");
111 return UIntToFP.FP; // Cast Hex constant to double
Chris Lattner275da862002-04-07 08:10:41 +0000112}
113
Chris Lattner00950542001-06-06 20:29:01 +0000114
Chris Lattner93750fa2001-07-28 17:48:55 +0000115// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
116// appropriate character. If AllowNull is set to false, a \00 value will cause
117// an exception to be thrown.
118//
119// If AllowNull is set to true, the return value of the function points to the
120// last character of the string in memory.
121//
Chris Lattnerbcafcce2002-07-25 06:17:42 +0000122char *UnEscapeLexed(char *Buffer, bool AllowNull) {
Chris Lattner93750fa2001-07-28 17:48:55 +0000123 char *BOut = Buffer;
124 for (char *BIn = Buffer; *BIn; ) {
125 if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
126 char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
Chris Lattnera8101c12005-01-08 20:07:03 +0000127 *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
Chris Lattner93750fa2001-07-28 17:48:55 +0000128 if (!AllowNull && !*BOut)
Reid Spencer61c83e02006-08-18 08:43:06 +0000129 GenerateError("String literal cannot accept \\00 escape!");
Misha Brukman5a2a3822005-05-10 22:02:28 +0000130
Chris Lattner93750fa2001-07-28 17:48:55 +0000131 BIn[3] = Tmp; // Restore character
132 BIn += 3; // Skip over handled chars
133 ++BOut;
134 } else {
135 *BOut++ = *BIn++;
136 }
137 }
138
139 return BOut;
140}
141
Brian Gaeked0fde302003-11-11 22:41:34 +0000142} // End llvm namespace
143
144using namespace llvm;
145
Chris Lattner00950542001-06-06 20:29:01 +0000146#define YY_NEVER_INTERACTIVE 1
147%}
148
149
150
151/* Comments start with a ; and go till end of line */
152Comment ;.*
153
Chris Lattnere1815642001-07-15 06:35:53 +0000154/* Variable(Value) identifiers start with a % sign */
Chris Lattner9a88d272001-12-04 04:31:30 +0000155VarID %[-a-zA-Z$._][-a-zA-Z$._0-9]*
Chris Lattner00950542001-06-06 20:29:01 +0000156
157/* Label identifiers end with a colon */
Chris Lattner9a88d272001-12-04 04:31:30 +0000158Label [-a-zA-Z$._0-9]+:
Alkis Evlogimenosd82ef512004-12-10 05:40:19 +0000159QuoteLabel \"[^\"]+\":
Chris Lattner00950542001-06-06 20:29:01 +0000160
161/* Quoted names can contain any character except " and \ */
Chris Lattner99e7ab72003-10-18 05:53:13 +0000162StringConstant \"[^\"]*\"
Chris Lattner00950542001-06-06 20:29:01 +0000163
164
165/* [PN]Integer: match positive and negative literal integer values that
166 * are preceeded by a '%' character. These represent unnamed variable slots.
167 */
168EPInteger %[0-9]+
169ENInteger %-[0-9]+
170
171
172/* E[PN]Integer: match positive and negative literal integer values */
173PInteger [0-9]+
174NInteger -[0-9]+
175
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000176/* FPConstant - A Floating point constant.
Chris Lattner275da862002-04-07 08:10:41 +0000177 */
Chris Lattner1e2c6142001-11-01 22:06:08 +0000178FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000179
Chris Lattner275da862002-04-07 08:10:41 +0000180/* HexFPConstant - Floating point constant represented in IEEE format as a
181 * hexadecimal number for when exponential notation is not precise enough.
182 */
183HexFPConstant 0x[0-9A-Fa-f]+
Chris Lattner3e8ba102003-04-17 22:17:32 +0000184
185/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
186 * it to deal with 64 bit numbers.
187 */
188HexIntConstant [us]0x[0-9A-Fa-f]+
Chris Lattner00950542001-06-06 20:29:01 +0000189%%
190
191{Comment} { /* Ignore comments for now */ }
192
193begin { return BEGINTOK; }
Chris Lattner9b02cc32002-05-03 18:23:48 +0000194end { return ENDTOK; }
Chris Lattner91ef4602004-03-31 03:49:47 +0000195true { return TRUETOK; }
196false { return FALSETOK; }
Chris Lattner00950542001-06-06 20:29:01 +0000197declare { return DECLARE; }
Chris Lattner70cc3392001-09-10 07:58:01 +0000198global { return GLOBAL; }
Chris Lattner1781aca2001-09-18 04:00:54 +0000199constant { return CONSTANT; }
Chris Lattnerdda71962001-11-26 18:54:16 +0000200internal { return INTERNAL; }
Chris Lattner4ad02e72003-04-16 20:28:45 +0000201linkonce { return LINKONCE; }
Chris Lattnerf797cab2003-10-10 04:54:02 +0000202weak { return WEAK; }
Chris Lattner4ad02e72003-04-16 20:28:45 +0000203appending { return APPENDING; }
Anton Korobeynikovb74ed072006-09-14 18:23:27 +0000204dllimport { return DLLIMPORT; }
205dllexport { return DLLEXPORT; }
206extern_weak { return EXTERN_WEAK; }
Chris Lattner08c0e6a2002-10-06 22:45:09 +0000207uninitialized { return EXTERNAL; } /* Deprecated, turn into external */
208external { return EXTERNAL; }
Chris Lattner00950542001-06-06 20:29:01 +0000209implementation { return IMPLEMENTATION; }
Chris Lattnerf4600482003-06-28 20:01:34 +0000210zeroinitializer { return ZEROINITIALIZER; }
Chris Lattner8b81bf52001-07-25 22:47:46 +0000211\.\.\. { return DOTDOTDOT; }
Chris Lattner16710e92004-10-16 18:17:13 +0000212undef { return UNDEF; }
Chris Lattner1a1cb112001-09-30 22:46:54 +0000213null { return NULL_TOK; }
Chris Lattner5efbbc22001-10-13 06:37:14 +0000214to { return TO; }
Chris Lattnera58e3a12004-02-08 21:48:25 +0000215except { RET_TOK(TermOpVal, Unwind, UNWIND); }
Chris Lattner699f1eb2002-08-14 17:12:33 +0000216not { return NOT; } /* Deprecated, turned into XOR */
Chris Lattnerc28ade42005-05-06 06:20:33 +0000217tail { return TAIL; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000218target { return TARGET; }
Reid Spencer3cd2fe32004-07-25 17:56:00 +0000219triple { return TRIPLE; }
220deplibs { return DEPLIBS; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000221endian { return ENDIAN; }
222pointersize { return POINTERSIZE; }
Chris Lattner10b27112006-10-22 06:07:41 +0000223datalayout { return DATALAYOUT; }
Chris Lattnerb9bcbb52003-04-22 19:07:06 +0000224little { return LITTLE; }
225big { return BIG; }
Chris Lattner15c9c032003-09-08 18:20:29 +0000226volatile { return VOLATILE; }
Chris Lattnerb7d08a52005-11-12 00:11:30 +0000227align { return ALIGN; }
228section { return SECTION; }
Chris Lattner71cdba32006-01-24 00:40:17 +0000229module { return MODULE; }
Chris Lattneree454772006-01-23 23:05:15 +0000230asm { return ASM_TOK; }
Chris Lattneraa2c8532006-01-25 22:26:43 +0000231sideeffect { return SIDEEFFECT; }
Chris Lattner00950542001-06-06 20:29:01 +0000232
Chris Lattnera8e8f162005-05-06 20:27:19 +0000233cc { return CC_TOK; }
234ccc { return CCC_TOK; }
Chris Lattner515906d2006-05-19 21:28:34 +0000235csretcc { return CSRETCC_TOK; }
Chris Lattnera8e8f162005-05-06 20:27:19 +0000236fastcc { return FASTCC_TOK; }
237coldcc { return COLDCC_TOK; }
Anton Korobeynikovbcb97702006-09-17 20:25:45 +0000238x86_stdcallcc { return X86_STDCALLCC_TOK; }
239x86_fastcallcc { return X86_FASTCALLCC_TOK; }
Chris Lattnera8e8f162005-05-06 20:27:19 +0000240
Chris Lattnere1fe8752001-09-07 16:32:43 +0000241void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; }
242bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; }
243sbyte { llvmAsmlval.PrimType = Type::SByteTy ; return SBYTE; }
244ubyte { llvmAsmlval.PrimType = Type::UByteTy ; return UBYTE; }
245short { llvmAsmlval.PrimType = Type::ShortTy ; return SHORT; }
246ushort { llvmAsmlval.PrimType = Type::UShortTy; return USHORT; }
247int { llvmAsmlval.PrimType = Type::IntTy ; return INT; }
248uint { llvmAsmlval.PrimType = Type::UIntTy ; return UINT; }
249long { llvmAsmlval.PrimType = Type::LongTy ; return LONG; }
250ulong { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG; }
251float { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT; }
252double { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; }
Chris Lattnere1fe8752001-09-07 16:32:43 +0000253label { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; }
Reid Spencer77f4d862004-07-04 12:17:44 +0000254type { return TYPE; }
Chris Lattner4e4cae82002-04-04 19:22:17 +0000255opaque { return OPAQUE; }
Chris Lattner00950542001-06-06 20:29:01 +0000256
Chris Lattner00950542001-06-06 20:29:01 +0000257add { RET_TOK(BinaryOpVal, Add, ADD); }
258sub { RET_TOK(BinaryOpVal, Sub, SUB); }
259mul { RET_TOK(BinaryOpVal, Mul, MUL); }
Reid Spencer1628cec2006-10-26 06:15:43 +0000260div { RET_TOK_OBSOLETE(BinaryOpVal, UDiv, UDIV); }
261udiv { RET_TOK(BinaryOpVal, UDiv, UDIV); }
262sdiv { RET_TOK(BinaryOpVal, SDiv, SDIV); }
263fdiv { RET_TOK(BinaryOpVal, FDiv, FDIV); }
Chris Lattner00950542001-06-06 20:29:01 +0000264rem { RET_TOK(BinaryOpVal, Rem, REM); }
Chris Lattner42c9e772001-10-20 09:32:59 +0000265and { RET_TOK(BinaryOpVal, And, AND); }
266or { RET_TOK(BinaryOpVal, Or , OR ); }
267xor { RET_TOK(BinaryOpVal, Xor, XOR); }
Chris Lattner00950542001-06-06 20:29:01 +0000268setne { RET_TOK(BinaryOpVal, SetNE, SETNE); }
269seteq { RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
270setlt { RET_TOK(BinaryOpVal, SetLT, SETLT); }
271setgt { RET_TOK(BinaryOpVal, SetGT, SETGT); }
272setle { RET_TOK(BinaryOpVal, SetLE, SETLE); }
273setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
274
Chris Lattner3b237fc2003-10-19 21:34:28 +0000275phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
Chris Lattner027dcc52001-07-08 21:10:27 +0000276call { RET_TOK(OtherOpVal, Call, CALL); }
277cast { RET_TOK(OtherOpVal, Cast, CAST); }
Chris Lattner76f0ff32004-03-12 05:51:36 +0000278select { RET_TOK(OtherOpVal, Select, SELECT); }
Chris Lattner027dcc52001-07-08 21:10:27 +0000279shl { RET_TOK(OtherOpVal, Shl, SHL); }
280shr { RET_TOK(OtherOpVal, Shr, SHR); }
Andrew Lenharth558bc882005-06-18 18:34:52 +0000281vanext { return VANEXT_old; }
282vaarg { return VAARG_old; }
283va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); }
Chris Lattner00950542001-06-06 20:29:01 +0000284ret { RET_TOK(TermOpVal, Ret, RET); }
285br { RET_TOK(TermOpVal, Br, BR); }
286switch { RET_TOK(TermOpVal, Switch, SWITCH); }
Chris Lattner5efbbc22001-10-13 06:37:14 +0000287invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
Chris Lattner36143fc2003-09-08 18:54:55 +0000288unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
Chris Lattner16710e92004-10-16 18:17:13 +0000289unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
Chris Lattner00950542001-06-06 20:29:01 +0000290
291malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
292alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
293free { RET_TOK(MemOpVal, Free, FREE); }
294load { RET_TOK(MemOpVal, Load, LOAD); }
295store { RET_TOK(MemOpVal, Store, STORE); }
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000296getelementptr { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
Chris Lattner00950542001-06-06 20:29:01 +0000297
Robert Bocchino9c62b562006-01-10 19:04:32 +0000298extractelement { RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); }
Robert Bocchino2def1b32006-01-17 20:06:25 +0000299insertelement { RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); }
Chris Lattner4c949082006-04-08 01:18:35 +0000300shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
Robert Bocchino9c62b562006-01-10 19:04:32 +0000301
Chris Lattner00950542001-06-06 20:29:01 +0000302
Chris Lattner93750fa2001-07-28 17:48:55 +0000303{VarID} {
304 UnEscapeLexed(yytext+1);
305 llvmAsmlval.StrVal = strdup(yytext+1); // Skip %
Misha Brukman5a2a3822005-05-10 22:02:28 +0000306 return VAR_ID;
Chris Lattner93750fa2001-07-28 17:48:55 +0000307 }
308{Label} {
Chris Lattner00950542001-06-06 20:29:01 +0000309 yytext[strlen(yytext)-1] = 0; // nuke colon
Chris Lattner93750fa2001-07-28 17:48:55 +0000310 UnEscapeLexed(yytext);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000311 llvmAsmlval.StrVal = strdup(yytext);
312 return LABELSTR;
Chris Lattner00950542001-06-06 20:29:01 +0000313 }
Chris Lattnerc6c97722004-12-10 05:27:29 +0000314{QuoteLabel} {
315 yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
316 UnEscapeLexed(yytext+1);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000317 llvmAsmlval.StrVal = strdup(yytext+1);
318 return LABELSTR;
Chris Lattnerc6c97722004-12-10 05:27:29 +0000319 }
Chris Lattner00950542001-06-06 20:29:01 +0000320
Chris Lattner93750fa2001-07-28 17:48:55 +0000321{StringConstant} { // Note that we cannot unescape a string constant here! The
Misha Brukman5a2a3822005-05-10 22:02:28 +0000322 // string constant might contain a \00 which would not be
Chris Lattner93750fa2001-07-28 17:48:55 +0000323 // understood by the string stuff. It is valid to make a
324 // [sbyte] c"Hello World\00" constant, for example.
325 //
Misha Brukman5a2a3822005-05-10 22:02:28 +0000326 yytext[strlen(yytext)-1] = 0; // nuke end quote
327 llvmAsmlval.StrVal = strdup(yytext+1); // Nuke start quote
328 return STRINGCONSTANT;
Chris Lattner93750fa2001-07-28 17:48:55 +0000329 }
Chris Lattner00950542001-06-06 20:29:01 +0000330
331
332{PInteger} { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
Misha Brukman5a2a3822005-05-10 22:02:28 +0000333{NInteger} {
Chris Lattner00950542001-06-06 20:29:01 +0000334 uint64_t Val = atoull(yytext+1);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000335 // +1: we have bigger negative range
336 if (Val > (uint64_t)INT64_MAX+1)
Reid Spencer61c83e02006-08-18 08:43:06 +0000337 GenerateError("Constant too large for signed 64 bits!");
Misha Brukman5a2a3822005-05-10 22:02:28 +0000338 llvmAsmlval.SInt64Val = -Val;
339 return ESINT64VAL;
Chris Lattner00950542001-06-06 20:29:01 +0000340 }
Chris Lattner3e8ba102003-04-17 22:17:32 +0000341{HexIntConstant} {
Misha Brukman5a2a3822005-05-10 22:02:28 +0000342 llvmAsmlval.UInt64Val = HexIntToVal(yytext+3);
Chris Lattner3e8ba102003-04-17 22:17:32 +0000343 return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
344 }
Chris Lattner00950542001-06-06 20:29:01 +0000345
Chris Lattnera8101c12005-01-08 20:07:03 +0000346{EPInteger} {
347 uint64_t Val = atoull(yytext+1);
348 if ((unsigned)Val != Val)
Reid Spencer61c83e02006-08-18 08:43:06 +0000349 GenerateError("Invalid value number (too large)!");
Chris Lattnera8101c12005-01-08 20:07:03 +0000350 llvmAsmlval.UIntVal = unsigned(Val);
351 return UINTVAL;
352 }
Chris Lattner00950542001-06-06 20:29:01 +0000353{ENInteger} {
354 uint64_t Val = atoull(yytext+2);
Misha Brukman5a2a3822005-05-10 22:02:28 +0000355 // +1: we have bigger negative range
356 if (Val > (uint64_t)INT32_MAX+1)
Reid Spencer61c83e02006-08-18 08:43:06 +0000357 GenerateError("Constant too large for signed 32 bits!");
Chris Lattnera8101c12005-01-08 20:07:03 +0000358 llvmAsmlval.SIntVal = (int)-Val;
Misha Brukman5a2a3822005-05-10 22:02:28 +0000359 return SINTVAL;
Chris Lattner00950542001-06-06 20:29:01 +0000360 }
361
Chris Lattner3d52b2f2001-07-15 00:17:01 +0000362{FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }
Chris Lattner275da862002-04-07 08:10:41 +0000363{HexFPConstant} { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; }
Chris Lattner00950542001-06-06 20:29:01 +0000364
Chris Lattnere1512592004-03-19 23:34:33 +0000365<<EOF>> {
366 /* Make sure to free the internal buffers for flex when we are
367 * done reading our input!
368 */
369 yy_delete_buffer(YY_CURRENT_BUFFER);
370 return EOF;
371 }
372
Chris Lattnera0846a32004-05-27 17:49:14 +0000373[ \r\t\n] { /* Ignore whitespace */ }
Chris Lattnere1fe8752001-09-07 16:32:43 +0000374. { return yytext[0]; }
Chris Lattner00950542001-06-06 20:29:01 +0000375
376%%