blob: 75c460919c08fd955e7dc1a6a87261ab153eb277 [file] [log] [blame]
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00007
Reid Spencer38c91a92007-02-28 02:24:54 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000012
Reid Spencer38c91a92007-02-28 02:24:54 +000013 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +000023/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
Reid Spencer38c91a92007-02-28 02:24:54 +000032
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +000033 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
Reid Spencer38c91a92007-02-28 02:24:54 +000038
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +000050#define YYBISON_VERSION "2.3"
Reid Spencer38c91a92007-02-28 02:24:54 +000051
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Reid Spencer38c91a92007-02-28 02:24:54 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Reid Spencer38c91a92007-02-28 02:24:54 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Reid Spencer38c91a92007-02-28 02:24:54 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 LABEL = 269,
89 TYPE = 270,
90 LOCALVAR = 271,
91 GLOBALVAR = 272,
92 LABELSTR = 273,
93 STRINGCONSTANT = 274,
94 ATSTRINGCONSTANT = 275,
Reid Spencer3d6b71e2007-04-09 01:56:05 +000095 ZEROINITIALIZER = 276,
96 TRUETOK = 277,
97 FALSETOK = 278,
98 BEGINTOK = 279,
99 ENDTOK = 280,
100 DECLARE = 281,
101 DEFINE = 282,
102 GLOBAL = 283,
103 CONSTANT = 284,
104 SECTION = 285,
105 VOLATILE = 286,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000106 THREAD_LOCAL = 287,
107 TO = 288,
108 DOTDOTDOT = 289,
109 NULL_TOK = 290,
110 UNDEF = 291,
111 INTERNAL = 292,
112 LINKONCE = 293,
113 WEAK = 294,
114 APPENDING = 295,
115 DLLIMPORT = 296,
116 DLLEXPORT = 297,
117 EXTERN_WEAK = 298,
118 OPAQUE = 299,
119 EXTERNAL = 300,
120 TARGET = 301,
121 TRIPLE = 302,
122 ALIGN = 303,
123 DEPLIBS = 304,
124 CALL = 305,
125 TAIL = 306,
126 ASM_TOK = 307,
127 MODULE = 308,
128 SIDEEFFECT = 309,
129 CC_TOK = 310,
130 CCC_TOK = 311,
131 FASTCC_TOK = 312,
132 COLDCC_TOK = 313,
133 X86_STDCALLCC_TOK = 314,
134 X86_FASTCALLCC_TOK = 315,
135 DATALAYOUT = 316,
136 RET = 317,
137 BR = 318,
138 SWITCH = 319,
139 INVOKE = 320,
140 UNWIND = 321,
141 UNREACHABLE = 322,
142 ADD = 323,
143 SUB = 324,
144 MUL = 325,
145 UDIV = 326,
146 SDIV = 327,
147 FDIV = 328,
148 UREM = 329,
149 SREM = 330,
150 FREM = 331,
151 AND = 332,
152 OR = 333,
153 XOR = 334,
154 SHL = 335,
155 LSHR = 336,
156 ASHR = 337,
157 ICMP = 338,
158 FCMP = 339,
159 EQ = 340,
160 NE = 341,
161 SLT = 342,
162 SGT = 343,
163 SLE = 344,
164 SGE = 345,
165 ULT = 346,
166 UGT = 347,
167 ULE = 348,
168 UGE = 349,
169 OEQ = 350,
170 ONE = 351,
171 OLT = 352,
172 OGT = 353,
173 OLE = 354,
174 OGE = 355,
175 ORD = 356,
176 UNO = 357,
177 UEQ = 358,
178 UNE = 359,
179 MALLOC = 360,
180 ALLOCA = 361,
181 FREE = 362,
182 LOAD = 363,
183 STORE = 364,
184 GETELEMENTPTR = 365,
185 TRUNC = 366,
186 ZEXT = 367,
187 SEXT = 368,
188 FPTRUNC = 369,
189 FPEXT = 370,
190 BITCAST = 371,
191 UITOFP = 372,
192 SITOFP = 373,
193 FPTOUI = 374,
194 FPTOSI = 375,
195 INTTOPTR = 376,
196 PTRTOINT = 377,
197 PHI_TOK = 378,
198 SELECT = 379,
199 VAARG = 380,
200 EXTRACTELEMENT = 381,
201 INSERTELEMENT = 382,
202 SHUFFLEVECTOR = 383,
203 NORETURN = 384,
204 INREG = 385,
205 SRET = 386,
206 NOUNWIND = 387,
207 DEFAULT = 388,
208 HIDDEN = 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000209 };
210#endif
211/* Tokens. */
212#define ESINT64VAL 258
213#define EUINT64VAL 259
214#define ESAPINTVAL 260
215#define EUAPINTVAL 261
216#define LOCALVAL_ID 262
217#define GLOBALVAL_ID 263
218#define FPVAL 264
219#define VOID 265
220#define INTTYPE 266
221#define FLOAT 267
222#define DOUBLE 268
223#define LABEL 269
224#define TYPE 270
225#define LOCALVAR 271
226#define GLOBALVAR 272
227#define LABELSTR 273
228#define STRINGCONSTANT 274
229#define ATSTRINGCONSTANT 275
Reid Spencer3d6b71e2007-04-09 01:56:05 +0000230#define ZEROINITIALIZER 276
231#define TRUETOK 277
232#define FALSETOK 278
233#define BEGINTOK 279
234#define ENDTOK 280
235#define DECLARE 281
236#define DEFINE 282
237#define GLOBAL 283
238#define CONSTANT 284
239#define SECTION 285
240#define VOLATILE 286
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000241#define THREAD_LOCAL 287
242#define TO 288
243#define DOTDOTDOT 289
244#define NULL_TOK 290
245#define UNDEF 291
246#define INTERNAL 292
247#define LINKONCE 293
248#define WEAK 294
249#define APPENDING 295
250#define DLLIMPORT 296
251#define DLLEXPORT 297
252#define EXTERN_WEAK 298
253#define OPAQUE 299
254#define EXTERNAL 300
255#define TARGET 301
256#define TRIPLE 302
257#define ALIGN 303
258#define DEPLIBS 304
259#define CALL 305
260#define TAIL 306
261#define ASM_TOK 307
262#define MODULE 308
263#define SIDEEFFECT 309
264#define CC_TOK 310
265#define CCC_TOK 311
266#define FASTCC_TOK 312
267#define COLDCC_TOK 313
268#define X86_STDCALLCC_TOK 314
269#define X86_FASTCALLCC_TOK 315
270#define DATALAYOUT 316
271#define RET 317
272#define BR 318
273#define SWITCH 319
274#define INVOKE 320
275#define UNWIND 321
276#define UNREACHABLE 322
277#define ADD 323
278#define SUB 324
279#define MUL 325
280#define UDIV 326
281#define SDIV 327
282#define FDIV 328
283#define UREM 329
284#define SREM 330
285#define FREM 331
286#define AND 332
287#define OR 333
288#define XOR 334
289#define SHL 335
290#define LSHR 336
291#define ASHR 337
292#define ICMP 338
293#define FCMP 339
294#define EQ 340
295#define NE 341
296#define SLT 342
297#define SGT 343
298#define SLE 344
299#define SGE 345
300#define ULT 346
301#define UGT 347
302#define ULE 348
303#define UGE 349
304#define OEQ 350
305#define ONE 351
306#define OLT 352
307#define OGT 353
308#define OLE 354
309#define OGE 355
310#define ORD 356
311#define UNO 357
312#define UEQ 358
313#define UNE 359
314#define MALLOC 360
315#define ALLOCA 361
316#define FREE 362
317#define LOAD 363
318#define STORE 364
319#define GETELEMENTPTR 365
320#define TRUNC 366
321#define ZEXT 367
322#define SEXT 368
323#define FPTRUNC 369
324#define FPEXT 370
325#define BITCAST 371
326#define UITOFP 372
327#define SITOFP 373
328#define FPTOUI 374
329#define FPTOSI 375
330#define INTTOPTR 376
331#define PTRTOINT 377
332#define PHI_TOK 378
333#define SELECT 379
334#define VAARG 380
335#define EXTRACTELEMENT 381
336#define INSERTELEMENT 382
337#define SHUFFLEVECTOR 383
338#define NORETURN 384
339#define INREG 385
340#define SRET 386
341#define NOUNWIND 387
342#define DEFAULT 388
343#define HIDDEN 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000344
345
346
347
348/* Copy the first part of user declarations. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000349#line 14 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350
351#include "ParserInternals.h"
352#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000353#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include "llvm/Instructions.h"
355#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000356#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000357#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000358#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000359#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000361#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000362#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000363#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000364#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000365#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000367#ifndef NDEBUG
368#define YYDEBUG 1
369#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370
Reid Spencere4f47592006-08-18 17:32:55 +0000371// The following is a gross hack. In order to rid the libAsmParser library of
372// exceptions, we have to have a way of getting the yyparse function to go into
373// an error situation. So, whenever we want an error to occur, the GenerateError
374// function (see bottom of file) sets TriggerError. Then, at the end of each
375// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
376// (a goto) to put YACC in error state. Furthermore, several calls to
377// GenerateError are made from inside productions and they must simulate the
378// previous exception behavior by exiting the production immediately. We have
379// replaced these with the GEN_ERROR macro which calls GeneratError and then
380// immediately invokes YYERROR. This would be so much cleaner if it was a
381// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000382static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000383#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000384#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
385
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
387int yylex(); // declaration" of xxx warnings.
388int yyparse();
389
390namespace llvm {
391 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000392#if YYDEBUG
393static cl::opt<bool>
394Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
395 cl::Hidden, cl::init(false));
396#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000397}
398using namespace llvm;
399
400static Module *ParserResult;
401
402// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
403// relating to upreferences in the input stream.
404//
405//#define DEBUG_UPREFS 1
406#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000407#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000408#else
409#define UR_OUT(X)
410#endif
411
412#define YYERROR_VERBOSE 1
413
Chris Lattnerb475c422005-11-12 18:22:38 +0000414static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415
416
417// This contains info used when building the body of a function. It is
418// destroyed when the function is completed.
419//
420typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000421
Reid Spencer68a24bd2005-08-27 18:50:39 +0000422static void
Reid Spencer93c40032007-03-19 18:40:50 +0000423ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424
425static struct PerModuleInfo {
426 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000427 ValueList Values; // Module level numbered definitions
428 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000429 std::vector<PATypeHolder> Types;
430 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431
432 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000433 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434 /// that we can resolve them later and print error messages as appropriate.
435 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
436
437 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
438 // references to global values. Global values may be referenced before they
439 // are defined, and if so, the temporary object that they represent is held
440 // here. This is used for forward references of GlobalValues.
441 //
442 typedef std::map<std::pair<const PointerType *,
443 ValID>, GlobalValue*> GlobalRefsType;
444 GlobalRefsType GlobalRefs;
445
446 void ModuleDone() {
447 // If we could not resolve some functions at function compilation time
448 // (calls to functions before they are defined), resolve them now... Types
449 // are resolved when the constant pool has been completely parsed.
450 //
451 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000452 if (TriggerError)
453 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000454
455 // Check to make sure that all global value forward references have been
456 // resolved!
457 //
458 if (!GlobalRefs.empty()) {
459 std::string UndefinedReferences = "Unresolved global references exist:\n";
460
461 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
462 I != E; ++I) {
463 UndefinedReferences += " " + I->first.first->getDescription() + " " +
464 I->first.second.getName() + "\n";
465 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000466 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000467 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000468 }
469
470 Values.clear(); // Clear out function local definitions
471 Types.clear();
472 CurrentModule = 0;
473 }
474
Reid Spencer68a24bd2005-08-27 18:50:39 +0000475 // GetForwardRefForGlobal - Check to see if there is a forward reference
476 // for this global. If so, remove it from the GlobalRefs map and return it.
477 // If not, just return null.
478 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
479 // Check to see if there is a forward reference to this global variable...
480 // if there is, eliminate it and patch the reference to use the new def'n.
481 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
482 GlobalValue *Ret = 0;
483 if (I != GlobalRefs.end()) {
484 Ret = I->second;
485 GlobalRefs.erase(I);
486 }
487 return Ret;
488 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000489
490 bool TypeIsUnresolved(PATypeHolder* PATy) {
491 // If it isn't abstract, its resolved
492 const Type* Ty = PATy->get();
493 if (!Ty->isAbstract())
494 return false;
495 // Traverse the type looking for abstract types. If it isn't abstract then
496 // we don't need to traverse that leg of the type.
497 std::vector<const Type*> WorkList, SeenList;
498 WorkList.push_back(Ty);
499 while (!WorkList.empty()) {
500 const Type* Ty = WorkList.back();
501 SeenList.push_back(Ty);
502 WorkList.pop_back();
503 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
504 // Check to see if this is an unresolved type
505 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
506 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
507 for ( ; I != E; ++I) {
508 if (I->second.get() == OpTy)
509 return true;
510 }
511 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
512 const Type* TheTy = SeqTy->getElementType();
513 if (TheTy->isAbstract() && TheTy != Ty) {
514 std::vector<const Type*>::iterator I = SeenList.begin(),
515 E = SeenList.end();
516 for ( ; I != E; ++I)
517 if (*I == TheTy)
518 break;
519 if (I == E)
520 WorkList.push_back(TheTy);
521 }
522 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
523 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
524 const Type* TheTy = StrTy->getElementType(i);
525 if (TheTy->isAbstract() && TheTy != Ty) {
526 std::vector<const Type*>::iterator I = SeenList.begin(),
527 E = SeenList.end();
528 for ( ; I != E; ++I)
529 if (*I == TheTy)
530 break;
531 if (I == E)
532 WorkList.push_back(TheTy);
533 }
534 }
535 }
536 }
537 return false;
538 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000539} CurModule;
540
541static struct PerFunctionInfo {
542 Function *CurrentFunction; // Pointer to current function being created
543
Reid Spencer93c40032007-03-19 18:40:50 +0000544 ValueList Values; // Keep track of #'d definitions
545 unsigned NextValNum;
546 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000547 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000548 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000549 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000550
551 /// BBForwardRefs - When we see forward references to basic blocks, keep
552 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000553 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554
555 inline PerFunctionInfo() {
556 CurrentFunction = 0;
557 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000558 Linkage = GlobalValue::ExternalLinkage;
559 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 }
561
562 inline void FunctionStart(Function *M) {
563 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000564 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565 }
566
567 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000569 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000570 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000571 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000572 return;
573 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574
575 // Resolve all forward references now.
576 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
577
578 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000579 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580 CurrentFunction = 0;
581 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000582 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000583 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 }
585} CurFun; // Info for the current function...
586
587static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
588
589
590//===----------------------------------------------------------------------===//
591// Code to handle definitions of all the types
592//===----------------------------------------------------------------------===//
593
Reid Spencer93c40032007-03-19 18:40:50 +0000594static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
595 // Things that have names or are void typed don't get slot numbers
596 if (V->hasName() || (V->getType() == Type::VoidTy))
597 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598
Reid Spencer93c40032007-03-19 18:40:50 +0000599 // In the case of function values, we have to allow for the forward reference
600 // of basic blocks, which are included in the numbering. Consequently, we keep
601 // track of the next insertion location with NextValNum. When a BB gets
602 // inserted, it could change the size of the CurFun.Values vector.
603 if (&ValueTab == &CurFun.Values) {
604 if (ValueTab.size() <= CurFun.NextValNum)
605 ValueTab.resize(CurFun.NextValNum+1);
606 ValueTab[CurFun.NextValNum++] = V;
607 return;
608 }
609 // For all other lists, its okay to just tack it on the back of the vector.
610 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611}
612
613static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
614 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000615 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000617 if (D.Num < CurModule.Types.size())
618 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000620 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
622 D.destroy(); // Free old strdup'd memory...
623 return N;
624 }
625 break;
626 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000627 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000628 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629 }
630
631 // If we reached here, we referenced either a symbol that we don't know about
632 // or an id number that hasn't been read yet. We may be referencing something
633 // forward, so just create an entry to be resolved later and get to it...
634 //
635 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
636
637
638 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000639 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000640 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000641 return 0;
642 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000643 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 return 0;
645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646 }
647
Reid Spencer861d9d62006-11-28 07:29:44 +0000648 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000650 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651
Reid Spencer861d9d62006-11-28 07:29:44 +0000652 Type *Typ = OpaqueType::get();
653 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
654 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000655 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656
Reid Spencer93c40032007-03-19 18:40:50 +0000657// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000658// the provided ValID. If the value exists and has already been defined, return
659// it. Otherwise return null.
660//
Reid Spencer93c40032007-03-19 18:40:50 +0000661static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000662 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000663 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000665 return 0;
666 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667
668 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000669 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000670 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000671 if (D.Num >= CurFun.Values.size())
672 return 0;
673 Value *Result = CurFun.Values[D.Num];
674 if (Ty != Result->getType()) {
675 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
676 Result->getType()->getDescription() + "' does not match "
677 "expected type, '" + Ty->getDescription() + "'");
678 return 0;
679 }
680 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000681 }
682 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000683 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000684 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000685 Value *Result = CurModule.Values[D.Num];
686 if (Ty != Result->getType()) {
687 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
688 Result->getType()->getDescription() + "' does not match "
689 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000690 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000691 }
692 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000693 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000694
695 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000696 if (!inFunctionScope())
697 return 0;
698 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
699 Value *N = SymTab.lookup(D.Name);
700 if (N == 0)
701 return 0;
702 if (N->getType() != Ty)
703 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000704
705 D.destroy(); // Free old strdup'd memory...
706 return N;
707 }
708 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000709 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
710 Value *N = SymTab.lookup(D.Name);
711 if (N == 0)
712 return 0;
713 if (N->getType() != Ty)
714 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715
716 D.destroy(); // Free old strdup'd memory...
717 return N;
718 }
719
720 // Check to make sure that "Ty" is an integral type, and that our
721 // value will fit into the specified type...
722 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000723 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000724 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000725 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000726 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000727 return 0;
728 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000729 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000730
731 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000732 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
733 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000734 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000735 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000736 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000737 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000738 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 }
740 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000741 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000742 }
743
744 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000745 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000746 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000747 return 0;
748 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000749 return ConstantFP::get(Ty, D.ConstPoolFP);
750
751 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000752 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000753 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000754 return 0;
755 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000756 return ConstantPointerNull::get(cast<PointerType>(Ty));
757
758 case ValID::ConstUndefVal: // Is it an undef value?
759 return UndefValue::get(Ty);
760
Chris Lattner7aa61892005-12-21 17:53:23 +0000761 case ValID::ConstZeroVal: // Is it a zero value?
762 return Constant::getNullValue(Ty);
763
Reid Spencer68a24bd2005-08-27 18:50:39 +0000764 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000766 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000769 return D.ConstantValue;
770
Chris Lattner0e9c3762006-01-25 22:27:16 +0000771 case ValID::InlineAsmVal: { // Inline asm expression
772 const PointerType *PTy = dyn_cast<PointerType>(Ty);
773 const FunctionType *FTy =
774 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000776 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 return 0;
778 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000779 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
780 D.IAD->HasSideEffects);
781 D.destroy(); // Free InlineAsmDescriptor.
782 return IA;
783 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000785 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786 return 0;
787 } // End of switch
788
Reid Spencera9720f52007-02-05 17:04:00 +0000789 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790 return 0;
791}
792
Reid Spencer93c40032007-03-19 18:40:50 +0000793// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794// value is not already defined, it "improvises" by creating a placeholder var
795// that looks and acts just like the requested variable. When the value is
796// defined later, all uses of the placeholder variable are replaced with the
797// real thing.
798//
799static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000801 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 return 0;
803 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000804
805 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000806 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000808 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000811 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 return 0;
813 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000814
815 // If we reached here, we referenced either a symbol that we don't know about
816 // or an id number that hasn't been read yet. We may be referencing something
817 // forward, so just create an entry to be resolved later and get to it...
818 //
819 V = new Argument(Ty);
820
821 // Remember where this forward reference came from. FIXME, shouldn't we try
822 // to recycle these things??
823 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
824 llvmAsmlineno)));
825
826 if (inFunctionScope())
827 InsertValue(V, CurFun.LateResolveValues);
828 else
829 InsertValue(V, CurModule.LateResolveValues);
830 return V;
831}
832
Reid Spencer93c40032007-03-19 18:40:50 +0000833/// defineBBVal - This is a definition of a new basic block with the specified
834/// identifier which must be the same as CurFun.NextValNum, if its numeric.
835static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000836 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
Reid Spencer93c40032007-03-19 18:40:50 +0000840 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841
Reid Spencer93c40032007-03-19 18:40:50 +0000842 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
843 if (BBI != CurFun.BBForwardRefs.end()) {
844 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000845 // The forward declaration could have been inserted anywhere in the
846 // function: insert it into the correct place now.
847 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
848 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000849
Reid Spencer66728ef2007-03-20 01:13:36 +0000850 // We're about to erase the entry, save the key so we can clean it up.
851 ValID Tmp = BBI->first;
852
Reid Spencer93c40032007-03-19 18:40:50 +0000853 // Erase the forward ref from the map as its no longer "forward"
854 CurFun.BBForwardRefs.erase(ID);
855
Reid Spencer66728ef2007-03-20 01:13:36 +0000856 // The key has been removed from the map but so we don't want to leave
857 // strdup'd memory around so destroy it too.
858 Tmp.destroy();
859
Reid Spencer93c40032007-03-19 18:40:50 +0000860 // If its a numbered definition, bump the number and set the BB value.
861 if (ID.Type == ValID::LocalID) {
862 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
863 InsertValue(BB);
864 }
865
866 ID.destroy();
867 return BB;
868 }
869
870 // We haven't seen this BB before and its first mention is a definition.
871 // Just create it and return it.
872 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
873 BB = new BasicBlock(Name, CurFun.CurrentFunction);
874 if (ID.Type == ValID::LocalID) {
875 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
876 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000877 }
Reid Spencer93c40032007-03-19 18:40:50 +0000878
879 ID.destroy(); // Free strdup'd memory
880 return BB;
881}
882
883/// getBBVal - get an existing BB value or create a forward reference for it.
884///
885static BasicBlock *getBBVal(const ValID &ID) {
886 assert(inFunctionScope() && "Can't get basic block at global scope!");
887
888 BasicBlock *BB = 0;
889
890 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
891 if (BBI != CurFun.BBForwardRefs.end()) {
892 BB = BBI->second;
893 } if (ID.Type == ValID::LocalName) {
894 std::string Name = ID.Name;
895 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
896 if (N)
897 if (N->getType()->getTypeID() == Type::LabelTyID)
898 BB = cast<BasicBlock>(N);
899 else
900 GenerateError("Reference to label '" + Name + "' is actually of type '"+
901 N->getType()->getDescription() + "'");
902 } else if (ID.Type == ValID::LocalID) {
903 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
904 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
905 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
906 else
907 GenerateError("Reference to label '%" + utostr(ID.Num) +
908 "' is actually of type '"+
909 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
910 }
911 } else {
912 GenerateError("Illegal label reference " + ID.getName());
913 return 0;
914 }
915
916 // If its already been defined, return it now.
917 if (BB) {
918 ID.destroy(); // Free strdup'd memory.
919 return BB;
920 }
921
922 // Otherwise, this block has not been seen before, create it.
923 std::string Name;
924 if (ID.Type == ValID::LocalName)
925 Name = ID.Name;
926 BB = new BasicBlock(Name, CurFun.CurrentFunction);
927
928 // Insert it in the forward refs map.
929 CurFun.BBForwardRefs[ID] = BB;
930
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931 return BB;
932}
933
934
935//===----------------------------------------------------------------------===//
936// Code to handle forward references in instructions
937//===----------------------------------------------------------------------===//
938//
939// This code handles the late binding needed with statements that reference
940// values not defined yet... for example, a forward branch, or the PHI node for
941// a loop body.
942//
943// This keeps a table (CurFun.LateResolveValues) of all such forward references
944// and back patchs after we are done.
945//
946
947// ResolveDefinitions - If we could not resolve some defs at parsing
948// time (forward branches, phi functions for loops, etc...) resolve the
949// defs now...
950//
951static void
Reid Spencer93c40032007-03-19 18:40:50 +0000952ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000954 while (!LateResolvers.empty()) {
955 Value *V = LateResolvers.back();
956 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000957
Reid Spencer93c40032007-03-19 18:40:50 +0000958 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
959 CurModule.PlaceHolderInfo.find(V);
960 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000961
Reid Spencer93c40032007-03-19 18:40:50 +0000962 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000963
Reid Spencer93c40032007-03-19 18:40:50 +0000964 Value *TheRealValue = getExistingVal(V->getType(), DID);
965 if (TriggerError)
966 return;
967 if (TheRealValue) {
968 V->replaceAllUsesWith(TheRealValue);
969 delete V;
970 CurModule.PlaceHolderInfo.erase(PHI);
971 } else if (FutureLateResolvers) {
972 // Functions have their unresolved items forwarded to the module late
973 // resolver table
974 InsertValue(V, *FutureLateResolvers);
975 } else {
976 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
977 GenerateError("Reference to an invalid definition: '" +DID.getName()+
978 "' of type '" + V->getType()->getDescription() + "'",
979 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000980 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000982 GenerateError("Reference to an invalid definition: #" +
983 itostr(DID.Num) + " of type '" +
984 V->getType()->getDescription() + "'",
985 PHI->second.second);
986 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000987 }
988 }
989 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000990 LateResolvers.clear();
991}
992
993// ResolveTypeTo - A brand new type was just declared. This means that (if
994// name is not null) things referencing Name can be resolved. Otherwise, things
995// refering to the number can be resolved. Do this now.
996//
997static void ResolveTypeTo(char *Name, const Type *ToTy) {
998 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000999 if (Name) D = ValID::createLocalName(Name);
1000 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001001
Reid Spencer861d9d62006-11-28 07:29:44 +00001002 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001003 CurModule.LateResolveTypes.find(D);
1004 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001005 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001006 CurModule.LateResolveTypes.erase(I);
1007 }
1008}
1009
1010// setValueName - Set the specified value to the name given. The name may be
1011// null potentially, in which case this is a noop. The string passed in is
1012// assumed to be a malloc'd string buffer, and is free'd by this function.
1013//
1014static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001015 if (!NameStr) return;
1016 std::string Name(NameStr); // Copy string
1017 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018
Reid Spencer41dff5e2007-01-26 08:05:27 +00001019 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001020 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001021 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001023
Reid Spencera9720f52007-02-05 17:04:00 +00001024 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001025 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1026 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001027 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001028 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001029 return;
1030 }
1031
1032 // Set the name.
1033 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001034}
1035
1036/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1037/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001038static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001039ParseGlobalVariable(char *NameStr,
1040 GlobalValue::LinkageTypes Linkage,
1041 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001042 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001043 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001044 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001045 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001046 return 0;
1047 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001048
1049 const PointerType *PTy = PointerType::get(Ty);
1050
1051 std::string Name;
1052 if (NameStr) {
1053 Name = NameStr; // Copy string
1054 free(NameStr); // Free old string
1055 }
1056
1057 // See if this global value was forward referenced. If so, recycle the
1058 // object.
1059 ValID ID;
1060 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001061 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001062 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001063 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001064 }
1065
1066 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1067 // Move the global to the end of the list, from whereever it was
1068 // previously inserted.
1069 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1070 CurModule.CurrentModule->getGlobalList().remove(GV);
1071 CurModule.CurrentModule->getGlobalList().push_back(GV);
1072 GV->setInitializer(Initializer);
1073 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001074 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001075 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001076 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001078 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001079 }
1080
Reid Spenceref9b9a72007-02-05 20:47:22 +00001081 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001083 // if the global we're parsing has an initializer (is a definition) and
1084 // has external linkage.
1085 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1086 // If there is already a global with external linkage with this name
1087 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1088 // If we allow this GVar to get created, it will be renamed in the
1089 // symbol table because it conflicts with an existing GVar. We can't
1090 // allow redefinition of GVars whose linking indicates that their name
1091 // must stay the same. Issue the error.
1092 GenerateError("Redefinition of global variable named '" + Name +
1093 "' of type '" + Ty->getDescription() + "'");
1094 return 0;
1095 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 }
1097
1098 // Otherwise there is no existing GV to use, create one now.
1099 GlobalVariable *GV =
1100 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001101 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001102 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001104 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105}
1106
1107// setTypeName - Set the specified type to the name given. The name may be
1108// null potentially, in which case this is a noop. The string passed in is
1109// assumed to be a malloc'd string buffer, and is freed by this function.
1110//
1111// This function returns true if the type has already been defined, but is
1112// allowed to be redefined in the specified context. If the name is a new name
1113// for the type plane, it is inserted and false is returned.
1114static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001115 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 if (NameStr == 0) return false;
1117
1118 std::string Name(NameStr); // Copy string
1119 free(NameStr); // Free old string
1120
1121 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001122 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001123 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001124 return false;
1125 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126
1127 // Set the type name, checking for conflicts as we do so.
1128 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1129
1130 if (AlreadyExists) { // Inserting a name that is already defined???
1131 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001132 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133
1134 // There is only one case where this is allowed: when we are refining an
1135 // opaque type. In this case, Existing will be an opaque type.
1136 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1137 // We ARE replacing an opaque type!
1138 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1139 return true;
1140 }
1141
1142 // Otherwise, this is an attempt to redefine a type. That's okay if
1143 // the redefinition is identical to the original. This will be so if
1144 // Existing and T point to the same Type object. In this one case we
1145 // allow the equivalent redefinition.
1146 if (Existing == T) return true; // Yes, it's equal.
1147
1148 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001149 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001150 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151 }
1152
1153 return false;
1154}
1155
1156//===----------------------------------------------------------------------===//
1157// Code for handling upreferences in type names...
1158//
1159
1160// TypeContains - Returns true if Ty directly contains E in it.
1161//
1162static bool TypeContains(const Type *Ty, const Type *E) {
1163 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1164 E) != Ty->subtype_end();
1165}
1166
1167namespace {
1168 struct UpRefRecord {
1169 // NestingLevel - The number of nesting levels that need to be popped before
1170 // this type is resolved.
1171 unsigned NestingLevel;
1172
1173 // LastContainedTy - This is the type at the current binding level for the
1174 // type. Every time we reduce the nesting level, this gets updated.
1175 const Type *LastContainedTy;
1176
1177 // UpRefTy - This is the actual opaque type that the upreference is
1178 // represented with.
1179 OpaqueType *UpRefTy;
1180
1181 UpRefRecord(unsigned NL, OpaqueType *URTy)
1182 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1183 };
1184}
1185
1186// UpRefs - A list of the outstanding upreferences that need to be resolved.
1187static std::vector<UpRefRecord> UpRefs;
1188
1189/// HandleUpRefs - Every time we finish a new layer of types, this function is
1190/// called. It loops through the UpRefs vector, which is a list of the
1191/// currently active types. For each type, if the up reference is contained in
1192/// the newly completed type, we decrement the level count. When the level
1193/// count reaches zero, the upreferenced type is the type that is passed in:
1194/// thus we can complete the cycle.
1195///
1196static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001197 // If Ty isn't abstract, or if there are no up-references in it, then there is
1198 // nothing to resolve here.
1199 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001201 PATypeHolder Ty(ty);
1202 UR_OUT("Type '" << Ty->getDescription() <<
1203 "' newly formed. Resolving upreferences.\n" <<
1204 UpRefs.size() << " upreferences active!\n");
1205
1206 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1207 // to zero), we resolve them all together before we resolve them to Ty. At
1208 // the end of the loop, if there is anything to resolve to Ty, it will be in
1209 // this variable.
1210 OpaqueType *TypeToResolve = 0;
1211
1212 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1213 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1214 << UpRefs[i].second->getDescription() << ") = "
1215 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1216 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1217 // Decrement level of upreference
1218 unsigned Level = --UpRefs[i].NestingLevel;
1219 UpRefs[i].LastContainedTy = Ty;
1220 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1221 if (Level == 0) { // Upreference should be resolved!
1222 if (!TypeToResolve) {
1223 TypeToResolve = UpRefs[i].UpRefTy;
1224 } else {
1225 UR_OUT(" * Resolving upreference for "
1226 << UpRefs[i].second->getDescription() << "\n";
1227 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1228 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1229 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1230 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1231 }
1232 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1233 --i; // Do not skip the next element...
1234 }
1235 }
1236 }
1237
1238 if (TypeToResolve) {
1239 UR_OUT(" * Resolving upreference for "
1240 << UpRefs[i].second->getDescription() << "\n";
1241 std::string OldName = TypeToResolve->getDescription());
1242 TypeToResolve->refineAbstractTypeTo(Ty);
1243 }
1244
1245 return Ty;
1246}
1247
Reid Spencer68a24bd2005-08-27 18:50:39 +00001248//===----------------------------------------------------------------------===//
1249// RunVMAsmParser - Define an interface to this parser
1250//===----------------------------------------------------------------------===//
1251//
Reid Spencer14310612006-12-31 05:40:51 +00001252static Module* RunParser(Module * M);
1253
Reid Spencer68a24bd2005-08-27 18:50:39 +00001254Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1255 set_scan_file(F);
1256
1257 CurFilename = Filename;
1258 return RunParser(new Module(CurFilename));
1259}
1260
1261Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1262 set_scan_string(AsmString);
1263
1264 CurFilename = "from_memory";
1265 if (M == NULL) {
1266 return RunParser(new Module (CurFilename));
1267 } else {
1268 return RunParser(M);
1269 }
1270}
1271
1272
Reid Spencer38c91a92007-02-28 02:24:54 +00001273
1274/* Enabling traces. */
1275#ifndef YYDEBUG
1276# define YYDEBUG 0
1277#endif
1278
1279/* Enabling verbose error messages. */
1280#ifdef YYERROR_VERBOSE
1281# undef YYERROR_VERBOSE
1282# define YYERROR_VERBOSE 1
1283#else
1284# define YYERROR_VERBOSE 0
1285#endif
1286
1287/* Enabling the token table. */
1288#ifndef YYTOKEN_TABLE
1289# define YYTOKEN_TABLE 0
1290#endif
1291
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001292#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1293typedef union YYSTYPE
1294#line 938 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
1295{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001296 llvm::Module *ModuleVal;
1297 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001298 llvm::BasicBlock *BasicBlockVal;
1299 llvm::TerminatorInst *TermInstVal;
1300 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001301 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001302
Reid Spencera132e042006-12-03 05:46:11 +00001303 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001304 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001305 llvm::PATypeHolder *TypeVal;
1306 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001307 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001308 llvm::ArgListType *ArgList;
1309 llvm::TypeWithAttrs TypeWithAttrs;
1310 llvm::TypeWithAttrsList *TypeWithAttrsList;
1311 llvm::ValueRefList *ValueRefList;
1312
Reid Spencer68a24bd2005-08-27 18:50:39 +00001313 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001314 std::list<std::pair<llvm::Value*,
1315 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001316 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001317 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001318
1319 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001320 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001321 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001322 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001323 int64_t SInt64Val;
1324 uint64_t UInt64Val;
1325 int SIntVal;
1326 unsigned UIntVal;
1327 double FPVal;
1328 bool BoolVal;
1329
1330 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001331 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001332
Reid Spencera132e042006-12-03 05:46:11 +00001333 llvm::Instruction::BinaryOps BinaryOpVal;
1334 llvm::Instruction::TermOps TermOpVal;
1335 llvm::Instruction::MemoryOps MemOpVal;
1336 llvm::Instruction::CastOps CastOpVal;
1337 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001338 llvm::ICmpInst::Predicate IPredicate;
1339 llvm::FCmpInst::Predicate FPredicate;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001340}
1341/* Line 193 of yacc.c. */
1342#line 1343 "llvmAsmParser.tab.c"
1343 YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001344# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1345# define YYSTYPE_IS_DECLARED 1
1346# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001347#endif
1348
Reid Spencer41dff5e2007-01-26 08:05:27 +00001349
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350
Reid Spencer38c91a92007-02-28 02:24:54 +00001351/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001352
1353
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001354/* Line 216 of yacc.c. */
1355#line 1356 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001356
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001357#ifdef short
1358# undef short
Reid Spencer38c91a92007-02-28 02:24:54 +00001359#endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001360
1361#ifdef YYTYPE_UINT8
1362typedef YYTYPE_UINT8 yytype_uint8;
1363#else
1364typedef unsigned char yytype_uint8;
Reid Spencer38c91a92007-02-28 02:24:54 +00001365#endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001366
1367#ifdef YYTYPE_INT8
1368typedef YYTYPE_INT8 yytype_int8;
1369#elif (defined __STDC__ || defined __C99__FUNC__ \
1370 || defined __cplusplus || defined _MSC_VER)
1371typedef signed char yytype_int8;
1372#else
1373typedef short int yytype_int8;
Reid Spencer38c91a92007-02-28 02:24:54 +00001374#endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001375
1376#ifdef YYTYPE_UINT16
1377typedef YYTYPE_UINT16 yytype_uint16;
1378#else
1379typedef unsigned short int yytype_uint16;
Reid Spencer38c91a92007-02-28 02:24:54 +00001380#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001381
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001382#ifdef YYTYPE_INT16
1383typedef YYTYPE_INT16 yytype_int16;
1384#else
1385typedef short int yytype_int16;
1386#endif
1387
1388#ifndef YYSIZE_T
1389# ifdef __SIZE_TYPE__
1390# define YYSIZE_T __SIZE_TYPE__
1391# elif defined size_t
1392# define YYSIZE_T size_t
1393# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1394 || defined __cplusplus || defined _MSC_VER)
1395# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1396# define YYSIZE_T size_t
1397# else
1398# define YYSIZE_T unsigned int
1399# endif
1400#endif
1401
1402#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1403
Reid Spencer38c91a92007-02-28 02:24:54 +00001404#ifndef YY_
1405# if YYENABLE_NLS
1406# if ENABLE_NLS
1407# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1408# define YY_(msgid) dgettext ("bison-runtime", msgid)
1409# endif
1410# endif
1411# ifndef YY_
1412# define YY_(msgid) msgid
1413# endif
1414#endif
1415
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001416/* Suppress unused-variable warnings by "using" E. */
1417#if ! defined lint || defined __GNUC__
1418# define YYUSE(e) ((void) (e))
1419#else
1420# define YYUSE(e) /* empty */
1421#endif
1422
1423/* Identity function, used to suppress warnings about constant conditions. */
1424#ifndef lint
1425# define YYID(n) (n)
1426#else
1427#if (defined __STDC__ || defined __C99__FUNC__ \
1428 || defined __cplusplus || defined _MSC_VER)
1429static int
1430YYID (int i)
1431#else
1432static int
1433YYID (i)
1434 int i;
1435#endif
1436{
1437 return i;
1438}
1439#endif
1440
1441#if ! defined yyoverflow || YYERROR_VERBOSE
Reid Spencer38c91a92007-02-28 02:24:54 +00001442
1443/* The parser invokes alloca or malloc; define the necessary symbols. */
1444
1445# ifdef YYSTACK_USE_ALLOCA
1446# if YYSTACK_USE_ALLOCA
1447# ifdef __GNUC__
1448# define YYSTACK_ALLOC __builtin_alloca
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001449# elif defined __BUILTIN_VA_ARG_INCR
1450# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1451# elif defined _AIX
1452# define YYSTACK_ALLOC __alloca
1453# elif defined _MSC_VER
1454# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1455# define alloca _alloca
Reid Spencer38c91a92007-02-28 02:24:54 +00001456# else
1457# define YYSTACK_ALLOC alloca
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001458# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1459 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00001460# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001461# ifndef _STDLIB_H
1462# define _STDLIB_H 1
1463# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00001464# endif
1465# endif
1466# endif
1467# endif
1468
1469# ifdef YYSTACK_ALLOC
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001470 /* Pacify GCC's `empty if-body' warning. */
1471# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
Reid Spencer38c91a92007-02-28 02:24:54 +00001472# ifndef YYSTACK_ALLOC_MAXIMUM
1473 /* The OS might guarantee only one guard page at the bottom of the stack,
1474 and a page size can be as small as 4096 bytes. So we cannot safely
1475 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1476 to allow for a few compiler-allocated temporary stack slots. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001477# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
Reid Spencer38c91a92007-02-28 02:24:54 +00001478# endif
1479# else
1480# define YYSTACK_ALLOC YYMALLOC
1481# define YYSTACK_FREE YYFREE
1482# ifndef YYSTACK_ALLOC_MAXIMUM
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001483# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
Reid Spencer38c91a92007-02-28 02:24:54 +00001484# endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001485# if (defined __cplusplus && ! defined _STDLIB_H \
1486 && ! ((defined YYMALLOC || defined malloc) \
1487 && (defined YYFREE || defined free)))
1488# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1489# ifndef _STDLIB_H
1490# define _STDLIB_H 1
1491# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00001492# endif
1493# ifndef YYMALLOC
1494# define YYMALLOC malloc
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001495# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1496 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00001497void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1498# endif
1499# endif
1500# ifndef YYFREE
1501# define YYFREE free
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001502# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1503 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00001504void free (void *); /* INFRINGES ON USER NAME SPACE */
1505# endif
1506# endif
Reid Spencer38c91a92007-02-28 02:24:54 +00001507# endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001508#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00001509
1510
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001511#if (! defined yyoverflow \
1512 && (! defined __cplusplus \
1513 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Reid Spencer38c91a92007-02-28 02:24:54 +00001514
1515/* A type that is properly aligned for any stack member. */
1516union yyalloc
1517{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001518 yytype_int16 yyss;
Reid Spencer38c91a92007-02-28 02:24:54 +00001519 YYSTYPE yyvs;
1520 };
1521
1522/* The size of the maximum gap between one aligned stack and the next. */
1523# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1524
1525/* The size of an array large to enough to hold all stacks, each with
1526 N elements. */
1527# define YYSTACK_BYTES(N) \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001528 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
Reid Spencer38c91a92007-02-28 02:24:54 +00001529 + YYSTACK_GAP_MAXIMUM)
1530
1531/* Copy COUNT objects from FROM to TO. The source and destination do
1532 not overlap. */
1533# ifndef YYCOPY
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001534# if defined __GNUC__ && 1 < __GNUC__
Reid Spencer38c91a92007-02-28 02:24:54 +00001535# define YYCOPY(To, From, Count) \
1536 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1537# else
1538# define YYCOPY(To, From, Count) \
1539 do \
1540 { \
1541 YYSIZE_T yyi; \
1542 for (yyi = 0; yyi < (Count); yyi++) \
1543 (To)[yyi] = (From)[yyi]; \
1544 } \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001545 while (YYID (0))
Reid Spencer38c91a92007-02-28 02:24:54 +00001546# endif
1547# endif
1548
1549/* Relocate STACK from its old location to the new one. The
1550 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1551 elements in the stack, and YYPTR gives the new location of the
1552 stack. Advance YYPTR to a properly aligned location for the next
1553 stack. */
1554# define YYSTACK_RELOCATE(Stack) \
1555 do \
1556 { \
1557 YYSIZE_T yynewbytes; \
1558 YYCOPY (&yyptr->Stack, Stack, yysize); \
1559 Stack = &yyptr->Stack; \
1560 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1561 yyptr += yynewbytes / sizeof (*yyptr); \
1562 } \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001563 while (YYID (0))
Chris Lattner9d2fda62007-02-13 05:53:56 +00001564
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001565#endif
1566
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001567/* YYFINAL -- State number of the termination state. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001568#define YYFINAL 39
Reid Spencer38c91a92007-02-28 02:24:54 +00001569/* YYLAST -- Last index in YYTABLE. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001570#define YYLAST 1317
Reid Spencer38c91a92007-02-28 02:24:54 +00001571
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001572/* YYNTOKENS -- Number of terminals. */
1573#define YYNTOKENS 149
1574/* YYNNTS -- Number of nonterminals. */
1575#define YYNNTS 79
1576/* YYNRULES -- Number of rules. */
1577#define YYNRULES 288
1578/* YYNRULES -- Number of states. */
1579#define YYNSTATES 563
Reid Spencer38c91a92007-02-28 02:24:54 +00001580
1581/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1582#define YYUNDEFTOK 2
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001583#define YYMAXUTOK 389
Reid Spencer38c91a92007-02-28 02:24:54 +00001584
1585#define YYTRANSLATE(YYX) \
1586 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1587
1588/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001589static const yytype_uint8 yytranslate[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001590{
1591 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001595 139, 140, 137, 2, 136, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001597 144, 135, 145, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1599 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001600 2, 141, 138, 143, 2, 2, 2, 2, 2, 148,
Reid Spencer38c91a92007-02-28 02:24:54 +00001601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001603 142, 2, 2, 146, 2, 147, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1616 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1617 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1618 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1619 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1620 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1621 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1622 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1623 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1624 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1625 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1626 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1627 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1628 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001629 125, 126, 127, 128, 129, 130, 131, 132, 133, 134
Reid Spencer38c91a92007-02-28 02:24:54 +00001630};
1631
1632#if YYDEBUG
1633/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1634 YYRHS. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001635static const yytype_uint16 yyprhs[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001636{
1637 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1638 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1639 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1640 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1641 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1642 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1643 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1644 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1645 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1646 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001647 195, 197, 199, 200, 203, 204, 207, 208, 212, 215,
1648 216, 218, 219, 223, 225, 228, 230, 232, 234, 236,
1649 238, 240, 243, 245, 248, 254, 260, 266, 272, 276,
1650 279, 285, 290, 293, 295, 297, 299, 303, 305, 309,
1651 311, 312, 314, 318, 323, 327, 331, 336, 341, 345,
1652 352, 358, 361, 364, 367, 370, 373, 376, 379, 382,
1653 385, 388, 391, 394, 401, 407, 416, 423, 430, 438,
1654 446, 453, 462, 471, 475, 477, 479, 481, 483, 484,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001655 486, 487, 489, 492, 493, 497, 498, 502, 506, 510,
1656 514, 515, 523, 524, 533, 534, 543, 546, 550, 552,
1657 556, 560, 564, 568, 570, 571, 577, 581, 583, 587,
1658 589, 590, 600, 602, 604, 609, 611, 613, 616, 620,
1659 621, 623, 625, 627, 629, 631, 633, 635, 637, 639,
1660 643, 645, 651, 653, 655, 657, 659, 661, 663, 666,
1661 669, 672, 676, 679, 680, 682, 685, 688, 692, 702,
1662 712, 721, 736, 738, 740, 747, 753, 756, 763, 771,
1663 775, 781, 782, 783, 787, 790, 792, 798, 804, 811,
1664 818, 823, 830, 835, 840, 847, 854, 857, 866, 868,
1665 870, 871, 875, 882, 886, 893, 896, 901, 908
Reid Spencer38c91a92007-02-28 02:24:54 +00001666};
1667
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001668/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1669static const yytype_int16 yyrhs[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001670{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001671 190, 0, -1, 68, -1, 69, -1, 70, -1, 71,
1672 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1673 -1, 80, -1, 81, -1, 82, -1, 77, -1, 78,
1674 -1, 79, -1, 111, -1, 112, -1, 113, -1, 114,
1675 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1676 -1, 120, -1, 121, -1, 122, -1, 85, -1, 86,
1677 -1, 87, -1, 88, -1, 89, -1, 90, -1, 91,
1678 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1679 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1680 -1, 102, -1, 103, -1, 104, -1, 91, -1, 92,
1681 -1, 93, -1, 94, -1, 22, -1, 23, -1, 11,
1682 -1, 12, -1, 13, -1, 16, -1, 19, -1, 157,
1683 -1, -1, 157, 135, -1, -1, 17, -1, 20, -1,
1684 160, 135, -1, -1, 37, -1, 39, -1, 38, -1,
1685 40, -1, 42, -1, 41, -1, 43, -1, 45, -1,
1686 -1, 134, -1, -1, 41, -1, 43, -1, -1, 37,
1687 -1, 38, -1, 39, -1, 42, -1, -1, 56, -1,
1688 57, -1, 58, -1, 59, -1, 60, -1, 55, 4,
1689 -1, 112, -1, 113, -1, 130, -1, 131, -1, -1,
1690 169, 168, -1, 129, -1, 132, -1, 168, -1, -1,
1691 171, 170, -1, -1, 48, 4, -1, -1, 136, 48,
1692 4, -1, 30, 19, -1, -1, 174, -1, -1, 136,
1693 177, 176, -1, 174, -1, 48, 4, -1, 11, -1,
1694 12, -1, 13, -1, 14, -1, 44, -1, 178, -1,
1695 179, 137, -1, 212, -1, 138, 4, -1, 179, 139,
1696 183, 140, 171, -1, 10, 139, 183, 140, 171, -1,
1697 141, 4, 142, 179, 143, -1, 144, 4, 142, 179,
1698 145, -1, 146, 184, 147, -1, 146, 147, -1, 144,
1699 146, 184, 147, 145, -1, 144, 146, 147, 145, -1,
1700 179, 169, -1, 179, -1, 10, -1, 180, -1, 182,
1701 136, 180, -1, 182, -1, 182, 136, 34, -1, 34,
1702 -1, -1, 179, -1, 184, 136, 179, -1, 179, 141,
1703 187, 143, -1, 179, 141, 143, -1, 179, 148, 19,
1704 -1, 179, 144, 187, 145, -1, 179, 146, 187, 147,
1705 -1, 179, 146, 147, -1, 179, 144, 146, 187, 147,
1706 145, -1, 179, 144, 146, 147, 145, -1, 179, 35,
1707 -1, 179, 36, -1, 179, 212, -1, 179, 186, -1,
1708 179, 21, -1, 155, 3, -1, 155, 5, -1, 155,
1709 4, -1, 155, 6, -1, 11, 22, -1, 11, 23,
1710 -1, 156, 9, -1, 152, 139, 185, 33, 179, 140,
1711 -1, 110, 139, 185, 223, 140, -1, 124, 139, 185,
1712 136, 185, 136, 185, 140, -1, 150, 139, 185, 136,
1713 185, 140, -1, 151, 139, 185, 136, 185, 140, -1,
1714 83, 153, 139, 185, 136, 185, 140, -1, 84, 154,
1715 139, 185, 136, 185, 140, -1, 126, 139, 185, 136,
1716 185, 140, -1, 127, 139, 185, 136, 185, 136, 185,
1717 140, -1, 128, 139, 185, 136, 185, 136, 185, 140,
1718 -1, 187, 136, 185, -1, 185, -1, 28, -1, 29,
1719 -1, 32, -1, -1, 191, -1, -1, 192, -1, 191,
1720 192, -1, -1, 27, 193, 208, -1, -1, 26, 194,
1721 209, -1, 53, 52, 198, -1, 159, 15, 179, -1,
1722 159, 15, 10, -1, -1, 161, 164, 189, 188, 185,
1723 195, 176, -1, -1, 161, 162, 164, 189, 188, 185,
1724 196, 176, -1, -1, 161, 163, 164, 189, 188, 179,
1725 197, 176, -1, 46, 199, -1, 49, 135, 200, -1,
1726 19, -1, 47, 135, 19, -1, 61, 135, 19, -1,
1727 141, 201, 143, -1, 201, 136, 19, -1, 19, -1,
1728 -1, 202, 136, 179, 169, 158, -1, 179, 169, 158,
1729 -1, 202, -1, 202, 136, 34, -1, 34, -1, -1,
1730 167, 181, 160, 139, 203, 140, 171, 175, 172, -1,
1731 24, -1, 146, -1, 166, 164, 204, 205, -1, 25,
1732 -1, 147, -1, 215, 207, -1, 165, 164, 204, -1,
1733 -1, 54, -1, 3, -1, 4, -1, 9, -1, 22,
1734 -1, 23, -1, 35, -1, 36, -1, 21, -1, 144,
1735 187, 145, -1, 186, -1, 52, 210, 19, 136, 19,
1736 -1, 7, -1, 8, -1, 157, -1, 160, -1, 212,
1737 -1, 211, -1, 179, 213, -1, 215, 216, -1, 206,
1738 216, -1, 217, 159, 218, -1, 217, 220, -1, -1,
1739 18, -1, 62, 214, -1, 62, 10, -1, 63, 14,
1740 213, -1, 63, 11, 213, 136, 14, 213, 136, 14,
1741 213, -1, 64, 155, 213, 136, 14, 213, 141, 219,
1742 143, -1, 64, 155, 213, 136, 14, 213, 141, 143,
1743 -1, 65, 167, 181, 213, 139, 222, 140, 171, 33,
1744 14, 213, 66, 14, 213, -1, 66, -1, 67, -1,
1745 219, 155, 211, 136, 14, 213, -1, 155, 211, 136,
1746 14, 213, -1, 159, 225, -1, 179, 141, 213, 136,
1747 213, 143, -1, 221, 136, 141, 213, 136, 213, 143,
1748 -1, 179, 213, 169, -1, 222, 136, 179, 213, 169,
1749 -1, -1, -1, 223, 136, 214, -1, 51, 50, -1,
1750 50, -1, 150, 179, 213, 136, 213, -1, 151, 179,
1751 213, 136, 213, -1, 83, 153, 179, 213, 136, 213,
1752 -1, 84, 154, 179, 213, 136, 213, -1, 152, 214,
1753 33, 179, -1, 124, 214, 136, 214, 136, 214, -1,
1754 125, 214, 136, 179, -1, 126, 214, 136, 214, -1,
1755 127, 214, 136, 214, 136, 214, -1, 128, 214, 136,
1756 214, 136, 214, -1, 123, 221, -1, 224, 167, 181,
1757 213, 139, 222, 140, 171, -1, 227, -1, 31, -1,
1758 -1, 105, 179, 173, -1, 105, 179, 136, 11, 213,
1759 173, -1, 106, 179, 173, -1, 106, 179, 136, 11,
1760 213, 173, -1, 107, 214, -1, 226, 108, 179, 213,
1761 -1, 226, 109, 214, 136, 179, 213, -1, 110, 179,
1762 213, 223, -1
Reid Spencer38c91a92007-02-28 02:24:54 +00001763};
1764
1765/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001766static const yytype_uint16 yyrline[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001767{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001768 0, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1769 1093, 1094, 1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095,
1770 1095, 1095, 1095, 1096, 1096, 1096, 1096, 1096, 1096, 1099,
1771 1099, 1100, 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1107,
1772 1107, 1108, 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112,
1773 1112, 1113, 1113, 1114, 1115, 1120, 1121, 1121, 1123, 1123,
1774 1124, 1124, 1128, 1132, 1137, 1137, 1139, 1143, 1149, 1150,
1775 1151, 1152, 1153, 1157, 1158, 1159, 1163, 1164, 1168, 1169,
1776 1170, 1174, 1175, 1176, 1177, 1178, 1181, 1182, 1183, 1184,
1777 1185, 1186, 1187, 1194, 1195, 1196, 1197, 1200, 1201, 1206,
1778 1207, 1208, 1211, 1212, 1219, 1220, 1226, 1227, 1235, 1243,
1779 1244, 1249, 1250, 1251, 1256, 1269, 1269, 1269, 1269, 1272,
1780 1276, 1280, 1287, 1292, 1300, 1326, 1353, 1358, 1370, 1380,
1781 1384, 1394, 1401, 1408, 1415, 1420, 1425, 1432, 1433, 1440,
1782 1447, 1455, 1461, 1473, 1501, 1517, 1546, 1574, 1599, 1618,
1783 1644, 1664, 1676, 1683, 1749, 1759, 1769, 1775, 1785, 1791,
1784 1801, 1806, 1811, 1819, 1831, 1853, 1861, 1867, 1878, 1883,
1785 1888, 1894, 1900, 1909, 1913, 1921, 1921, 1924, 1924, 1935,
1786 1940, 1948, 1949, 1953, 1953, 1957, 1957, 1960, 1963, 1987,
1787 1998, 1998, 2008, 2008, 2016, 2016, 2026, 2029, 2035, 2048,
1788 2052, 2057, 2059, 2064, 2069, 2078, 2088, 2099, 2103, 2112,
1789 2121, 2126, 2245, 2245, 2247, 2256, 2256, 2258, 2263, 2275,
1790 2279, 2284, 2288, 2292, 2296, 2300, 2304, 2308, 2312, 2316,
1791 2341, 2345, 2359, 2363, 2367, 2371, 2377, 2377, 2383, 2392,
1792 2396, 2405, 2414, 2423, 2427, 2432, 2436, 2440, 2445, 2455,
1793 2474, 2483, 2559, 2563, 2570, 2581, 2594, 2604, 2615, 2625,
1794 2634, 2643, 2646, 2647, 2654, 2658, 2663, 2684, 2701, 2715,
1795 2729, 2741, 2749, 2756, 2762, 2768, 2774, 2789, 2861, 2866,
1796 2870, 2877, 2884, 2892, 2899, 2907, 2915, 2929, 2946
Reid Spencer38c91a92007-02-28 02:24:54 +00001797};
1798#endif
1799
1800#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1801/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001802 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Reid Spencer38c91a92007-02-28 02:24:54 +00001803static const char *const yytname[] =
1804{
1805 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1806 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1807 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001808 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1809 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001810 "CONSTANT", "SECTION", "VOLATILE", "THREAD_LOCAL", "TO", "DOTDOTDOT",
1811 "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", "APPENDING",
1812 "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET",
1813 "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1814 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK",
1815 "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR",
1816 "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV",
1817 "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL",
1818 "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE",
1819 "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE",
1820 "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001821 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1822 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1823 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1824 "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "NOUNWIND", "DEFAULT",
1825 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1826 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1827 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1828 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1829 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1830 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1831 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1832 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1833 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1834 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001835 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "ThreadLocal",
1836 "Module", "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5",
1837 "AsmBlock", "TargetDefinition", "LibrariesDefinition", "LibList",
1838 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1839 "END", "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Reid Spencer38c91a92007-02-28 02:24:54 +00001840 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1841 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1842 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1843 "OptVolatile", "MemoryInst", 0
1844};
1845#endif
1846
1847# ifdef YYPRINT
1848/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1849 token YYLEX-NUM. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001850static const yytype_uint16 yytoknum[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001851{
1852 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1853 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1854 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1855 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1856 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1857 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1858 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1859 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1860 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1861 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1862 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1863 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1864 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001865 385, 386, 387, 388, 389, 61, 44, 42, 92, 40,
1866 41, 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer38c91a92007-02-28 02:24:54 +00001867};
1868# endif
1869
1870/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001871static const yytype_uint8 yyr1[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001872{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001873 0, 149, 150, 150, 150, 150, 150, 150, 150, 150,
1874 150, 151, 151, 151, 151, 151, 151, 152, 152, 152,
Reid Spencer38c91a92007-02-28 02:24:54 +00001875 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001876 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1877 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1878 154, 154, 154, 154, 154, 155, 156, 156, 157, 157,
1879 158, 158, 159, 159, 160, 160, 161, 161, 162, 162,
1880 162, 162, 162, 163, 163, 163, 164, 164, 165, 165,
1881 165, 166, 166, 166, 166, 166, 167, 167, 167, 167,
1882 167, 167, 167, 168, 168, 168, 168, 169, 169, 170,
1883 170, 170, 171, 171, 172, 172, 173, 173, 174, 175,
1884 175, 176, 176, 177, 177, 178, 178, 178, 178, 179,
1885 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1886 179, 179, 180, 181, 181, 182, 182, 183, 183, 183,
1887 183, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1888 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
1889 185, 185, 185, 186, 186, 186, 186, 186, 186, 186,
1890 186, 186, 186, 187, 187, 188, 188, 189, 189, 190,
1891 190, 191, 191, 193, 192, 194, 192, 192, 192, 192,
1892 195, 192, 196, 192, 197, 192, 192, 192, 198, 199,
1893 199, 200, 201, 201, 201, 202, 202, 203, 203, 203,
1894 203, 204, 205, 205, 206, 207, 207, 208, 209, 210,
1895 210, 211, 211, 211, 211, 211, 211, 211, 211, 211,
1896 211, 211, 212, 212, 212, 212, 213, 213, 214, 215,
1897 215, 216, 217, 217, 217, 218, 218, 218, 218, 218,
1898 218, 218, 218, 218, 219, 219, 220, 221, 221, 222,
1899 222, 222, 223, 223, 224, 224, 225, 225, 225, 225,
1900 225, 225, 225, 225, 225, 225, 225, 225, 225, 226,
1901 226, 227, 227, 227, 227, 227, 227, 227, 227
Reid Spencer38c91a92007-02-28 02:24:54 +00001902};
1903
1904/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001905static const yytype_uint8 yyr2[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001906{
1907 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1908 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1909 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1910 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1911 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1912 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1913 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1914 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1915 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1916 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001917 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1918 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1919 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1920 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1921 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1922 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1923 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1924 6, 8, 8, 3, 1, 1, 1, 1, 0, 1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001925 0, 1, 2, 0, 3, 0, 3, 3, 3, 3,
1926 0, 7, 0, 8, 0, 8, 2, 3, 1, 3,
1927 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1928 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1929 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1930 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1931 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1932 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1933 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1934 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1935 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer38c91a92007-02-28 02:24:54 +00001936};
1937
1938/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1939 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1940 means the default is an error. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001941static const yytype_uint16 yydefact[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00001942{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001943 67, 58, 64, 59, 65, 185, 183, 0, 0, 0,
1944 0, 0, 0, 76, 0, 67, 181, 78, 81, 0,
1945 0, 196, 0, 0, 62, 0, 66, 68, 70, 69,
1946 71, 73, 72, 74, 75, 77, 76, 76, 178, 1,
1947 182, 79, 80, 76, 186, 82, 83, 84, 85, 76,
1948 243, 184, 243, 0, 0, 204, 197, 198, 187, 232,
1949 233, 189, 115, 116, 117, 118, 119, 0, 0, 0,
1950 0, 234, 235, 120, 188, 122, 178, 178, 177, 0,
1951 86, 86, 244, 240, 63, 215, 216, 217, 239, 199,
1952 200, 203, 0, 140, 123, 0, 0, 0, 0, 129,
1953 141, 0, 121, 140, 0, 0, 175, 176, 0, 0,
1954 87, 88, 89, 90, 91, 0, 218, 0, 280, 242,
1955 0, 201, 139, 97, 135, 137, 0, 0, 0, 0,
1956 0, 0, 128, 0, 0, 0, 115, 116, 117, 0,
1957 0, 0, 190, 92, 134, 133, 0, 212, 213, 214,
1958 279, 265, 0, 0, 0, 0, 86, 252, 253, 2,
1959 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
1960 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
1961 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1962 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
1963 0, 241, 86, 256, 0, 278, 202, 132, 0, 102,
1964 0, 0, 131, 0, 142, 102, 192, 194, 160, 161,
1965 156, 158, 157, 159, 162, 155, 151, 152, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00001966 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001967 0, 0, 154, 153, 111, 0, 264, 246, 0, 245,
1968 0, 0, 55, 0, 0, 29, 30, 31, 32, 33,
1969 34, 35, 36, 37, 38, 0, 53, 54, 49, 50,
1970 51, 52, 39, 40, 41, 42, 43, 44, 45, 46,
1971 47, 48, 0, 106, 106, 285, 0, 0, 276, 0,
1972 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1973 93, 94, 95, 96, 98, 138, 136, 125, 126, 127,
1974 130, 124, 111, 111, 0, 0, 0, 0, 0, 0,
1975 0, 144, 174, 0, 0, 0, 148, 0, 145, 0,
1976 0, 0, 0, 191, 210, 221, 222, 223, 228, 224,
1977 225, 226, 227, 219, 0, 230, 237, 236, 238, 0,
1978 247, 0, 0, 0, 0, 0, 281, 0, 283, 262,
1979 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1980 0, 0, 0, 99, 100, 101, 103, 193, 195, 0,
1981 0, 262, 0, 0, 0, 0, 0, 143, 129, 141,
1982 0, 146, 147, 0, 0, 0, 0, 0, 113, 111,
1983 209, 97, 207, 0, 220, 0, 0, 0, 0, 0,
1984 0, 0, 0, 0, 0, 288, 0, 0, 0, 272,
1985 273, 0, 0, 0, 0, 270, 0, 286, 0, 0,
1986 0, 0, 0, 0, 0, 0, 173, 150, 0, 0,
1987 0, 0, 108, 114, 112, 61, 0, 102, 0, 229,
1988 0, 0, 261, 0, 0, 106, 107, 106, 0, 0,
1989 0, 0, 0, 0, 266, 267, 261, 0, 0, 0,
1990 164, 0, 0, 0, 0, 149, 0, 0, 0, 60,
1991 206, 208, 97, 109, 0, 0, 0, 0, 0, 268,
1992 269, 0, 282, 284, 263, 0, 0, 271, 274, 275,
1993 0, 287, 0, 0, 0, 170, 0, 0, 166, 167,
1994 163, 61, 110, 104, 231, 0, 0, 97, 0, 102,
1995 257, 0, 102, 168, 169, 0, 0, 0, 205, 0,
1996 211, 0, 250, 0, 0, 259, 0, 0, 258, 277,
1997 165, 171, 172, 105, 248, 0, 249, 0, 97, 0,
1998 0, 0, 260, 0, 0, 0, 0, 255, 0, 0,
1999 254, 0, 251
Reid Spencer38c91a92007-02-28 02:24:54 +00002000};
2001
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002002/* YYDEFGOTO[NTERM-NUM]. */
2003static const yytype_int16 yydefgoto[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002004{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002005 -1, 239, 240, 241, 265, 282, 139, 140, 71, 480,
2006 11, 72, 13, 36, 37, 38, 43, 49, 115, 304,
2007 207, 376, 307, 530, 356, 398, 513, 333, 399, 73,
2008 141, 124, 146, 125, 126, 101, 322, 345, 323, 108,
2009 79, 14, 15, 16, 18, 17, 244, 312, 313, 58,
2010 21, 56, 92, 402, 403, 116, 149, 50, 87, 51,
2011 44, 405, 346, 75, 348, 249, 52, 83, 84, 201,
2012 534, 119, 288, 488, 415, 202, 203, 204, 205
Reid Spencer38c91a92007-02-28 02:24:54 +00002013};
2014
2015/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2016 STATE-NUM. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002017#define YYPACT_NINF -476
2018static const yytype_int16 yypact[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002019{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002020 28, -476, -476, -476, -476, -476, -476, -10, -55, 8,
2021 -33, 97, 3, 55, 167, 394, -476, 172, 210, 86,
2022 98, -476, 102, 219, -476, 1017, -476, -476, -476, -476,
2023 -476, -476, -476, -476, -476, -476, 123, 123, 218, -476,
2024 -476, -476, -476, 123, -476, -476, -476, -476, -476, 123,
2025 241, -476, 2, 242, 251, 253, -476, -476, -476, -476,
2026 -476, 137, -476, -476, -476, -476, -476, 274, 283, 1,
2027 456, -476, -476, -476, 83, -476, 218, 218, -476, 103,
2028 291, 291, -476, -476, 121, -476, -476, -476, -476, -476,
2029 -476, -476, -26, 874, -476, 148, 149, 470, 137, -476,
2030 83, -97, -476, 874, 103, 103, -476, -476, 1031, 288,
2031 -476, -476, -476, -476, -476, 1073, -476, -7, 1172, -476,
2032 282, -476, -476, 83, -476, 157, 162, 1087, 1087, 158,
2033 -61, 1087, -476, 165, 1031, 1087, 60, 297, 298, 201,
2034 299, 656, -476, -476, 137, 83, 217, -476, -476, -476,
2035 -476, -476, 262, 1129, 257, 302, 291, -476, -476, -476,
2036 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
2037 -476, -476, -476, -476, 461, 273, 1087, 1087, 1087, 1087,
2038 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
2039 -476, -476, 1087, 1087, 1087, 1087, 1087, 1087, 1087, 1087,
2040 1087, -476, 291, -476, 74, -476, -476, -25, 914, -476,
2041 19, 41, -476, 175, 83, -476, -476, 83, -476, -476,
2042 -476, -476, -476, -476, -476, -476, -476, -476, 461, 273,
2043 178, 182, 183, 184, 186, 933, 1171, 552, 309, 190,
2044 191, 194, -476, -476, 199, 197, -476, 137, 509, -476,
2045 635, 635, -476, 635, 1073, -476, -476, -476, -476, -476,
2046 -476, -476, -476, -476, -476, 1087, -476, -476, -476, -476,
2047 -476, -476, -476, -476, -476, -476, -476, -476, -476, -476,
2048 -476, -476, 1087, -17, 92, -476, 509, 75, 207, 208,
2049 220, 221, 222, 223, 509, 509, 304, 1073, 1087, 1087,
2050 -476, -476, -476, -476, -476, -476, -476, 154, -476, -476,
2051 -476, 154, 199, 199, 214, 215, 1031, 1031, 1031, 1031,
2052 1031, -476, -476, -22, 828, -75, -476, -58, -476, 1031,
2053 1031, 1031, 5, -476, 972, -476, -476, -476, -476, -476,
2054 -476, -476, -476, 301, 1031, -476, -476, -476, -476, 224,
2055 -476, 226, 635, 509, 509, 14, -476, 23, -476, -476,
2056 635, 237, 1087, 1087, 1087, 1087, 1087, 243, 244, 1087,
2057 635, 509, 246, -476, -476, -476, -476, -476, -476, 1031,
2058 1031, -476, 247, 248, 254, 255, 1031, -476, 250, 656,
2059 -46, -476, -476, 256, 261, 360, 383, 399, -476, 199,
2060 -476, 83, 269, 266, -476, 388, -60, 398, 401, 277,
2061 272, 289, 635, 420, 635, 293, 294, 635, 295, 83,
2062 -476, 296, 300, 635, 635, 83, 305, -476, 1087, 310,
2063 314, -98, 1031, 1031, 1031, 1031, -476, -476, 290, 1031,
2064 1031, 1087, -476, -476, -476, 33, 988, -476, 315, -476,
2065 635, 635, 1087, 635, 635, 316, -476, 316, 1087, 635,
2066 317, 1087, 1087, 1087, -476, -476, 1087, 509, 1031, 1031,
2067 -476, 318, 287, 320, 321, -476, 319, 322, 116, -476,
2068 -476, -476, 83, 79, 414, 324, 330, 509, 21, -476,
2069 -476, 393, -476, -476, -476, 331, 635, -476, -476, -476,
2070 59, -476, 325, 339, 1031, -476, 1031, 1031, -476, -476,
2071 -476, 33, -476, 410, -476, 447, -2, -476, 1087, -476,
2072 -476, 342, -476, -476, -476, 348, 351, 352, -476, 489,
2073 -476, 635, -476, 785, -1, -25, 509, 133, -476, 154,
2074 -476, -476, -476, -476, -476, 359, -476, 785, -476, 482,
2075 483, 362, -25, 635, 635, 485, 439, -476, 635, 492,
2076 -476, 635, -476
Reid Spencer38c91a92007-02-28 02:24:54 +00002077};
2078
2079/* YYPGOTO[NTERM-NUM]. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002080static const yytype_int16 yypgoto[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002081{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002082 -476, 389, 392, 397, 292, 306, -153, -476, 0, 10,
2083 435, 4, -476, -476, -476, 87, -476, -476, -145, -295,
2084 -383, -476, -208, -476, -276, 39, -476, -291, -476, -476,
2085 -24, 326, -241, -476, 421, 426, 69, -138, -196, 89,
2086 204, -476, -476, 512, -476, -476, -476, -476, -476, -476,
2087 -476, -476, -476, -476, -476, 452, -476, -476, -476, -476,
2088 -476, -476, -475, -135, -227, -164, -476, 484, -476, -476,
2089 -476, -476, -476, 73, 159, -476, -476, -476, -476
Reid Spencer38c91a92007-02-28 02:24:54 +00002090};
2091
2092/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2093 positive, shift that token. If negative, reduce the rule which
2094 number is the opposite. If zero, do what YYDEFACT says.
2095 If YYTABLE_NINF, syntax error. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002096#define YYTABLE_NINF -181
2097static const yytype_int16 yytable[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002098{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002099 10, 74, 253, 242, 12, 96, 243, 311, 358, 252,
2100 252, 254, 375, 352, 285, 10, 375, 147, 445, 12,
2101 82, 377, 378, 349, 350, 412, 351, 85, -180, 289,
2102 290, 291, 292, 293, 414, 396, 296, 19, 458, 131,
2103 325, 327, 470, -63, 1, 2, 100, 3, 4, 1,
2104 132, 20, 3, 397, 5, 6, 370, 297, 545, 359,
2105 23, 386, 413, -55, -55, -55, -55, 367, 368, 123,
2106 391, 413, 551, 100, 7, 131, 386, 8, 386, 123,
2107 22, 9, 218, 219, 10, 449, 213, 300, 301, 392,
2108 386, 145, 27, 28, 29, 30, 31, 32, 33, 511,
2109 34, 438, 24, 210, 211, 302, 303, 214, 444, 396,
2110 120, 217, 25, 347, 386, 347, 347, 121, 347, 355,
2111 102, 387, 103, 76, 77, 409, 410, 411, 390, 248,
2112 80, 106, 107, 416, 535, 372, 81, 1, 26, 148,
2113 3, 532, 546, 426, 427, 300, 301, 97, 406, 86,
2114 245, 347, 283, 284, 248, 286, 102, 518, 103, 347,
2115 347, 519, 308, 302, 303, 552, 549, 39, 287, 248,
2116 248, 248, 248, 248, 294, 295, 248, 142, 102, 492,
2117 103, 493, 298, 299, 123, 455, 309, 457, 375, 35,
2118 460, 300, 301, 134, 135, 518, 464, 465, 418, 522,
2119 420, 421, 422, 216, 220, 221, 222, 223, 373, 302,
2120 303, 374, 102, 41, 103, 42, 360, 347, 347, 347,
2121 102, 53, 103, 485, 486, 347, 489, 490, 357, 102,
2122 145, 103, 495, 54, 2, 347, 347, 4, 57, 483,
2123 501, 353, 375, 55, 375, 300, 301, 45, 46, 47,
2124 78, 242, 48, 102, 243, 103, 510, 35, 354, 82,
2125 517, 89, 373, 302, 303, 374, 300, 301, 250, 521,
2126 90, 251, 91, 145, 371, 248, 93, 347, 94, 347,
2127 104, 105, 347, 373, 302, 303, 374, 95, 347, 347,
2128 127, 128, 143, 208, 494, 266, 267, 497, 498, 499,
2129 389, 206, 209, 212, 544, 215, -56, -57, 224, 548,
2130 401, 537, 246, 252, 539, 347, 347, 316, 347, 347,
2131 310, 317, 318, 319, 347, 320, 556, 557, 328, 329,
2132 330, 560, 347, 331, 562, 332, 334, 369, 248, 419,
2133 248, 248, 248, 361, 362, 425, 109, 110, 111, 112,
2134 113, 114, 347, 379, 380, 404, 363, 364, 365, 366,
2135 407, 347, 408, 533, 268, 269, 270, 271, 272, 273,
2136 274, 275, 276, 277, 278, 279, 280, 281, 417, 423,
2137 424, 547, 428, 432, 433, 381, 382, 383, 384, 385,
2138 434, 435, 439, 441, -179, 437, 347, 440, 393, 394,
2139 395, 347, 442, 443, 467, 446, 447, 448, 453, -63,
2140 1, 2, 450, 3, 4, 451, 452, 478, 347, 347,
2141 5, 6, 482, 347, 456, 454, 347, 505, 487, 458,
2142 459, 461, 462, 514, 248, 475, 463, 248, 248, 248,
2143 7, 413, 487, 8, 466, 479, 468, 9, 429, 430,
2144 469, 484, 491, 496, 504, 436, 506, 507, 529, 508,
2145 515, 531, 509, 59, 60, 523, 98, 62, 63, 64,
2146 65, 516, 1, 2, 520, 3, 4, 59, 60, 524,
2147 98, 62, 63, 64, 65, 538, 1, 2, 540, 3,
2148 4, 541, 542, 543, 536, 550, 553, 554, 555, 558,
2149 66, 471, 472, 473, 474, 559, 561, 198, 476, 477,
2150 199, 479, 335, 336, 66, 200, 59, 60, 337, 118,
2151 314, 528, 512, 130, 133, 1, 2, 40, 3, 4,
2152 338, 339, 340, 117, 306, 315, 88, 502, 503, 500,
2153 431, 0, 0, 0, 341, 342, 255, 256, 257, 258,
2154 259, 260, 261, 262, 263, 264, 0, 0, 0, 59,
2155 60, 343, 98, 136, 137, 138, 65, 0, 1, 2,
2156 0, 3, 4, 525, 0, 526, 527, 159, 160, 161,
2157 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
2158 172, 173, 228, 229, 67, 0, 66, 68, 0, 0,
2159 69, 0, 70, 99, 0, 0, 0, 0, 67, 0,
2160 0, 68, 0, 0, 69, 0, 70, 129, 0, 230,
2161 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2162 190, 191, 0, 231, 0, 232, 233, 234, 335, 336,
2163 0, 0, 59, 60, 337, 0, 102, 0, 103, 0,
2164 0, 1, 2, 344, 3, 4, 338, 339, 340, 0,
2165 0, 0, 0, 59, 60, 0, 0, 0, 0, 0,
2166 341, 342, 1, 2, 0, 3, 4, 225, 0, 0,
2167 0, 0, 0, 0, 0, 0, 0, 343, 0, 0,
2168 67, 226, 227, 68, 0, 0, 69, 0, 70, 326,
2169 0, 0, 0, 159, 160, 161, 162, 163, 164, 165,
2170 166, 167, 168, 169, 170, 171, 172, 173, 228, 229,
2171 0, 0, 0, 0, 159, 160, 161, 162, 163, 164,
2172 165, 166, 167, 168, 169, 170, 171, 172, 173, 228,
2173 229, 0, 0, 0, 0, 230, 180, 181, 182, 183,
2174 184, 185, 186, 187, 188, 189, 190, 191, 0, 231,
2175 0, 232, 233, 234, 0, 0, 230, 180, 181, 182,
2176 183, 184, 185, 186, 187, 188, 189, 190, 191, 344,
2177 231, 0, 232, 233, 234, 0, 0, 0, 335, 336,
2178 0, 0, 0, 102, 337, 103, 0, 235, 0, 0,
2179 236, 0, 237, 0, 238, 0, 338, 339, 340, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002181 341, 342, 0, 0, 0, 0, 0, 0, 0, 0,
2182 0, 0, 0, 0, 0, 59, 60, 343, 98, 136,
2183 137, 138, 65, 0, 1, 2, 0, 3, 4, 0,
2184 0, 0, 0, 159, 160, 161, 162, 163, 164, 165,
2185 166, 167, 168, 169, 170, 171, 172, 173, 228, 229,
2186 0, 0, 66, 0, 0, 0, 0, 0, 0, 0,
2187 0, 59, 60, 0, 98, 62, 63, 64, 65, 0,
2188 1, 2, 0, 3, 4, 230, 180, 181, 182, 183,
2189 184, 185, 186, 187, 188, 189, 190, 191, 122, 231,
2190 0, 232, 233, 234, 0, 0, 0, 0, 66, 0,
2191 0, 59, 60, 0, 98, 62, 63, 64, 65, 344,
2192 1, 2, 0, 3, 4, 0, 0, 0, 0, 0,
2193 59, 60, 0, 98, 136, 137, 138, 65, 305, 1,
2194 2, 0, 3, 4, 0, 0, 0, 0, 66, 0,
2195 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
2196 0, 0, 69, 0, 70, 388, 0, 66, 0, 59,
2197 60, 0, 98, 62, 63, 64, 65, 0, 1, 2,
2198 0, 3, 4, 0, 0, 59, 60, 0, 98, 62,
2199 63, 64, 65, 0, 1, 2, 400, 3, 4, 0,
2200 0, 0, 67, 0, 0, 68, 66, 0, 69, 0,
2201 70, 0, 481, 0, 59, 60, 0, 61, 62, 63,
2202 64, 65, 66, 1, 2, 0, 3, 4, 59, 60,
2203 0, 98, 136, 137, 138, 65, 0, 1, 2, 0,
2204 3, 4, 67, 0, 0, 68, 0, 0, 69, 0,
2205 70, 66, 0, 0, 0, 0, 0, 0, 0, 0,
2206 0, 67, 0, 0, 68, 66, 321, 69, 0, 70,
2207 59, 60, 0, 144, 62, 63, 64, 65, 0, 1,
2208 2, 0, 3, 4, 59, 60, 0, 98, 62, 63,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002209 64, 65, 0, 1, 2, 0, 3, 4, 0, 0,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002210 67, 0, 0, 68, 0, 0, 69, 66, 70, 0,
2211 0, 0, 0, 0, 0, 0, 67, 0, 0, 68,
2212 0, 66, 69, 0, 70, 0, 59, 60, 0, 247,
2213 62, 63, 64, 65, 0, 1, 2, 0, 3, 4,
2214 0, 0, 0, 0, 0, 67, 0, 0, 68, 0,
2215 0, 69, 0, 70, 0, 0, 0, 0, 0, 67,
2216 0, 0, 68, 66, 0, 69, 0, 70, 59, 60,
2217 0, 98, 136, 137, 138, 65, 0, 1, 2, 0,
2218 3, 4, 0, 0, 0, 0, 0, 0, 0, 0,
2219 0, 0, 0, 150, 0, 0, 0, 0, 0, 0,
2220 0, 67, 0, 0, 68, 66, 0, 69, 0, 70,
2221 0, 0, 151, 152, 0, 67, 0, 0, 68, 0,
2222 0, 69, 0, 70, 153, 154, 155, 156, 157, 158,
2223 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
2224 169, 170, 171, 172, 173, 174, 175, 0, 0, 0,
2225 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
2226 68, 0, 0, 69, 0, 70, 0, 176, 177, 178,
2227 0, 0, 179, 180, 181, 182, 183, 184, 185, 186,
2228 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
2229 197, 0, 0, 0, 0, 0, 0, 0, 0, 67,
2230 0, 0, 68, 0, 0, 69, 0, 324
Reid Spencer38c91a92007-02-28 02:24:54 +00002231};
2232
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002233static const yytype_int16 yycheck[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002234{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002235 0, 25, 155, 141, 0, 4, 141, 215, 284, 11,
2236 11, 156, 307, 254, 178, 15, 311, 24, 401, 15,
2237 18, 312, 313, 250, 251, 11, 253, 25, 0, 193,
2238 194, 195, 196, 197, 11, 30, 200, 47, 136, 136,
2239 236, 237, 140, 15, 16, 17, 70, 19, 20, 16,
2240 147, 61, 19, 48, 26, 27, 297, 202, 533, 286,
2241 52, 136, 48, 3, 4, 5, 6, 294, 295, 93,
2242 145, 48, 547, 97, 46, 136, 136, 49, 136, 103,
2243 135, 53, 22, 23, 84, 145, 147, 112, 113, 147,
2244 136, 115, 37, 38, 39, 40, 41, 42, 43, 482,
2245 45, 147, 135, 127, 128, 130, 131, 131, 399, 30,
2246 136, 135, 15, 248, 136, 250, 251, 143, 253, 136,
2247 137, 143, 139, 36, 37, 352, 353, 354, 324, 153,
2248 43, 28, 29, 360, 517, 299, 49, 16, 135, 146,
2249 19, 143, 143, 370, 371, 112, 113, 146, 344, 147,
2250 146, 286, 176, 177, 178, 179, 137, 136, 139, 294,
2251 295, 140, 143, 130, 131, 548, 33, 0, 192, 193,
2252 194, 195, 196, 197, 198, 199, 200, 108, 137, 455,
2253 139, 457, 108, 109, 208, 412, 145, 414, 483, 134,
2254 417, 112, 113, 104, 105, 136, 423, 424, 362, 140,
2255 364, 365, 366, 134, 3, 4, 5, 6, 129, 130,
2256 131, 132, 137, 41, 139, 43, 141, 352, 353, 354,
2257 137, 135, 139, 450, 451, 360, 453, 454, 136, 137,
2258 254, 139, 459, 135, 17, 370, 371, 20, 19, 447,
2259 467, 265, 537, 141, 539, 112, 113, 37, 38, 39,
2260 32, 389, 42, 137, 389, 139, 140, 134, 282, 18,
2261 487, 19, 129, 130, 131, 132, 112, 113, 11, 496,
2262 19, 14, 19, 297, 298, 299, 139, 412, 4, 414,
2263 76, 77, 417, 129, 130, 131, 132, 4, 423, 424,
2264 142, 142, 4, 136, 458, 22, 23, 461, 462, 463,
2265 324, 19, 140, 145, 531, 140, 9, 9, 9, 536,
2266 334, 519, 50, 11, 522, 450, 451, 139, 453, 454,
2267 145, 139, 139, 139, 459, 139, 553, 554, 19, 139,
2268 139, 558, 467, 139, 561, 136, 139, 33, 362, 363,
2269 364, 365, 366, 136, 136, 369, 55, 56, 57, 58,
2270 59, 60, 487, 139, 139, 54, 136, 136, 136, 136,
2271 136, 496, 136, 516, 91, 92, 93, 94, 95, 96,
2272 97, 98, 99, 100, 101, 102, 103, 104, 141, 136,
2273 136, 534, 136, 136, 136, 316, 317, 318, 319, 320,
2274 136, 136, 136, 33, 0, 145, 531, 136, 329, 330,
2275 331, 536, 19, 4, 428, 136, 140, 19, 136, 15,
2276 16, 17, 14, 19, 20, 14, 139, 441, 553, 554,
2277 26, 27, 446, 558, 4, 136, 561, 140, 452, 136,
2278 136, 136, 136, 19, 458, 145, 136, 461, 462, 463,
2279 46, 48, 466, 49, 139, 445, 136, 53, 379, 380,
2280 136, 136, 136, 136, 136, 386, 136, 136, 48, 140,
2281 136, 14, 140, 7, 8, 140, 10, 11, 12, 13,
2282 14, 141, 16, 17, 143, 19, 20, 7, 8, 140,
2283 10, 11, 12, 13, 14, 143, 16, 17, 140, 19,
2284 20, 140, 140, 4, 518, 136, 14, 14, 136, 14,
2285 44, 432, 433, 434, 435, 66, 14, 118, 439, 440,
2286 118, 511, 3, 4, 44, 118, 7, 8, 9, 84,
2287 228, 511, 483, 97, 103, 16, 17, 15, 19, 20,
2288 21, 22, 23, 81, 208, 229, 52, 468, 469, 466,
2289 381, -1, -1, -1, 35, 36, 85, 86, 87, 88,
2290 89, 90, 91, 92, 93, 94, -1, -1, -1, 7,
2291 8, 52, 10, 11, 12, 13, 14, -1, 16, 17,
2292 -1, 19, 20, 504, -1, 506, 507, 68, 69, 70,
2293 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2294 81, 82, 83, 84, 138, -1, 44, 141, -1, -1,
2295 144, -1, 146, 147, -1, -1, -1, -1, 138, -1,
2296 -1, 141, -1, -1, 144, -1, 146, 147, -1, 110,
2297 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2298 121, 122, -1, 124, -1, 126, 127, 128, 3, 4,
2299 -1, -1, 7, 8, 9, -1, 137, -1, 139, -1,
2300 -1, 16, 17, 144, 19, 20, 21, 22, 23, -1,
2301 -1, -1, -1, 7, 8, -1, -1, -1, -1, -1,
2302 35, 36, 16, 17, -1, 19, 20, 21, -1, -1,
2303 -1, -1, -1, -1, -1, -1, -1, 52, -1, -1,
2304 138, 35, 36, 141, -1, -1, 144, -1, 146, 147,
2305 -1, -1, -1, 68, 69, 70, 71, 72, 73, 74,
2306 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2307 -1, -1, -1, -1, 68, 69, 70, 71, 72, 73,
Reid Spencer38c91a92007-02-28 02:24:54 +00002308 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002309 84, -1, -1, -1, -1, 110, 111, 112, 113, 114,
2310 115, 116, 117, 118, 119, 120, 121, 122, -1, 124,
2311 -1, 126, 127, 128, -1, -1, 110, 111, 112, 113,
2312 114, 115, 116, 117, 118, 119, 120, 121, 122, 144,
2313 124, -1, 126, 127, 128, -1, -1, -1, 3, 4,
2314 -1, -1, -1, 137, 9, 139, -1, 141, -1, -1,
2315 144, -1, 146, -1, 148, -1, 21, 22, 23, -1,
2316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2317 35, 36, -1, -1, -1, -1, -1, -1, -1, -1,
2318 -1, -1, -1, -1, -1, 7, 8, 52, 10, 11,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002319 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002320 -1, -1, -1, 68, 69, 70, 71, 72, 73, 74,
2321 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2322 -1, -1, 44, -1, -1, -1, -1, -1, -1, -1,
2323 -1, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2324 16, 17, -1, 19, 20, 110, 111, 112, 113, 114,
2325 115, 116, 117, 118, 119, 120, 121, 122, 34, 124,
2326 -1, 126, 127, 128, -1, -1, -1, -1, 44, -1,
2327 -1, 7, 8, -1, 10, 11, 12, 13, 14, 144,
2328 16, 17, -1, 19, 20, -1, -1, -1, -1, -1,
2329 7, 8, -1, 10, 11, 12, 13, 14, 34, 16,
2330 17, -1, 19, 20, -1, -1, -1, -1, 44, -1,
2331 -1, -1, -1, -1, -1, -1, 138, -1, -1, 141,
2332 -1, -1, 144, -1, 146, 147, -1, 44, -1, 7,
2333 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2334 -1, 19, 20, -1, -1, 7, 8, -1, 10, 11,
2335 12, 13, 14, -1, 16, 17, 34, 19, 20, -1,
2336 -1, -1, 138, -1, -1, 141, 44, -1, 144, -1,
2337 146, -1, 34, -1, 7, 8, -1, 10, 11, 12,
2338 13, 14, 44, 16, 17, -1, 19, 20, 7, 8,
2339 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2340 19, 20, 138, -1, -1, 141, -1, -1, 144, -1,
2341 146, 44, -1, -1, -1, -1, -1, -1, -1, -1,
2342 -1, 138, -1, -1, 141, 44, 143, 144, -1, 146,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002343 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer38c91a92007-02-28 02:24:54 +00002344 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002345 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002346 138, -1, -1, 141, -1, -1, 144, 44, 146, -1,
2347 -1, -1, -1, -1, -1, -1, 138, -1, -1, 141,
2348 -1, 44, 144, -1, 146, -1, 7, 8, -1, 10,
2349 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2350 -1, -1, -1, -1, -1, 138, -1, -1, 141, -1,
2351 -1, 144, -1, 146, -1, -1, -1, -1, -1, 138,
2352 -1, -1, 141, 44, -1, 144, -1, 146, 7, 8,
2353 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2354 19, 20, -1, -1, -1, -1, -1, -1, -1, -1,
2355 -1, -1, -1, 31, -1, -1, -1, -1, -1, -1,
2356 -1, 138, -1, -1, 141, 44, -1, 144, -1, 146,
2357 -1, -1, 50, 51, -1, 138, -1, -1, 141, -1,
2358 -1, 144, -1, 146, 62, 63, 64, 65, 66, 67,
2359 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2360 78, 79, 80, 81, 82, 83, 84, -1, -1, -1,
2361 -1, -1, -1, -1, -1, -1, -1, 138, -1, -1,
2362 141, -1, -1, 144, -1, 146, -1, 105, 106, 107,
2363 -1, -1, 110, 111, 112, 113, 114, 115, 116, 117,
2364 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2365 128, -1, -1, -1, -1, -1, -1, -1, -1, 138,
2366 -1, -1, 141, -1, -1, 144, -1, 146
Reid Spencer38c91a92007-02-28 02:24:54 +00002367};
2368
2369/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2370 symbol of state STATE-NUM. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002371static const yytype_uint8 yystos[] =
Reid Spencer38c91a92007-02-28 02:24:54 +00002372{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002373 0, 16, 17, 19, 20, 26, 27, 46, 49, 53,
2374 157, 159, 160, 161, 190, 191, 192, 194, 193, 47,
2375 61, 199, 135, 52, 135, 15, 135, 37, 38, 39,
2376 40, 41, 42, 43, 45, 134, 162, 163, 164, 0,
2377 192, 41, 43, 165, 209, 37, 38, 39, 42, 166,
2378 206, 208, 215, 135, 135, 141, 200, 19, 198, 7,
2379 8, 10, 11, 12, 13, 14, 44, 138, 141, 144,
2380 146, 157, 160, 178, 179, 212, 164, 164, 32, 189,
2381 164, 164, 18, 216, 217, 25, 147, 207, 216, 19,
2382 19, 19, 201, 139, 4, 4, 4, 146, 10, 147,
2383 179, 184, 137, 139, 189, 189, 28, 29, 188, 55,
2384 56, 57, 58, 59, 60, 167, 204, 204, 159, 220,
2385 136, 143, 34, 179, 180, 182, 183, 142, 142, 147,
2386 184, 136, 147, 183, 188, 188, 11, 12, 13, 155,
2387 156, 179, 185, 4, 10, 179, 181, 24, 146, 205,
2388 31, 50, 51, 62, 63, 64, 65, 66, 67, 68,
2389 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2390 79, 80, 81, 82, 83, 84, 105, 106, 107, 110,
Reid Spencer38c91a92007-02-28 02:24:54 +00002391 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002392 121, 122, 123, 124, 125, 126, 127, 128, 150, 151,
2393 152, 218, 224, 225, 226, 227, 19, 169, 136, 140,
2394 179, 179, 145, 147, 179, 140, 185, 179, 22, 23,
2395 3, 4, 5, 6, 9, 21, 35, 36, 83, 84,
2396 110, 124, 126, 127, 128, 141, 144, 146, 148, 150,
2397 151, 152, 186, 212, 195, 160, 50, 10, 179, 214,
2398 11, 14, 11, 155, 167, 85, 86, 87, 88, 89,
2399 90, 91, 92, 93, 94, 153, 22, 23, 91, 92,
2400 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2401 103, 104, 154, 179, 179, 214, 179, 179, 221, 214,
2402 214, 214, 214, 214, 179, 179, 214, 167, 108, 109,
2403 112, 113, 130, 131, 168, 34, 180, 171, 143, 145,
2404 145, 171, 196, 197, 153, 154, 139, 139, 139, 139,
2405 139, 143, 185, 187, 146, 187, 147, 187, 19, 139,
2406 139, 139, 136, 176, 139, 3, 4, 9, 21, 22,
2407 23, 35, 36, 52, 144, 186, 211, 212, 213, 213,
2408 213, 213, 181, 179, 179, 136, 173, 136, 173, 213,
2409 141, 136, 136, 136, 136, 136, 136, 213, 213, 33,
2410 181, 179, 214, 129, 132, 168, 170, 176, 176, 139,
2411 139, 185, 185, 185, 185, 185, 136, 143, 147, 179,
2412 187, 145, 147, 185, 185, 185, 30, 48, 174, 177,
2413 34, 179, 202, 203, 54, 210, 187, 136, 136, 213,
2414 213, 213, 11, 48, 11, 223, 213, 141, 214, 179,
2415 214, 214, 214, 136, 136, 179, 213, 213, 136, 185,
2416 185, 223, 136, 136, 136, 136, 185, 145, 147, 136,
2417 136, 33, 19, 4, 176, 169, 136, 140, 19, 145,
2418 14, 14, 139, 136, 136, 213, 4, 213, 136, 136,
2419 213, 136, 136, 136, 213, 213, 139, 179, 136, 136,
2420 140, 185, 185, 185, 185, 145, 185, 185, 179, 157,
2421 158, 34, 179, 171, 136, 213, 213, 179, 222, 213,
2422 213, 136, 173, 173, 214, 213, 136, 214, 214, 214,
2423 222, 213, 185, 185, 136, 140, 136, 136, 140, 140,
2424 140, 169, 174, 175, 19, 136, 141, 213, 136, 140,
2425 143, 213, 140, 140, 140, 185, 185, 185, 158, 48,
2426 172, 14, 143, 155, 219, 169, 179, 171, 143, 171,
2427 140, 140, 140, 4, 213, 211, 143, 155, 213, 33,
2428 136, 211, 169, 14, 14, 136, 213, 213, 14, 66,
2429 213, 14, 213
Reid Spencer38c91a92007-02-28 02:24:54 +00002430};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002431
2432#define yyerrok (yyerrstatus = 0)
2433#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002434#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002435#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002436
Reid Spencer68a24bd2005-08-27 18:50:39 +00002437#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002438#define YYABORT goto yyabortlab
2439#define YYERROR goto yyerrorlab
2440
2441
2442/* Like YYERROR except do call yyerror. This remains here temporarily
2443 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002444 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002445
Reid Spencer68a24bd2005-08-27 18:50:39 +00002446#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002447
Reid Spencer68a24bd2005-08-27 18:50:39 +00002448#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002449
2450#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002451do \
2452 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002453 { \
2454 yychar = (Token); \
2455 yylval = (Value); \
2456 yytoken = YYTRANSLATE (yychar); \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002457 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458 goto yybackup; \
2459 } \
2460 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002461 { \
2462 yyerror (YY_("syntax error: cannot back up")); \
2463 YYERROR; \
2464 } \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002465while (YYID (0))
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002466
Reid Spencer38c91a92007-02-28 02:24:54 +00002467
Reid Spencer68a24bd2005-08-27 18:50:39 +00002468#define YYTERROR 1
2469#define YYERRCODE 256
2470
Reid Spencer38c91a92007-02-28 02:24:54 +00002471
2472/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2473 If N is 0, then set CURRENT to the empty location which ends
2474 the previous symbol: RHS[0] (always defined). */
2475
2476#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2477#ifndef YYLLOC_DEFAULT
2478# define YYLLOC_DEFAULT(Current, Rhs, N) \
2479 do \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002480 if (YYID (N)) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002481 { \
2482 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2483 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2484 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2485 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2486 } \
2487 else \
2488 { \
2489 (Current).first_line = (Current).last_line = \
2490 YYRHSLOC (Rhs, 0).last_line; \
2491 (Current).first_column = (Current).last_column = \
2492 YYRHSLOC (Rhs, 0).last_column; \
2493 } \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002494 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002495#endif
2496
Reid Spencer38c91a92007-02-28 02:24:54 +00002497
2498/* YY_LOCATION_PRINT -- Print the location on the stream.
2499 This macro was not mandated originally: define only if we know
2500 we won't break user code: when these are the locations we know. */
2501
2502#ifndef YY_LOCATION_PRINT
2503# if YYLTYPE_IS_TRIVIAL
2504# define YY_LOCATION_PRINT(File, Loc) \
2505 fprintf (File, "%d.%d-%d.%d", \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002506 (Loc).first_line, (Loc).first_column, \
2507 (Loc).last_line, (Loc).last_column)
Reid Spencer38c91a92007-02-28 02:24:54 +00002508# else
2509# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2510# endif
2511#endif
2512
2513
2514/* YYLEX -- calling `yylex' with the right arguments. */
2515
Reid Spencer41dff5e2007-01-26 08:05:27 +00002516#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002517# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002518#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002519# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002520#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002521
2522/* Enable debugging if requested. */
2523#if YYDEBUG
2524
2525# ifndef YYFPRINTF
2526# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2527# define YYFPRINTF fprintf
2528# endif
2529
2530# define YYDPRINTF(Args) \
2531do { \
2532 if (yydebug) \
2533 YYFPRINTF Args; \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002534} while (YYID (0))
Reid Spencer38c91a92007-02-28 02:24:54 +00002535
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002536# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2537do { \
2538 if (yydebug) \
2539 { \
2540 YYFPRINTF (stderr, "%s ", Title); \
2541 yy_symbol_print (stderr, \
2542 Type, Value); \
2543 YYFPRINTF (stderr, "\n"); \
2544 } \
2545} while (YYID (0))
2546
2547
2548/*--------------------------------.
2549| Print this symbol on YYOUTPUT. |
2550`--------------------------------*/
2551
2552/*ARGSUSED*/
2553#if (defined __STDC__ || defined __C99__FUNC__ \
2554 || defined __cplusplus || defined _MSC_VER)
2555static void
2556yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2557#else
2558static void
2559yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2560 FILE *yyoutput;
2561 int yytype;
2562 YYSTYPE const * const yyvaluep;
2563#endif
2564{
2565 if (!yyvaluep)
2566 return;
2567# ifdef YYPRINT
2568 if (yytype < YYNTOKENS)
2569 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2570# else
2571 YYUSE (yyoutput);
2572# endif
2573 switch (yytype)
2574 {
2575 default:
2576 break;
2577 }
2578}
2579
2580
2581/*--------------------------------.
2582| Print this symbol on YYOUTPUT. |
2583`--------------------------------*/
2584
2585#if (defined __STDC__ || defined __C99__FUNC__ \
2586 || defined __cplusplus || defined _MSC_VER)
2587static void
2588yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2589#else
2590static void
2591yy_symbol_print (yyoutput, yytype, yyvaluep)
2592 FILE *yyoutput;
2593 int yytype;
2594 YYSTYPE const * const yyvaluep;
2595#endif
2596{
2597 if (yytype < YYNTOKENS)
2598 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2599 else
2600 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2601
2602 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2603 YYFPRINTF (yyoutput, ")");
2604}
Reid Spencer38c91a92007-02-28 02:24:54 +00002605
2606/*------------------------------------------------------------------.
2607| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2608| TOP (included). |
2609`------------------------------------------------------------------*/
2610
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002611#if (defined __STDC__ || defined __C99__FUNC__ \
2612 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002613static void
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002614yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
Chris Lattner32980692007-02-19 07:44:24 +00002615#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002616static void
2617yy_stack_print (bottom, top)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002618 yytype_int16 *bottom;
2619 yytype_int16 *top;
Chris Lattner32980692007-02-19 07:44:24 +00002620#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002621{
2622 YYFPRINTF (stderr, "Stack now");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002623 for (; bottom <= top; ++bottom)
Reid Spencer38c91a92007-02-28 02:24:54 +00002624 YYFPRINTF (stderr, " %d", *bottom);
2625 YYFPRINTF (stderr, "\n");
2626}
2627
2628# define YY_STACK_PRINT(Bottom, Top) \
2629do { \
2630 if (yydebug) \
2631 yy_stack_print ((Bottom), (Top)); \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002632} while (YYID (0))
Reid Spencer38c91a92007-02-28 02:24:54 +00002633
2634
2635/*------------------------------------------------.
2636| Report that the YYRULE is going to be reduced. |
2637`------------------------------------------------*/
2638
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002639#if (defined __STDC__ || defined __C99__FUNC__ \
2640 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002641static void
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002642yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
Reid Spencer38c91a92007-02-28 02:24:54 +00002643#else
2644static void
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002645yy_reduce_print (yyvsp, yyrule)
2646 YYSTYPE *yyvsp;
Reid Spencer38c91a92007-02-28 02:24:54 +00002647 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002648#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002649{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002650 int yynrhs = yyr2[yyrule];
Reid Spencer38c91a92007-02-28 02:24:54 +00002651 int yyi;
2652 unsigned long int yylno = yyrline[yyrule];
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002653 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2654 yyrule - 1, yylno);
2655 /* The symbols being reduced. */
2656 for (yyi = 0; yyi < yynrhs; yyi++)
2657 {
2658 fprintf (stderr, " $%d = ", yyi + 1);
2659 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2660 &(yyvsp[(yyi + 1) - (yynrhs)])
2661 );
2662 fprintf (stderr, "\n");
2663 }
Reid Spencer38c91a92007-02-28 02:24:54 +00002664}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002665
Reid Spencer38c91a92007-02-28 02:24:54 +00002666# define YY_REDUCE_PRINT(Rule) \
2667do { \
2668 if (yydebug) \
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002669 yy_reduce_print (yyvsp, Rule); \
2670} while (YYID (0))
Reid Spencer9d6565a2007-02-15 02:26:10 +00002671
Reid Spencer38c91a92007-02-28 02:24:54 +00002672/* Nonzero means print parse trace. It is left uninitialized so that
2673 multiple parsers can coexist. */
2674int yydebug;
2675#else /* !YYDEBUG */
2676# define YYDPRINTF(Args)
2677# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2678# define YY_STACK_PRINT(Bottom, Top)
2679# define YY_REDUCE_PRINT(Rule)
2680#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002681
Reid Spencer9d6565a2007-02-15 02:26:10 +00002682
Reid Spencer38c91a92007-02-28 02:24:54 +00002683/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002684#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002685# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002686#endif
2687
Reid Spencer38c91a92007-02-28 02:24:54 +00002688/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2689 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002690
Reid Spencer38c91a92007-02-28 02:24:54 +00002691 Do not make this value too large; the results are undefined if
2692 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2693 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002694
2695#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002696# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002697#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002698
Reid Spencer68a24bd2005-08-27 18:50:39 +00002699
2700
Reid Spencer38c91a92007-02-28 02:24:54 +00002701#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002702
Reid Spencer38c91a92007-02-28 02:24:54 +00002703# ifndef yystrlen
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002704# if defined __GLIBC__ && defined _STRING_H
Reid Spencer38c91a92007-02-28 02:24:54 +00002705# define yystrlen strlen
2706# else
2707/* Return the length of YYSTR. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002708#if (defined __STDC__ || defined __C99__FUNC__ \
2709 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002710static YYSIZE_T
Reid Spencer38c91a92007-02-28 02:24:54 +00002711yystrlen (const char *yystr)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002712#else
2713static YYSIZE_T
Reid Spencer38c91a92007-02-28 02:24:54 +00002714yystrlen (yystr)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002715 const char *yystr;
2716#endif
Chris Lattner32980692007-02-19 07:44:24 +00002717{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002718 YYSIZE_T yylen;
2719 for (yylen = 0; yystr[yylen]; yylen++)
Reid Spencer38c91a92007-02-28 02:24:54 +00002720 continue;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002721 return yylen;
Chris Lattner32980692007-02-19 07:44:24 +00002722}
Reid Spencer38c91a92007-02-28 02:24:54 +00002723# endif
2724# endif
Chris Lattner32980692007-02-19 07:44:24 +00002725
Reid Spencer38c91a92007-02-28 02:24:54 +00002726# ifndef yystpcpy
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002727# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
Reid Spencer38c91a92007-02-28 02:24:54 +00002728# define yystpcpy stpcpy
2729# else
2730/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2731 YYDEST. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002732#if (defined __STDC__ || defined __C99__FUNC__ \
2733 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002734static char *
Reid Spencer38c91a92007-02-28 02:24:54 +00002735yystpcpy (char *yydest, const char *yysrc)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002736#else
2737static char *
Reid Spencer38c91a92007-02-28 02:24:54 +00002738yystpcpy (yydest, yysrc)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002739 char *yydest;
2740 const char *yysrc;
2741#endif
Chris Lattner32980692007-02-19 07:44:24 +00002742{
Reid Spencer38c91a92007-02-28 02:24:54 +00002743 char *yyd = yydest;
2744 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002745
Reid Spencer38c91a92007-02-28 02:24:54 +00002746 while ((*yyd++ = *yys++) != '\0')
2747 continue;
2748
2749 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002750}
Reid Spencer38c91a92007-02-28 02:24:54 +00002751# endif
2752# endif
Chris Lattner32980692007-02-19 07:44:24 +00002753
Reid Spencer38c91a92007-02-28 02:24:54 +00002754# ifndef yytnamerr
2755/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2756 quotes and backslashes, so that it's suitable for yyerror. The
2757 heuristic is that double-quoting is unnecessary unless the string
2758 contains an apostrophe, a comma, or backslash (other than
2759 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2760 null, do not copy; instead, return the length of what the result
2761 would have been. */
2762static YYSIZE_T
2763yytnamerr (char *yyres, const char *yystr)
2764{
2765 if (*yystr == '"')
2766 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002767 YYSIZE_T yyn = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00002768 char const *yyp = yystr;
2769
2770 for (;;)
2771 switch (*++yyp)
2772 {
2773 case '\'':
2774 case ',':
2775 goto do_not_strip_quotes;
2776
2777 case '\\':
2778 if (*++yyp != '\\')
2779 goto do_not_strip_quotes;
2780 /* Fall through. */
2781 default:
2782 if (yyres)
2783 yyres[yyn] = *yyp;
2784 yyn++;
2785 break;
2786
2787 case '"':
2788 if (yyres)
2789 yyres[yyn] = '\0';
2790 return yyn;
2791 }
2792 do_not_strip_quotes: ;
2793 }
2794
2795 if (! yyres)
2796 return yystrlen (yystr);
2797
2798 return yystpcpy (yyres, yystr) - yyres;
2799}
2800# endif
2801
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002802/* Copy into YYRESULT an error message about the unexpected token
2803 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2804 including the terminating null byte. If YYRESULT is null, do not
2805 copy anything; just return the number of bytes that would be
2806 copied. As a special case, return 0 if an ordinary "syntax error"
2807 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2808 size calculation. */
2809static YYSIZE_T
2810yysyntax_error (char *yyresult, int yystate, int yychar)
2811{
2812 int yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002813
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002814 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2815 return 0;
2816 else
2817 {
2818 int yytype = YYTRANSLATE (yychar);
2819 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2820 YYSIZE_T yysize = yysize0;
2821 YYSIZE_T yysize1;
2822 int yysize_overflow = 0;
2823 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2824 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2825 int yyx;
2826
2827# if 0
2828 /* This is so xgettext sees the translatable formats that are
2829 constructed on the fly. */
2830 YY_("syntax error, unexpected %s");
2831 YY_("syntax error, unexpected %s, expecting %s");
2832 YY_("syntax error, unexpected %s, expecting %s or %s");
2833 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2834 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2835# endif
2836 char *yyfmt;
2837 char const *yyf;
2838 static char const yyunexpected[] = "syntax error, unexpected %s";
2839 static char const yyexpecting[] = ", expecting %s";
2840 static char const yyor[] = " or %s";
2841 char yyformat[sizeof yyunexpected
2842 + sizeof yyexpecting - 1
2843 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2844 * (sizeof yyor - 1))];
2845 char const *yyprefix = yyexpecting;
2846
2847 /* Start YYX at -YYN if negative to avoid negative indexes in
2848 YYCHECK. */
2849 int yyxbegin = yyn < 0 ? -yyn : 0;
2850
2851 /* Stay within bounds of both yycheck and yytname. */
2852 int yychecklim = YYLAST - yyn + 1;
2853 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2854 int yycount = 1;
2855
2856 yyarg[0] = yytname[yytype];
2857 yyfmt = yystpcpy (yyformat, yyunexpected);
2858
2859 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2860 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2861 {
2862 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2863 {
2864 yycount = 1;
2865 yysize = yysize0;
2866 yyformat[sizeof yyunexpected - 1] = '\0';
2867 break;
2868 }
2869 yyarg[yycount++] = yytname[yyx];
2870 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2871 yysize_overflow |= (yysize1 < yysize);
2872 yysize = yysize1;
2873 yyfmt = yystpcpy (yyfmt, yyprefix);
2874 yyprefix = yyor;
2875 }
2876
2877 yyf = YY_(yyformat);
2878 yysize1 = yysize + yystrlen (yyf);
2879 yysize_overflow |= (yysize1 < yysize);
2880 yysize = yysize1;
2881
2882 if (yysize_overflow)
2883 return YYSIZE_MAXIMUM;
2884
2885 if (yyresult)
2886 {
2887 /* Avoid sprintf, as that infringes on the user's name space.
2888 Don't have undefined behavior even if the translation
2889 produced a string with the wrong number of "%s"s. */
2890 char *yyp = yyresult;
2891 int yyi = 0;
2892 while ((*yyp = *yyf) != '\0')
2893 {
2894 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2895 {
2896 yyp += yytnamerr (yyp, yyarg[yyi++]);
2897 yyf += 2;
2898 }
2899 else
2900 {
2901 yyp++;
2902 yyf++;
2903 }
2904 }
2905 }
2906 return yysize;
2907 }
2908}
2909#endif /* YYERROR_VERBOSE */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002910
2911
Reid Spencer38c91a92007-02-28 02:24:54 +00002912/*-----------------------------------------------.
2913| Release the memory associated to this symbol. |
2914`-----------------------------------------------*/
2915
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002916/*ARGSUSED*/
2917#if (defined __STDC__ || defined __C99__FUNC__ \
2918 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002919static void
2920yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2921#else
2922static void
2923yydestruct (yymsg, yytype, yyvaluep)
2924 const char *yymsg;
2925 int yytype;
2926 YYSTYPE *yyvaluep;
2927#endif
2928{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002929 YYUSE (yyvaluep);
Reid Spencer38c91a92007-02-28 02:24:54 +00002930
2931 if (!yymsg)
2932 yymsg = "Deleting";
2933 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2934
2935 switch (yytype)
2936 {
2937
2938 default:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002939 break;
Reid Spencer38c91a92007-02-28 02:24:54 +00002940 }
2941}
2942
2943
2944/* Prevent warnings from -Wmissing-prototypes. */
2945
2946#ifdef YYPARSE_PARAM
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002947#if defined __STDC__ || defined __cplusplus
Reid Spencer38c91a92007-02-28 02:24:54 +00002948int yyparse (void *YYPARSE_PARAM);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002949#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002950int yyparse ();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002951#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002952#else /* ! YYPARSE_PARAM */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002953#if defined __STDC__ || defined __cplusplus
Reid Spencere812fb22006-01-19 01:21:04 +00002954int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002955#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002956int yyparse ();
2957#endif
2958#endif /* ! YYPARSE_PARAM */
2959
2960
2961
2962/* The look-ahead symbol. */
2963int yychar;
2964
2965/* The semantic value of the look-ahead symbol. */
2966YYSTYPE yylval;
2967
2968/* Number of syntax errors so far. */
2969int yynerrs;
2970
2971
2972
2973/*----------.
2974| yyparse. |
2975`----------*/
2976
2977#ifdef YYPARSE_PARAM
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002978#if (defined __STDC__ || defined __C99__FUNC__ \
2979 || defined __cplusplus || defined _MSC_VER)
2980int
2981yyparse (void *YYPARSE_PARAM)
2982#else
2983int
2984yyparse (YYPARSE_PARAM)
2985 void *YYPARSE_PARAM;
2986#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002987#else /* ! YYPARSE_PARAM */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00002988#if (defined __STDC__ || defined __C99__FUNC__ \
2989 || defined __cplusplus || defined _MSC_VER)
Reid Spencer38c91a92007-02-28 02:24:54 +00002990int
2991yyparse (void)
2992#else
2993int
2994yyparse ()
2995
2996#endif
2997#endif
2998{
2999
3000 int yystate;
3001 int yyn;
3002 int yyresult;
3003 /* Number of tokens to shift before error messages enabled. */
3004 int yyerrstatus;
3005 /* Look-ahead token as an internal (translated) token number. */
3006 int yytoken = 0;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003007#if YYERROR_VERBOSE
3008 /* Buffer for error messages, and its allocated size. */
3009 char yymsgbuf[128];
3010 char *yymsg = yymsgbuf;
3011 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3012#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00003013
3014 /* Three stacks and their tools:
3015 `yyss': related to states,
3016 `yyvs': related to semantic values,
3017 `yyls': related to locations.
3018
3019 Refer to the stacks thru separate pointers, to allow yyoverflow
3020 to reallocate them elsewhere. */
3021
3022 /* The state stack. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003023 yytype_int16 yyssa[YYINITDEPTH];
3024 yytype_int16 *yyss = yyssa;
3025 yytype_int16 *yyssp;
Reid Spencer38c91a92007-02-28 02:24:54 +00003026
3027 /* The semantic value stack. */
3028 YYSTYPE yyvsa[YYINITDEPTH];
3029 YYSTYPE *yyvs = yyvsa;
3030 YYSTYPE *yyvsp;
3031
3032
3033
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003034#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003035
Reid Spencer38c91a92007-02-28 02:24:54 +00003036 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00003037
Reid Spencer38c91a92007-02-28 02:24:54 +00003038 /* The variables used to return semantic value and location from the
3039 action routines. */
3040 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00003041
Chris Lattner7d9801d2007-02-13 00:58:01 +00003042
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003043 /* The number of symbols on the RHS of the reduced rule.
3044 Keep to zero when no symbol should be popped. */
3045 int yylen = 0;
Chris Lattner7d9801d2007-02-13 00:58:01 +00003046
Reid Spencer38c91a92007-02-28 02:24:54 +00003047 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00003048
Reid Spencer68a24bd2005-08-27 18:50:39 +00003049 yystate = 0;
3050 yyerrstatus = 0;
3051 yynerrs = 0;
3052 yychar = YYEMPTY; /* Cause a token to be read. */
3053
3054 /* Initialize stack pointers.
3055 Waste one element of value and location stack
3056 so that they stay on the same level as the state stack.
3057 The wasted elements are never initialized. */
3058
Reid Spencer38c91a92007-02-28 02:24:54 +00003059 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003060 yyvsp = yyvs;
3061
Reid Spencer38c91a92007-02-28 02:24:54 +00003062 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003063
Reid Spencer38c91a92007-02-28 02:24:54 +00003064/*------------------------------------------------------------.
3065| yynewstate -- Push a new state, which is found in yystate. |
3066`------------------------------------------------------------*/
3067 yynewstate:
3068 /* In all cases, when you get here, the value and location stacks
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003069 have just been pushed. So pushing a state here evens the stacks. */
Reid Spencer38c91a92007-02-28 02:24:54 +00003070 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003071
Reid Spencer38c91a92007-02-28 02:24:54 +00003072 yysetstate:
3073 *yyssp = yystate;
3074
3075 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003076 {
3077 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00003078 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003079
3080#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00003081 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003082 /* Give user a chance to reallocate the stack. Use copies of
Reid Spencer38c91a92007-02-28 02:24:54 +00003083 these so that the &'s don't force the real ones into
3084 memory. */
3085 YYSTYPE *yyvs1 = yyvs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003086 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003087
Reid Spencer38c91a92007-02-28 02:24:54 +00003088
3089 /* Each stack pointer address is followed by the size of the
3090 data in use in that stack, in bytes. This used to be a
3091 conditional around just the two extra args, but that might
3092 be undefined if yyoverflow is a macro. */
3093 yyoverflow (YY_("memory exhausted"),
3094 &yyss1, yysize * sizeof (*yyssp),
3095 &yyvs1, yysize * sizeof (*yyvsp),
3096
3097 &yystacksize);
3098
3099 yyss = yyss1;
3100 yyvs = yyvs1;
3101 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003102#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00003103# ifndef YYSTACK_RELOCATE
3104 goto yyexhaustedlab;
3105# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00003107 if (YYMAXDEPTH <= yystacksize)
3108 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003109 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00003110 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00003112
3113 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003114 yytype_int16 *yyss1 = yyss;
Reid Spencer38c91a92007-02-28 02:24:54 +00003115 union yyalloc *yyptr =
3116 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3117 if (! yyptr)
3118 goto yyexhaustedlab;
3119 YYSTACK_RELOCATE (yyss);
3120 YYSTACK_RELOCATE (yyvs);
3121
3122# undef YYSTACK_RELOCATE
3123 if (yyss1 != yyssa)
3124 YYSTACK_FREE (yyss1);
3125 }
3126# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003127#endif /* no yyoverflow */
3128
Reid Spencer38c91a92007-02-28 02:24:54 +00003129 yyssp = yyss + yysize - 1;
3130 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003131
3132
Reid Spencer38c91a92007-02-28 02:24:54 +00003133 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3134 (unsigned long int) yystacksize));
3135
3136 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003137 YYABORT;
3138 }
3139
Reid Spencer38c91a92007-02-28 02:24:54 +00003140 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003141
3142 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00003143
3144/*-----------.
3145| yybackup. |
3146`-----------*/
3147yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003148
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003149 /* Do appropriate processing given the current state. Read a
3150 look-ahead token if we need one and don't already have one. */
Andrew Lenharth6353e052006-12-08 18:07:09 +00003151
Reid Spencer38c91a92007-02-28 02:24:54 +00003152 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003153 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00003154 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003155 goto yydefault;
3156
Reid Spencer38c91a92007-02-28 02:24:54 +00003157 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003158
Reid Spencer38c91a92007-02-28 02:24:54 +00003159 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003160 if (yychar == YYEMPTY)
3161 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003162 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003163 yychar = YYLEX;
3164 }
3165
Reid Spencer38c91a92007-02-28 02:24:54 +00003166 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003167 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003168 yychar = yytoken = YYEOF;
3169 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003170 }
3171 else
3172 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003173 yytoken = YYTRANSLATE (yychar);
3174 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003175 }
3176
Reid Spencer38c91a92007-02-28 02:24:54 +00003177 /* If the proper action on seeing token YYTOKEN is to reduce or to
3178 detect an error, take that action. */
3179 yyn += yytoken;
3180 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003181 goto yydefault;
3182 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00003183 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003184 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003185 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003186 goto yyerrlab;
3187 yyn = -yyn;
3188 goto yyreduce;
3189 }
3190
3191 if (yyn == YYFINAL)
3192 YYACCEPT;
3193
Reid Spencer38c91a92007-02-28 02:24:54 +00003194 /* Count tokens shifted since error; after three, turn off error
3195 status. */
3196 if (yyerrstatus)
3197 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00003198
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003199 /* Shift the look-ahead token. */
3200 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3201
3202 /* Discard the shifted token unless it is eof. */
3203 if (yychar != YYEOF)
3204 yychar = YYEMPTY;
3205
Chris Lattner9d2fda62007-02-13 05:53:56 +00003206 yystate = yyn;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003207 *++yyvsp = yylval;
3208
Reid Spencer68a24bd2005-08-27 18:50:39 +00003209 goto yynewstate;
3210
Chris Lattner32980692007-02-19 07:44:24 +00003211
Reid Spencer38c91a92007-02-28 02:24:54 +00003212/*-----------------------------------------------------------.
3213| yydefault -- do the default action for the current state. |
3214`-----------------------------------------------------------*/
3215yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003216 yyn = yydefact[yystate];
3217 if (yyn == 0)
3218 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00003219 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003220
Reid Spencer38c91a92007-02-28 02:24:54 +00003221
3222/*-----------------------------.
3223| yyreduce -- Do a reduction. |
3224`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003225yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003226 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003227 yylen = yyr2[yyn];
3228
Reid Spencer38c91a92007-02-28 02:24:54 +00003229 /* If YYLEN is nonzero, implement the default value of the action:
3230 `$$ = $1'.
3231
3232 Otherwise, the following line sets YYVAL to garbage.
3233 This behavior is undocumented and Bison
3234 users should not rely upon it. Assigning to YYVAL
3235 unconditionally makes the parser a bit smaller, and it avoids a
3236 GCC warning that YYVAL may be used uninitialized. */
3237 yyval = yyvsp[1-yylen];
3238
3239
3240 YY_REDUCE_PRINT (yyn);
3241 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003242 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003243 case 29:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003244#line 1099 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003245 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3246 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003247
Reid Spencer38c91a92007-02-28 02:24:54 +00003248 case 30:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003249#line 1099 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003250 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3251 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003252
Reid Spencer38c91a92007-02-28 02:24:54 +00003253 case 31:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003254#line 1100 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003255 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3256 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003257
Reid Spencer38c91a92007-02-28 02:24:54 +00003258 case 32:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003259#line 1100 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003260 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3261 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003262
Reid Spencer38c91a92007-02-28 02:24:54 +00003263 case 33:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003264#line 1101 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003265 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3266 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003267
Reid Spencer38c91a92007-02-28 02:24:54 +00003268 case 34:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003269#line 1101 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003270 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3271 break;
3272
3273 case 35:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003274#line 1102 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003275 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3276 break;
3277
3278 case 36:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003279#line 1102 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003280 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3281 break;
3282
3283 case 37:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003284#line 1103 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003285 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3286 break;
3287
3288 case 38:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003289#line 1103 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003290 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3291 break;
3292
3293 case 39:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003294#line 1107 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003295 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3296 break;
3297
3298 case 40:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003299#line 1107 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003300 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3301 break;
3302
3303 case 41:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003304#line 1108 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003305 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3306 break;
3307
3308 case 42:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003309#line 1108 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003310 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3311 break;
3312
3313 case 43:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003314#line 1109 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003315 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3316 break;
3317
3318 case 44:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003319#line 1109 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003320 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3321 break;
3322
3323 case 45:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003324#line 1110 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003325 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3326 break;
3327
3328 case 46:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003329#line 1110 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003330 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3331 break;
3332
3333 case 47:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003334#line 1111 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003335 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3336 break;
3337
3338 case 48:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003339#line 1111 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003340 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3341 break;
3342
3343 case 49:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003344#line 1112 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003345 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3346 break;
3347
3348 case 50:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003349#line 1112 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003350 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3351 break;
3352
3353 case 51:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003354#line 1113 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003355 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3356 break;
3357
3358 case 52:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003359#line 1113 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003360 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3361 break;
3362
3363 case 53:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003364#line 1114 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003365 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3366 break;
3367
3368 case 54:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003369#line 1115 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003370 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3371 break;
3372
3373 case 61:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003374#line 1124 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003375 { (yyval.StrVal) = 0; ;}
3376 break;
3377
3378 case 62:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003379#line 1128 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003380 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003381 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003382 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003383 ;}
3384 break;
3385
3386 case 63:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003387#line 1132 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003388 {
3389 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003390 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003391 ;}
3392 break;
3393
3394 case 66:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003395#line 1139 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003396 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003397 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003398 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003399 ;}
3400 break;
3401
3402 case 67:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003403#line 1143 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003404 {
3405 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003406 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003407 ;}
3408 break;
3409
3410 case 68:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003411#line 1149 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003412 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3413 break;
3414
3415 case 69:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003416#line 1150 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003417 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3418 break;
3419
3420 case 70:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003421#line 1151 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003422 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3423 break;
3424
3425 case 71:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003426#line 1152 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003427 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3428 break;
3429
3430 case 72:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003431#line 1153 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003432 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3433 break;
3434
3435 case 73:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003436#line 1157 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003437 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3438 break;
3439
3440 case 74:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003441#line 1158 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003442 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3443 break;
3444
3445 case 75:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003446#line 1159 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003447 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3448 break;
3449
3450 case 76:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003451#line 1163 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003452 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3453 break;
3454
3455 case 77:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003456#line 1164 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003457 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3458 break;
3459
3460 case 78:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003461#line 1168 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003462 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3463 break;
3464
3465 case 79:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003466#line 1169 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003467 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3468 break;
3469
3470 case 80:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003471#line 1170 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003472 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3473 break;
3474
3475 case 81:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003476#line 1174 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003477 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3478 break;
3479
3480 case 82:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003481#line 1175 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003482 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3483 break;
3484
3485 case 83:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003486#line 1176 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003487 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3488 break;
3489
3490 case 84:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003491#line 1177 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003492 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3493 break;
3494
3495 case 85:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003496#line 1178 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003497 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3498 break;
3499
3500 case 86:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003501#line 1181 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003502 { (yyval.UIntVal) = CallingConv::C; ;}
3503 break;
3504
3505 case 87:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003506#line 1182 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003507 { (yyval.UIntVal) = CallingConv::C; ;}
3508 break;
3509
3510 case 88:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003511#line 1183 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003512 { (yyval.UIntVal) = CallingConv::Fast; ;}
3513 break;
3514
3515 case 89:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003516#line 1184 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003517 { (yyval.UIntVal) = CallingConv::Cold; ;}
3518 break;
3519
3520 case 90:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003521#line 1185 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003522 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3523 break;
3524
3525 case 91:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003526#line 1186 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003527 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3528 break;
3529
3530 case 92:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003531#line 1187 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003532 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003533 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003534 GEN_ERROR("Calling conv too large");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003535 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003536 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003537 ;}
3538 break;
3539
3540 case 93:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003541#line 1194 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003542 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003543 break;
3544
3545 case 94:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003546#line 1195 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003547 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003548 break;
3549
3550 case 95:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003551#line 1196 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003552 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003553 break;
3554
3555 case 96:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003556#line 1197 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003557 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003558 break;
3559
3560 case 97:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003561#line 1200 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003562 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003563 break;
3564
3565 case 98:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003566#line 1201 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003567 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003568 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003569 ;}
3570 break;
3571
3572 case 99:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003573#line 1206 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003574 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003575 break;
3576
Reid Spencer67d8ed92007-03-22 02:14:08 +00003577 case 100:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003578#line 1207 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003579 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003580 break;
3581
3582 case 102:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003583#line 1211 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer18da0722007-04-11 02:44:20 +00003584 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Reid Spencer67d8ed92007-03-22 02:14:08 +00003585 break;
3586
3587 case 103:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003588#line 1212 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003589 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003590 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003591 ;}
3592 break;
3593
Reid Spencer67d8ed92007-03-22 02:14:08 +00003594 case 104:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003595#line 1219 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003596 { (yyval.UIntVal) = 0; ;}
3597 break;
3598
Reid Spencer67d8ed92007-03-22 02:14:08 +00003599 case 105:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003600#line 1220 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003601 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003602 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer38c91a92007-02-28 02:24:54 +00003603 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003604 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003605 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003606;}
3607 break;
3608
Reid Spencer66728ef2007-03-20 01:13:36 +00003609 case 106:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003610#line 1226 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003611 { (yyval.UIntVal) = 0; ;}
3612 break;
3613
3614 case 107:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003615#line 1227 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer66728ef2007-03-20 01:13:36 +00003616 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003617 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
Reid Spencer66728ef2007-03-20 01:13:36 +00003618 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3619 GEN_ERROR("Alignment must be a power of two");
3620 CHECK_FOR_ERROR
3621;}
3622 break;
3623
Reid Spencer67d8ed92007-03-22 02:14:08 +00003624 case 108:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003625#line 1235 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003626 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003627 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
3628 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003629 GEN_ERROR("Invalid character in section name");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003630 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003631 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003632;}
3633 break;
3634
Reid Spencer67d8ed92007-03-22 02:14:08 +00003635 case 109:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003636#line 1243 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003637 { (yyval.StrVal) = 0; ;}
3638 break;
3639
Reid Spencer38c91a92007-02-28 02:24:54 +00003640 case 110:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003641#line 1244 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3642 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003643 break;
3644
3645 case 111:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003646#line 1249 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003647 {;}
3648 break;
3649
3650 case 112:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003651#line 1250 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003652 {;}
3653 break;
3654
3655 case 113:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003656#line 1251 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003657 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003658 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
3659 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003660 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003661 ;}
3662 break;
3663
Reid Spencer67d8ed92007-03-22 02:14:08 +00003664 case 114:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003665#line 1256 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003666 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003667 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003668 GEN_ERROR("Alignment must be a power of two");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003669 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003670 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003671 ;}
3672 break;
3673
Reid Spencer67d8ed92007-03-22 02:14:08 +00003674 case 119:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003675#line 1272 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003676 {
3677 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003678 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003679 ;}
3680 break;
3681
Reid Spencer67d8ed92007-03-22 02:14:08 +00003682 case 120:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003683#line 1276 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003684 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003685 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003686 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003687 ;}
3688 break;
3689
Reid Spencer67d8ed92007-03-22 02:14:08 +00003690 case 121:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003691#line 1280 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003692 { // Pointer type?
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003693 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003694 GEN_ERROR("Cannot form a pointer to a basic block");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003695 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3696 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003697 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003698 ;}
3699 break;
3700
Reid Spencer67d8ed92007-03-22 02:14:08 +00003701 case 122:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003702#line 1287 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003703 { // Named types are also simple types...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003704 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003706 (yyval.TypeVal) = new PATypeHolder(tmp);
3707 ;}
3708 break;
3709
Reid Spencer67d8ed92007-03-22 02:14:08 +00003710 case 123:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003711#line 1292 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003712 { // Type UpReference
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003713 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003714 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003715 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
Reid Spencer38c91a92007-02-28 02:24:54 +00003716 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003717 UR_OUT("New Upreference!\n");
3718 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003719 ;}
3720 break;
3721
Reid Spencer67d8ed92007-03-22 02:14:08 +00003722 case 124:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003723#line 1300 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003724 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003725 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003726 ParamAttrsList Attrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003727 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None)
3728 Attrs.addAttributes(0, (yyvsp[(5) - (5)].ParamAttrs));
Reid Spencer7b5d4662007-04-09 06:16:21 +00003729 unsigned index = 1;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003730 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003731 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003732 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003733 Params.push_back(Ty);
3734 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00003735 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003736 Attrs.addAttributes(index, I->Attrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003737 }
3738 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3739 if (isVarArg) Params.pop_back();
3740
Reid Spencer7b5d4662007-04-09 06:16:21 +00003741 ParamAttrsList *ActualAttrs = 0;
3742 if (!Attrs.empty())
3743 ActualAttrs = new ParamAttrsList(Attrs);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003744 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
3745 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3746 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
Reid Spencer38c91a92007-02-28 02:24:54 +00003747 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003748 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003749 ;}
3750 break;
3751
Reid Spencer67d8ed92007-03-22 02:14:08 +00003752 case 125:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003753#line 1326 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003754 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003755 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003756 ParamAttrsList Attrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003757 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None)
3758 Attrs.addAttributes(0, (yyvsp[(5) - (5)].ParamAttrs));
3759 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003760 unsigned index = 1;
3761 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003762 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003763 Params.push_back(Ty);
3764 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00003765 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003766 Attrs.addAttributes(index, I->Attrs);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003767 }
3768 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3769 if (isVarArg) Params.pop_back();
3770
Reid Spencer7b5d4662007-04-09 06:16:21 +00003771 ParamAttrsList *ActualAttrs = 0;
3772 if (!Attrs.empty())
3773 ActualAttrs = new ParamAttrsList(Attrs);
3774
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003775 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
3776 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
Reid Spencer38c91a92007-02-28 02:24:54 +00003777 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003778 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003779 ;}
3780 break;
3781
Reid Spencer67d8ed92007-03-22 02:14:08 +00003782 case 126:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003783#line 1353 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003784 { // Sized array type?
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003785 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3786 delete (yyvsp[(4) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003787 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003788 ;}
3789 break;
3790
Reid Spencer67d8ed92007-03-22 02:14:08 +00003791 case 127:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003792#line 1358 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003793 { // Vector type?
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003794 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
3795 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003796 GEN_ERROR("Unsigned result not equal to signed result");
3797 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003798 GEN_ERROR("Element type of a VectorType must be primitive");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003799 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003800 GEN_ERROR("Vector length should be a power of 2");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003801 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3802 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003803 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003804 ;}
3805 break;
3806
Reid Spencer67d8ed92007-03-22 02:14:08 +00003807 case 128:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003808#line 1370 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003809 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003810 std::vector<const Type*> Elements;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003811 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
3812 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003813 Elements.push_back(*I);
3814
Reid Spencer38c91a92007-02-28 02:24:54 +00003815 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003816 delete (yyvsp[(2) - (3)].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003817 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003818 ;}
3819 break;
3820
Reid Spencer67d8ed92007-03-22 02:14:08 +00003821 case 129:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003822#line 1380 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003823 { // Empty structure type?
3824 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003825 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003826 ;}
3827 break;
3828
Reid Spencer67d8ed92007-03-22 02:14:08 +00003829 case 130:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003830#line 1384 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003831 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003832 std::vector<const Type*> Elements;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003833 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
3834 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003835 Elements.push_back(*I);
3836
Reid Spencer38c91a92007-02-28 02:24:54 +00003837 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003838 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003839 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003840 ;}
3841 break;
3842
Reid Spencer67d8ed92007-03-22 02:14:08 +00003843 case 131:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003844#line 1394 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003845 { // Empty structure type?
3846 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003847 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003848 ;}
3849 break;
3850
Reid Spencer67d8ed92007-03-22 02:14:08 +00003851 case 132:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003852#line 1401 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003853 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003854 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
3855 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003856 ;}
3857 break;
3858
Reid Spencer67d8ed92007-03-22 02:14:08 +00003859 case 133:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003860#line 1408 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003861 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003862 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003863 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
3864 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003865 GEN_ERROR("LLVM functions cannot return aggregate types");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003866 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00003867 ;}
3868 break;
3869
Reid Spencer67d8ed92007-03-22 02:14:08 +00003870 case 134:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003871#line 1415 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003872 {
3873 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3874 ;}
3875 break;
3876
Reid Spencer67d8ed92007-03-22 02:14:08 +00003877 case 135:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003878#line 1420 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003879 {
3880 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003881 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003882 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003883 ;}
3884 break;
3885
Reid Spencer67d8ed92007-03-22 02:14:08 +00003886 case 136:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003887#line 1425 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003888 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003889 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003890 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003891 ;}
3892 break;
3893
Reid Spencer67d8ed92007-03-22 02:14:08 +00003894 case 138:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003895#line 1433 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003896 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003897 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003898 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003899 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003900 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003901 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003902 ;}
3903 break;
3904
Reid Spencer67d8ed92007-03-22 02:14:08 +00003905 case 139:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003906#line 1440 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003907 {
3908 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003909 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003910 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003911 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003912 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003913 ;}
3914 break;
3915
Reid Spencer67d8ed92007-03-22 02:14:08 +00003916 case 140:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003917#line 1447 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003918 {
3919 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003920 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003921 ;}
3922 break;
3923
Reid Spencer67d8ed92007-03-22 02:14:08 +00003924 case 141:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003925#line 1455 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003926 {
3927 (yyval.TypeList) = new std::list<PATypeHolder>();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003928 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
3929 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003930 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003931 ;}
3932 break;
3933
Reid Spencer67d8ed92007-03-22 02:14:08 +00003934 case 142:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003935#line 1461 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003936 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003937 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
3938 delete (yyvsp[(3) - (3)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003939 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003940 ;}
3941 break;
3942
Reid Spencer67d8ed92007-03-22 02:14:08 +00003943 case 143:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003944#line 1473 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003945 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003946 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003947 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
3948 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003949 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003950 GEN_ERROR("Cannot make array constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003951 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003952 const Type *ETy = ATy->getElementType();
3953 int NumElements = ATy->getNumElements();
3954
3955 // Verify that we have the correct size...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003956 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003957 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003958 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003959 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003960
3961 // Verify all elements are correct type!
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003962 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
3963 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003964 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3965 ETy->getDescription() +"' as required!\nIt is of type '"+
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003966 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003967 }
3968
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003969 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
3970 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003971 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003972 ;}
3973 break;
3974
Reid Spencer67d8ed92007-03-22 02:14:08 +00003975 case 144:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003976#line 1501 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003977 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003978 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003979 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
3980 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003981 if (ATy == 0)
3982 GEN_ERROR("Cannot make array constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003983 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003984
Andrew Lenharth6353e052006-12-08 18:07:09 +00003985 int NumElements = ATy->getNumElements();
3986 if (NumElements != -1 && NumElements != 0)
3987 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003988 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003989 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003990 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003991 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003992 ;}
3993 break;
3994
Reid Spencer67d8ed92007-03-22 02:14:08 +00003995 case 145:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003996#line 1517 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003997 {
Reid Spencer14310612006-12-31 05:40:51 +00003998 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003999 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4000 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004001 if (ATy == 0)
4002 GEN_ERROR("Cannot make array constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004003 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00004004
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004005 int NumElements = ATy->getNumElements();
4006 const Type *ETy = ATy->getElementType();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004007 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4008 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004009 GEN_ERROR("Can't build string constant of size " +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004010 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004011 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004012 std::vector<Constant*> Vals;
4013 if (ETy == Type::Int8Ty) {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004014 for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004015 C != (unsigned char*)EndStr; ++C)
4016 Vals.push_back(ConstantInt::get(ETy, *C));
4017 } else {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004018 free((yyvsp[(3) - (3)].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00004019 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004020 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004021 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004022 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004023 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004024 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004025 ;}
4026 break;
4027
Reid Spencer67d8ed92007-03-22 02:14:08 +00004028 case 146:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004029#line 1546 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004030 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004031 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004032 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4033 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004034 if (PTy == 0)
4035 GEN_ERROR("Cannot make packed constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004036 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004037 const Type *ETy = PTy->getElementType();
4038 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004039
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004040 // Verify that we have the correct size...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004041 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004042 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004043 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004044 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004045
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004046 // Verify all elements are correct type!
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004047 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4048 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004049 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4050 ETy->getDescription() +"' as required!\nIt is of type '"+
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004051 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004052 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004053
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004054 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4055 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004056 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004057 ;}
4058 break;
4059
Reid Spencer67d8ed92007-03-22 02:14:08 +00004060 case 147:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004061#line 1574 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004062 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004063 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004064 if (STy == 0)
4065 GEN_ERROR("Cannot make struct constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004066 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004067
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004068 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004069 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004070
4071 // Check to ensure that constants are compatible with the type initializer!
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004072 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4073 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004074 GEN_ERROR("Expected type '" +
4075 STy->getElementType(i)->getDescription() +
4076 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004077 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004078
4079 // Check to ensure that Type is not packed
4080 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004081 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004082
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004083 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4084 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004085 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004086 ;}
4087 break;
4088
Reid Spencer67d8ed92007-03-22 02:14:08 +00004089 case 148:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004090#line 1599 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004091 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004092 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004093 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4094 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004095 if (STy == 0)
4096 GEN_ERROR("Cannot make struct constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004097 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004098
4099 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004100 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004101
4102 // Check to ensure that Type is not packed
4103 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004104 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004105
Reid Spencer38c91a92007-02-28 02:24:54 +00004106 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004107 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004108 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004109 ;}
4110 break;
4111
Reid Spencer67d8ed92007-03-22 02:14:08 +00004112 case 149:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004113#line 1618 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004114 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004115 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004116 if (STy == 0)
4117 GEN_ERROR("Cannot make struct constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004118 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004119
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004120 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004121 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004122
4123 // Check to ensure that constants are compatible with the type initializer!
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004124 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4125 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004126 GEN_ERROR("Expected type '" +
4127 STy->getElementType(i)->getDescription() +
4128 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004129 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004130
4131 // Check to ensure that Type is packed
4132 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004133 GEN_ERROR("Vector initializer to non-vector type '" +
4134 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004135
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004136 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4137 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004138 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004139 ;}
4140 break;
4141
Reid Spencer67d8ed92007-03-22 02:14:08 +00004142 case 150:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004143#line 1644 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004144 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004145 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004146 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4147 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004148 if (STy == 0)
4149 GEN_ERROR("Cannot make struct constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004150 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004151
4152 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004153 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004154
4155 // Check to ensure that Type is packed
4156 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004157 GEN_ERROR("Vector initializer to non-vector type '" +
4158 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004159
Reid Spencer38c91a92007-02-28 02:24:54 +00004160 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004161 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004162 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004163 ;}
4164 break;
4165
Reid Spencer67d8ed92007-03-22 02:14:08 +00004166 case 151:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004167#line 1664 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004168 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004169 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004170 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4171 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004172 if (PTy == 0)
4173 GEN_ERROR("Cannot make null pointer constant with type: '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004174 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004175
Reid Spencer38c91a92007-02-28 02:24:54 +00004176 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004177 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004178 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004179 ;}
4180 break;
4181
Reid Spencer67d8ed92007-03-22 02:14:08 +00004182 case 152:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004183#line 1676 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004184 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004185 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004186 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4187 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4188 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004189 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004190 ;}
4191 break;
4192
Reid Spencer67d8ed92007-03-22 02:14:08 +00004193 case 153:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004194#line 1683 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004195 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004196 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004197 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4198 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004199 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004200 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004201
4202 // ConstExprs can exist in the body of a function, thus creating
4203 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004204 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004205 // symbol table instead of the module symbol table for the global symbol,
4206 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004207 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208 //
4209 Function *SavedCurFn = CurFun.CurrentFunction;
4210 CurFun.CurrentFunction = 0;
4211
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004212 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004213 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004214
4215 CurFun.CurrentFunction = SavedCurFn;
4216
4217 // If this is an initializer for a constant pointer, which is referencing a
4218 // (currently) undefined variable, create a stub now that shall be replaced
4219 // in the future with the right type of variable.
4220 //
4221 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004222 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004223 const PointerType *PT = cast<PointerType>(Ty);
4224
4225 // First check to see if the forward references value is already created!
4226 PerModuleInfo::GlobalRefsType::iterator I =
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004227 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004228
4229 if (I != CurModule.GlobalRefs.end()) {
4230 V = I->second; // Placeholder already exists, use it...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004231 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004232 } else {
4233 std::string Name;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004234 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4235 Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4236 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004237 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004238
4239 // Create the forward referenced global.
4240 GlobalValue *GV;
4241 if (const FunctionType *FTy =
4242 dyn_cast<FunctionType>(PT->getElementType())) {
4243 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4244 CurModule.CurrentModule);
4245 } else {
4246 GV = new GlobalVariable(PT->getElementType(), false,
4247 GlobalValue::ExternalLinkage, 0,
4248 Name, CurModule.CurrentModule);
4249 }
4250
4251 // Keep track of the fact that we have a forward ref to recycle it
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004252 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004253 V = GV;
4254 }
4255 }
4256
Reid Spencer38c91a92007-02-28 02:24:54 +00004257 (yyval.ConstVal) = cast<GlobalValue>(V);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004258 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004259 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004260 ;}
4261 break;
4262
Reid Spencer67d8ed92007-03-22 02:14:08 +00004263 case 154:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004264#line 1749 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004265 {
Reid Spencer14310612006-12-31 05:40:51 +00004266 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004267 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4268 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004269 GEN_ERROR("Mismatched types for constant expression: " +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004270 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4271 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4272 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004273 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004274 ;}
4275 break;
4276
Reid Spencer67d8ed92007-03-22 02:14:08 +00004277 case 155:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004278#line 1759 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004279 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004280 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004281 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4282 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004283 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004284 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004285 (yyval.ConstVal) = Constant::getNullValue(Ty);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004286 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004287 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004288 ;}
4289 break;
4290
Reid Spencer67d8ed92007-03-22 02:14:08 +00004291 case 156:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004292#line 1769 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004293 { // integral constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004294 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004295 GEN_ERROR("Constant value doesn't fit in type");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004296 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004297 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004298 ;}
4299 break;
4300
Reid Spencer67d8ed92007-03-22 02:14:08 +00004301 case 157:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004302#line 1775 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004303 { // arbitrary precision integer constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004304 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4305 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004306 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004307 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004308 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4309 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4310 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004311 CHECK_FOR_ERROR
4312 ;}
4313 break;
4314
Reid Spencer67d8ed92007-03-22 02:14:08 +00004315 case 158:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004316#line 1785 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004317 { // integral constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004318 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004319 GEN_ERROR("Constant value doesn't fit in type");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004320 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004321 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004322 ;}
4323 break;
4324
Reid Spencer67d8ed92007-03-22 02:14:08 +00004325 case 159:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004326#line 1791 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004327 { // arbitrary precision integer constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004328 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4329 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004330 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004331 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004332 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4333 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4334 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004335 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004336 ;}
4337 break;
4338
Reid Spencer67d8ed92007-03-22 02:14:08 +00004339 case 160:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004340#line 1801 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004341 { // Boolean constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004342 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
Reid Spencer38c91a92007-02-28 02:24:54 +00004343 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004344 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004345 ;}
4346 break;
4347
Reid Spencer67d8ed92007-03-22 02:14:08 +00004348 case 161:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004349#line 1806 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004350 { // Boolean constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004351 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
Reid Spencer38c91a92007-02-28 02:24:54 +00004352 (yyval.ConstVal) = ConstantInt::getFalse();
4353 CHECK_FOR_ERROR
4354 ;}
4355 break;
4356
Reid Spencer67d8ed92007-03-22 02:14:08 +00004357 case 162:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004358#line 1811 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004359 { // Float & Double constants
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004360 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004361 GEN_ERROR("Floating point constant invalid for type");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004362 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004363 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004364 ;}
4365 break;
4366
Reid Spencer67d8ed92007-03-22 02:14:08 +00004367 case 163:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004368#line 1819 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004369 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004370 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004371 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4372 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4373 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4374 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004375 GEN_ERROR("invalid cast opcode for cast from '" +
4376 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004377 DestTy->getDescription() + "'");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004378 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4379 delete (yyvsp[(5) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004380 ;}
4381 break;
4382
Reid Spencer67d8ed92007-03-22 02:14:08 +00004383 case 164:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004384#line 1831 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004385 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004386 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004387 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004388
4389 const Type *IdxTy =
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004390 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004391 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004392 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004393 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004394
Chris Lattnerf7469af2007-01-31 04:44:08 +00004395 SmallVector<Constant*, 8> IdxVec;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004396 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4397 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004398 IdxVec.push_back(C);
4399 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004400 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004401
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004402 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004403
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004404 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004405 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004406 ;}
4407 break;
4408
Reid Spencer67d8ed92007-03-22 02:14:08 +00004409 case 165:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004410#line 1853 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004411 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004412 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004413 GEN_ERROR("Select condition must be of boolean type");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004414 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004415 GEN_ERROR("Select operand types must match");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004416 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004417 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004418 ;}
4419 break;
4420
Reid Spencer67d8ed92007-03-22 02:14:08 +00004421 case 166:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004422#line 1861 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004423 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004424 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004425 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004426 CHECK_FOR_ERROR;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004427 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004428 ;}
4429 break;
4430
Reid Spencer67d8ed92007-03-22 02:14:08 +00004431 case 167:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004432#line 1867 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004433 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004434 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004435 GEN_ERROR("Logical operator types must match");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004436 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4437 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4438 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004439 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004440 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004441 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004442 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004443 ;}
4444 break;
4445
Reid Spencer67d8ed92007-03-22 02:14:08 +00004446 case 168:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004447#line 1878 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004448 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004449 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004450 GEN_ERROR("icmp operand types must match");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004451 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004452 ;}
4453 break;
4454
Reid Spencer67d8ed92007-03-22 02:14:08 +00004455 case 169:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004456#line 1883 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004457 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004458 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004459 GEN_ERROR("fcmp operand types must match");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004460 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004461 ;}
4462 break;
4463
Reid Spencer67d8ed92007-03-22 02:14:08 +00004464 case 170:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004465#line 1888 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004466 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004467 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004468 GEN_ERROR("Invalid extractelement operands");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004469 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004470 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004471 ;}
4472 break;
4473
Reid Spencer67d8ed92007-03-22 02:14:08 +00004474 case 171:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004475#line 1894 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004476 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004477 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004478 GEN_ERROR("Invalid insertelement operands");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004479 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004480 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004481 ;}
4482 break;
4483
Reid Spencer67d8ed92007-03-22 02:14:08 +00004484 case 172:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004485#line 1900 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004486 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004487 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004488 GEN_ERROR("Invalid shufflevector operands");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004489 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004490 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004491 ;}
4492 break;
4493
Reid Spencer67d8ed92007-03-22 02:14:08 +00004494 case 173:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004495#line 1909 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004496 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004497 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004498 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004499 ;}
4500 break;
4501
Reid Spencer67d8ed92007-03-22 02:14:08 +00004502 case 174:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004503#line 1913 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004504 {
4505 (yyval.ConstVector) = new std::vector<Constant*>();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004506 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004507 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004508 ;}
4509 break;
4510
Reid Spencer67d8ed92007-03-22 02:14:08 +00004511 case 175:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004512#line 1921 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004513 { (yyval.BoolVal) = false; ;}
4514 break;
4515
Reid Spencer67d8ed92007-03-22 02:14:08 +00004516 case 176:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004517#line 1921 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004518 { (yyval.BoolVal) = true; ;}
4519 break;
4520
Reid Spencer38c91a92007-02-28 02:24:54 +00004521 case 177:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004522#line 1924 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4523 { (yyval.BoolVal) = true; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004524 break;
4525
Reid Spencer67d8ed92007-03-22 02:14:08 +00004526 case 178:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004527#line 1924 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4528 { (yyval.BoolVal) = false; ;}
4529 break;
4530
4531 case 179:
4532#line 1935 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004533 {
4534 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4535 CurModule.ModuleDone();
4536 CHECK_FOR_ERROR;
4537 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004538 break;
4539
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004540 case 180:
4541#line 1940 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4542 {
4543 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4544 CurModule.ModuleDone();
4545 CHECK_FOR_ERROR;
4546 ;}
4547 break;
4548
4549 case 183:
4550#line 1953 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004551 { CurFun.isDeclare = false; ;}
4552 break;
4553
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004554 case 184:
4555#line 1953 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004556 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004557 CurFun.FunctionDone();
4558 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004559 ;}
4560 break;
4561
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004562 case 185:
4563#line 1957 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004564 { CurFun.isDeclare = true; ;}
4565 break;
4566
Reid Spencer67d8ed92007-03-22 02:14:08 +00004567 case 186:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004568#line 1957 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4569 {
4570 CHECK_FOR_ERROR
4571 ;}
4572 break;
4573
4574 case 187:
4575#line 1960 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4576 {
4577 CHECK_FOR_ERROR
4578 ;}
4579 break;
4580
4581 case 188:
4582#line 1963 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004583 {
Reid Spencer14310612006-12-31 05:40:51 +00004584 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004585 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004586 // Eagerly resolve types. This is not an optimization, this is a
4587 // requirement that is due to the fact that we could have this:
4588 //
4589 // %list = type { %list * }
4590 // %list = type { %list * } ; repeated type decl
4591 //
4592 // If types are not resolved eagerly, then the two types will not be
4593 // determined to be the same type!
4594 //
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004595 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004596
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004597 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004598 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004599 // If this is a named type that is not a redefinition, add it to the slot
4600 // table.
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004601 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004602 }
Reid Spencera132e042006-12-03 05:46:11 +00004603
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004604 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004605 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004606 ;}
4607 break;
4608
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004609 case 189:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004610#line 1987 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004611 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004612 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4613
4614 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
4615 CHECK_FOR_ERROR
4616 // If this is a named type that is not a redefinition, add it to the slot
4617 // table.
4618 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
4619 }
4620 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004621 ;}
4622 break;
4623
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004624 case 190:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004625#line 1998 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4626 {
4627 /* "Externally Visible" Linkage */
4628 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004629 GEN_ERROR("Global value initializer is not a constant");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004630 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4631 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004632 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004633 ;}
4634 break;
4635
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004636 case 191:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004637#line 2005 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004638 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004639 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004640 ;}
4641 break;
4642
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004643 case 192:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004644#line 2008 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004645 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004646 if ((yyvsp[(6) - (6)].ConstVal) == 0)
4647 GEN_ERROR("Global value initializer is not a constant");
4648 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004649 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004650 ;}
4651 break;
4652
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004653 case 193:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004654#line 2013 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4655 {
4656 CurGV = 0;
4657 ;}
4658 break;
4659
4660 case 194:
4661#line 2016 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4662 {
4663 if (!UpRefs.empty())
4664 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4665 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), *(yyvsp[(6) - (6)].TypeVal), 0, (yyvsp[(4) - (6)].BoolVal));
4666 CHECK_FOR_ERROR
4667 delete (yyvsp[(6) - (6)].TypeVal);
4668 ;}
4669 break;
4670
4671 case 195:
4672#line 2022 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004673 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004674 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004675 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004676 ;}
4677 break;
4678
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004679 case 196:
4680#line 2026 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004681 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004682 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004683 ;}
4684 break;
4685
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004686 case 197:
4687#line 2029 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004688 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004689 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004690 ;}
4691 break;
4692
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004693 case 198:
4694#line 2035 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004695 {
Chris Lattner66316012006-01-24 04:14:29 +00004696 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004697 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
4698 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
4699 free((yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004700
4701 if (AsmSoFar.empty())
4702 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4703 else
4704 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004706;}
4707 break;
4708
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004709 case 199:
4710#line 2048 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004711 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004712 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
4713 free((yyvsp[(3) - (3)].StrVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004714 ;}
4715 break;
4716
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004717 case 200:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004718#line 2052 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004719 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004720 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
4721 free((yyvsp[(3) - (3)].StrVal));
4722 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004723 break;
4724
4725 case 202:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004726#line 2059 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004727 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004728 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
4729 free((yyvsp[(3) - (3)].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004730 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004731 ;}
4732 break;
4733
4734 case 203:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004735#line 2064 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004736 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004737 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
4738 free((yyvsp[(1) - (1)].StrVal));
4739 CHECK_FOR_ERROR
4740 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004741 break;
4742
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004743 case 204:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004744#line 2069 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004745 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004746 CHECK_FOR_ERROR
4747 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004748 break;
4749
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004750 case 205:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004751#line 2078 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004752 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004753 if (!UpRefs.empty())
4754 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
4755 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
4756 GEN_ERROR("void typed arguments are invalid");
4757 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
4758 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
4759 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004760 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004761 ;}
4762 break;
4763
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004764 case 206:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004765#line 2088 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004766 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004767 if (!UpRefs.empty())
4768 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4769 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
4770 GEN_ERROR("void typed arguments are invalid");
4771 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
4772 (yyval.ArgList) = new ArgListType;
Reid Spencer38c91a92007-02-28 02:24:54 +00004773 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004774 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004775 ;}
4776 break;
4777
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004778 case 207:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004779#line 2099 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4780 {
4781 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
4782 CHECK_FOR_ERROR
4783 ;}
4784 break;
4785
4786 case 208:
4787#line 2103 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4788 {
4789 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
4790 struct ArgListEntry E;
4791 E.Ty = new PATypeHolder(Type::VoidTy);
4792 E.Name = 0;
4793 E.Attrs = ParamAttr::None;
4794 (yyval.ArgList)->push_back(E);
4795 CHECK_FOR_ERROR
4796 ;}
4797 break;
4798
4799 case 209:
4800#line 2112 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004801 {
4802 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004803 struct ArgListEntry E;
4804 E.Ty = new PATypeHolder(Type::VoidTy);
4805 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004806 E.Attrs = ParamAttr::None;
Reid Spencer38c91a92007-02-28 02:24:54 +00004807 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004808 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004809 ;}
4810 break;
4811
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004812 case 210:
4813#line 2121 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004814 {
4815 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004816 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004817 ;}
4818 break;
4819
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004820 case 211:
4821#line 2127 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004822 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004823 UnEscapeLexed((yyvsp[(3) - (9)].StrVal));
4824 std::string FunctionName((yyvsp[(3) - (9)].StrVal));
4825 free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004826
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004827 // Check the function result for abstractness if this is a define. We should
4828 // have no abstract types at this point
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004829 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
4830 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004831
Reid Spencer68a24bd2005-08-27 18:50:39 +00004832 std::vector<const Type*> ParamTypeList;
Reid Spencer7b5d4662007-04-09 06:16:21 +00004833 ParamAttrsList ParamAttrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004834 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None)
4835 ParamAttrs.addAttributes(0, (yyvsp[(7) - (9)].ParamAttrs));
4836 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004837 unsigned index = 1;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004838 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004839 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004840 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4841 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004842 ParamTypeList.push_back(Ty);
4843 if (Ty != Type::VoidTy)
Reid Spencer18da0722007-04-11 02:44:20 +00004844 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00004845 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer14310612006-12-31 05:40:51 +00004846 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004847 }
4848
4849 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4850 if (isVarArg) ParamTypeList.pop_back();
4851
Reid Spencer7b5d4662007-04-09 06:16:21 +00004852 ParamAttrsList *ActualAttrs = 0;
4853 if (!ParamAttrs.empty())
4854 ActualAttrs = new ParamAttrsList(ParamAttrs);
4855
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004856 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg,
Reid Spencer7b5d4662007-04-09 06:16:21 +00004857 ActualAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004858 const PointerType *PFT = PointerType::get(FT);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004859 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004860
4861 ValID ID;
4862 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004863 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004864 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004865 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004866 }
4867
4868 Function *Fn = 0;
4869 // See if this function was forward referenced. If so, recycle the object.
4870 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4871 // Move the function to the end of the list, from whereever it was
4872 // previously inserted.
4873 Fn = cast<Function>(FWRef);
4874 CurModule.CurrentModule->getFunctionList().remove(Fn);
4875 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4876 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004877 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4878 if (Fn->getFunctionType() != FT ) {
4879 // The existing function doesn't have the same type. This is an overload
4880 // error.
4881 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4882 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4883 // Neither the existing or the current function is a declaration and they
4884 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004885 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004886 } if (Fn->isDeclaration()) {
4887 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004888 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4889 AI != AE; ++AI)
4890 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004891 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004892 } else { // Not already defined?
4893 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4894 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004895
Reid Spencer68a24bd2005-08-27 18:50:39 +00004896 InsertValue(Fn, CurModule.Values);
4897 }
4898
4899 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004900
4901 if (CurFun.isDeclare) {
4902 // If we have declaration, always overwrite linkage. This will allow us to
4903 // correctly handle cases, when pointer to function is passed as argument to
4904 // another function.
4905 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004906 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004907 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004908 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
4909 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
4910 if ((yyvsp[(8) - (9)].StrVal)) {
4911 Fn->setSection((yyvsp[(8) - (9)].StrVal));
4912 free((yyvsp[(8) - (9)].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004913 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004914
4915 // Add all of the arguments we parsed to the function...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004916 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004917 if (isVarArg) { // Nuke the last entry
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004918 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004919 "Not a varargs marker!");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004920 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
4921 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004922 }
4923 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004924 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004925 unsigned Idx = 1;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004926 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
4927 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004928 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004929 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004930 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004931 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004932 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004933 }
Reid Spencera132e042006-12-03 05:46:11 +00004934
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004935 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004936 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004937 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004938;}
4939 break;
4940
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004941 case 214:
4942#line 2247 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004943 {
4944 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004945
4946 // Make sure that we keep track of the linkage type even if there was a
4947 // previous "declare".
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004948 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
4949 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
Reid Spencer38c91a92007-02-28 02:24:54 +00004950;}
4951 break;
4952
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004953 case 217:
4954#line 2258 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004955 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004956 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004957 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004958;}
4959 break;
4960
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004961 case 218:
4962#line 2263 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004963 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004964 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
4965 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
Reid Spencer38c91a92007-02-28 02:24:54 +00004966 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004967 CurFun.FunctionDone();
4968 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004969 ;}
4970 break;
4971
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004972 case 219:
4973#line 2275 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004974 {
4975 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004976 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004977 ;}
4978 break;
4979
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004980 case 220:
4981#line 2279 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004982 {
4983 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004984 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004985 ;}
4986 break;
4987
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004988 case 221:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004989#line 2284 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4990 { // A reference to a direct constant
4991 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004992 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004993 ;}
4994 break;
4995
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004996 case 222:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004997#line 2288 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4998 {
4999 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
5000 CHECK_FOR_ERROR
5001 ;}
5002 break;
5003
5004 case 223:
5005#line 2292 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5006 { // Perhaps it's an FP constant?
5007 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
5008 CHECK_FOR_ERROR
5009 ;}
5010 break;
5011
5012 case 224:
5013#line 2296 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005014 {
5015 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005016 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005017 ;}
5018 break;
5019
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005020 case 225:
5021#line 2300 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005022 {
5023 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005024 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005025 ;}
5026 break;
5027
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005028 case 226:
5029#line 2304 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005030 {
5031 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005032 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005033 ;}
5034 break;
5035
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005036 case 227:
5037#line 2308 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005038 {
5039 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005040 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005041 ;}
5042 break;
5043
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005044 case 228:
5045#line 2312 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005046 { // A vector zero constant.
5047 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00005048 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005049 ;}
5050 break;
5051
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005052 case 229:
5053#line 2316 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005054 { // Nonempty unsized packed vector
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005055 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5056 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005057
Reid Spencer9d6565a2007-02-15 02:26:10 +00005058 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005059 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005060 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005061 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005062 ETy,
5063 NumElements)
5064 )
5065 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005066
5067 // Verify all elements are correct type!
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005068 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5069 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005070 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005071 ETy->getDescription() +"' as required!\nIt is of type '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005072 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005073 }
5074
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005075 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5076 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005077 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005078 ;}
5079 break;
5080
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005081 case 230:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005082#line 2341 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5083 {
5084 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005085 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005086 ;}
5087 break;
5088
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005089 case 231:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005090#line 2345 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005091 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005092 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5093 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5094 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5095 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5096 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5097 free((yyvsp[(3) - (5)].StrVal));
5098 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005099 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005100 ;}
5101 break;
5102
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005103 case 232:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005104#line 2359 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5105 { // Is it an integer reference...?
5106 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005107 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005108 ;}
5109 break;
5110
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005111 case 233:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005112#line 2363 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5113 {
5114 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
5115 CHECK_FOR_ERROR
5116 ;}
5117 break;
5118
5119 case 234:
5120#line 2367 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005121 { // Is it a named reference...?
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005122 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005123 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005124 ;}
5125 break;
5126
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005127 case 235:
5128#line 2371 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5129 { // Is it a named reference...?
5130 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005131 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005132 ;}
5133 break;
5134
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005135 case 238:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005136#line 2383 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5137 {
5138 if (!UpRefs.empty())
5139 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5140 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5141 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005142 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005143 ;}
5144 break;
5145
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005146 case 239:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005147#line 2392 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005148 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005149 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005150 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005151 ;}
5152 break;
5153
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005154 case 240:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005155#line 2396 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5156 { // Do not allow functions with 0 basic blocks
5157 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005158 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005159 ;}
5160 break;
5161
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005162 case 241:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005163#line 2405 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5164 {
5165 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
5166 CHECK_FOR_ERROR
5167 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5168 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5169 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5170 CHECK_FOR_ERROR
5171 ;}
5172 break;
5173
5174 case 242:
5175#line 2414 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5176 {
5177 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
5178 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5179 if (CI2->getParent() == 0)
5180 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5181 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5182 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
5183 CHECK_FOR_ERROR
5184 ;}
5185 break;
5186
5187 case 243:
5188#line 2423 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005189 { // Empty space between instruction lists
5190 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005191 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005192 ;}
5193 break;
5194
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005195 case 244:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005196#line 2427 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5197 { // Labelled (named) basic block
5198 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[(1) - (1)].StrVal)));
5199 CHECK_FOR_ERROR
5200 ;}
5201 break;
5202
5203 case 245:
5204#line 2432 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5205 { // Return with a result...
5206 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5207 CHECK_FOR_ERROR
5208 ;}
5209 break;
5210
5211 case 246:
5212#line 2436 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005213 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00005214 (yyval.TermInstVal) = new ReturnInst();
5215 CHECK_FOR_ERROR
5216 ;}
5217 break;
5218
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005219 case 247:
5220#line 2440 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005221 { // Unconditional Branch...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005222 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005223 CHECK_FOR_ERROR
5224 (yyval.TermInstVal) = new BranchInst(tmpBB);
5225 ;}
5226 break;
5227
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005228 case 248:
5229#line 2445 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005230 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005231 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5232 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005233 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005234 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005235 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005236 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005237 CHECK_FOR_ERROR
5238 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5239 ;}
5240 break;
5241
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005242 case 249:
5243#line 2455 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005244 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005245 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005246 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005247 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005248 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005249 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005250 (yyval.TermInstVal) = S;
5251
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005252 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5253 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005254 for (; I != E; ++I) {
5255 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5256 S->addCase(CI, I->second);
5257 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005258 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005259 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005260 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005261 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005262 ;}
5263 break;
5264
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005265 case 250:
5266#line 2474 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005267 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005268 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005269 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005270 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005271 CHECK_FOR_ERROR
5272 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005273 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005274 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005275 ;}
5276 break;
5277
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005278 case 251:
5279#line 2484 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005280 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005281
Reid Spencer14310612006-12-31 05:40:51 +00005282 // Handle the short syntax
5283 const PointerType *PFTy = 0;
5284 const FunctionType *Ty = 0;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005285 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005286 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5287 // Pull out the types of all of the arguments...
5288 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005289 ParamAttrsList ParamAttrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005290 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
5291 ParamAttrs.addAttributes(0, (yyvsp[(8) - (14)].ParamAttrs));
5292 ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005293 unsigned index = 1;
5294 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005295 const Type *Ty = I->Val->getType();
5296 if (Ty == Type::VoidTy)
5297 GEN_ERROR("Short call syntax cannot be used with varargs");
5298 ParamTypes.push_back(Ty);
Reid Spencer18da0722007-04-11 02:44:20 +00005299 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00005300 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005301 }
5302
Reid Spencer7b5d4662007-04-09 06:16:21 +00005303 ParamAttrsList *Attrs = 0;
5304 if (!ParamAttrs.empty())
5305 Attrs = new ParamAttrsList(ParamAttrs);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005306 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005307 PFTy = PointerType::get(Ty);
5308 }
5309
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005310 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005311
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005312 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005313 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005314 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005315 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005316 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005317 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005318
Reid Spencer14310612006-12-31 05:40:51 +00005319 // Check the arguments
5320 ValueList Args;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005321 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005322 // Make sure no arguments is a good thing!
5323 if (Ty->getNumParams() != 0)
5324 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005325 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005326 } else { // Has arguments?
5327 // Loop through FunctionType's arguments and ensure they are specified
5328 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005329 FunctionType::param_iterator I = Ty->param_begin();
5330 FunctionType::param_iterator E = Ty->param_end();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005331 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005332
Reid Spencer14310612006-12-31 05:40:51 +00005333 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5334 if (ArgI->Val->getType() != *I)
5335 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005336 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005337 Args.push_back(ArgI->Val);
5338 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005339
Reid Spencer14310612006-12-31 05:40:51 +00005340 if (Ty->isVarArg()) {
5341 if (I == E)
5342 for (; ArgI != ArgE; ++ArgI)
5343 Args.push_back(ArgI->Val); // push the remaining varargs
5344 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005345 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005346 }
Reid Spencer14310612006-12-31 05:40:51 +00005347
5348 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005349 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005350 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005351 (yyval.TermInstVal) = II;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005352 delete (yyvsp[(6) - (14)].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005353 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005354 ;}
5355 break;
5356
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005357 case 252:
5358#line 2559 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005359 {
5360 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005361 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005362 ;}
5363 break;
5364
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005365 case 253:
5366#line 2563 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005367 {
5368 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005369 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005370 ;}
5371 break;
5372
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005373 case 254:
5374#line 2570 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005375 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005376 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5377 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005378 CHECK_FOR_ERROR
5379 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005380 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005381
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005382 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005383 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005384 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5385 ;}
5386 break;
5387
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005388 case 255:
5389#line 2581 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005390 {
5391 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005392 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005393 CHECK_FOR_ERROR
5394
5395 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005396 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005397
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005398 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005399 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005400 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5401 ;}
5402 break;
5403
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005404 case 256:
5405#line 2594 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005406 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005407 // Is this definition named?? if so, assign the name...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005408 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005409 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005410 InsertValue((yyvsp[(2) - (2)].InstVal));
5411 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005412 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005413 ;}
5414 break;
5415
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005416 case 257:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005417#line 2604 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5418 { // Used for PHI nodes
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005419 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005420 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5421 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5422 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
5423 CHECK_FOR_ERROR
5424 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5425 CHECK_FOR_ERROR
5426 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5427 delete (yyvsp[(1) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005428 ;}
5429 break;
5430
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005431 case 258:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005432#line 2615 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005433 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005434 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5435 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005436 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005437 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5438 CHECK_FOR_ERROR
5439 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer38c91a92007-02-28 02:24:54 +00005440 ;}
5441 break;
5442
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005443 case 259:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005444#line 2625 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5445 {
5446 if (!UpRefs.empty())
5447 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5448 // Used for call and invoke instructions
5449 (yyval.ValueRefList) = new ValueRefList();
5450 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5451 (yyval.ValueRefList)->push_back(E);
5452 delete (yyvsp[(1) - (3)].TypeVal);
5453 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00005454 break;
5455
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005456 case 260:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005457#line 2634 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005458 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005459 if (!UpRefs.empty())
5460 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5461 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5462 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5463 (yyval.ValueRefList)->push_back(E);
5464 delete (yyvsp[(3) - (5)].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00005465 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005466 ;}
5467 break;
5468
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005469 case 261:
5470#line 2643 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5471 { (yyval.ValueRefList) = new ValueRefList(); ;}
5472 break;
5473
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005474 case 262:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005475#line 2646 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5476 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5477 break;
5478
5479 case 263:
5480#line 2647 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5481 {
5482 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5483 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
5484 CHECK_FOR_ERROR
5485 ;}
5486 break;
5487
5488 case 264:
5489#line 2654 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005490 {
5491 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005492 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005493 ;}
5494 break;
5495
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005496 case 265:
5497#line 2658 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005498 {
5499 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005500 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005501 ;}
5502 break;
5503
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005504 case 266:
5505#line 2663 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005506 {
Reid Spencer14310612006-12-31 05:40:51 +00005507 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005508 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5509 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5510 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005511 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005512 "Arithmetic operator requires integer, FP, or packed operands");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005513 if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5514 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5515 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5516 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005517 GEN_ERROR("Remainder not supported on vector types");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005518 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005519 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005520 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005521 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005522 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
Reid Spencer38c91a92007-02-28 02:24:54 +00005523 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005524 GEN_ERROR("binary operator returned null");
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005525 delete (yyvsp[(2) - (5)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005526 ;}
5527 break;
5528
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005529 case 267:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005530#line 2684 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005531 {
Reid Spencer14310612006-12-31 05:40:51 +00005532 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005533 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5534 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5535 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5536 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
5537 GEN_ERROR("Logical operator requires integral operands");
5538 }
5539 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005540 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005541 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005542 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005543 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
Reid Spencer38c91a92007-02-28 02:24:54 +00005544 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005545 GEN_ERROR("binary operator returned null");
5546 delete (yyvsp[(2) - (5)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005547 ;}
5548 break;
5549
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005550 case 268:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005551#line 2701 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005552 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005553 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005554 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5555 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
5556 GEN_ERROR("Vector types not supported by icmp instruction");
5557 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
5558 CHECK_FOR_ERROR
5559 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
5560 CHECK_FOR_ERROR
5561 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5562 if ((yyval.InstVal) == 0)
5563 GEN_ERROR("icmp operator returned null");
5564 delete (yyvsp[(3) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005565 ;}
5566 break;
5567
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005568 case 269:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005569#line 2715 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005570 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005571 if (!UpRefs.empty())
5572 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5573 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
5574 GEN_ERROR("Vector types not supported by fcmp instruction");
5575 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005576 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005577 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
5578 CHECK_FOR_ERROR
5579 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5580 if ((yyval.InstVal) == 0)
5581 GEN_ERROR("fcmp operator returned null");
5582 delete (yyvsp[(3) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005583 ;}
5584 break;
5585
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005586 case 270:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005587#line 2729 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005588 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005589 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005590 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5591 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5592 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5593 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
5594 GEN_ERROR("invalid cast opcode for cast from '" +
5595 Val->getType()->getDescription() + "' to '" +
5596 DestTy->getDescription() + "'");
5597 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5598 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005599 ;}
5600 break;
5601
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005602 case 271:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005603#line 2741 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005604 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005605 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
5606 GEN_ERROR("select condition must be boolean");
5607 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
5608 GEN_ERROR("select value types should match");
5609 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005610 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005611 ;}
5612 break;
5613
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005614 case 272:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005615#line 2749 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005616 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005617 if (!UpRefs.empty())
5618 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5619 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5620 delete (yyvsp[(4) - (4)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005621 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005622 ;}
5623 break;
5624
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005625 case 273:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005626#line 2756 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005627 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005628 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
5629 GEN_ERROR("Invalid extractelement operands");
5630 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005631 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005632 ;}
5633 break;
5634
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005635 case 274:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005636#line 2762 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005637 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005638 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
5639 GEN_ERROR("Invalid insertelement operands");
5640 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005641 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005642 ;}
5643 break;
5644
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005645 case 275:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005646#line 2768 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5647 {
5648 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
5649 GEN_ERROR("Invalid shufflevector operands");
5650 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
5651 CHECK_FOR_ERROR
5652 ;}
5653 break;
5654
5655 case 276:
5656#line 2774 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5657 {
5658 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
5659 if (!Ty->isFirstClassType())
5660 GEN_ERROR("PHI node operands must be of first class type");
5661 (yyval.InstVal) = new PHINode(Ty);
5662 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5663 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5664 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
5665 GEN_ERROR("All elements of a PHI node must be of the same type");
5666 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5667 (yyvsp[(2) - (2)].PHIList)->pop_front();
5668 }
5669 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
5670 CHECK_FOR_ERROR
5671 ;}
5672 break;
5673
5674 case 277:
5675#line 2790 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005676 {
Reid Spencer14310612006-12-31 05:40:51 +00005677
5678 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005679 const PointerType *PFTy = 0;
5680 const FunctionType *Ty = 0;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005681 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005682 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5683 // Pull out the types of all of the arguments...
5684 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005685 ParamAttrsList ParamAttrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005686 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
5687 ParamAttrs.addAttributes(0, (yyvsp[(8) - (8)].ParamAttrs));
Reid Spencer7b5d4662007-04-09 06:16:21 +00005688 unsigned index = 1;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005689 ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005690 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005691 const Type *Ty = I->Val->getType();
5692 if (Ty == Type::VoidTy)
5693 GEN_ERROR("Short call syntax cannot be used with varargs");
5694 ParamTypes.push_back(Ty);
Reid Spencer18da0722007-04-11 02:44:20 +00005695 if (I->Attrs != ParamAttr::None)
Reid Spencer7b5d4662007-04-09 06:16:21 +00005696 ParamAttrs.addAttributes(index, I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005697 }
5698
Reid Spencer7b5d4662007-04-09 06:16:21 +00005699 ParamAttrsList *Attrs = 0;
5700 if (!ParamAttrs.empty())
5701 Attrs = new ParamAttrsList(ParamAttrs);
5702
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005703 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005704 PFTy = PointerType::get(Ty);
5705 }
5706
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005707 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005708 CHECK_FOR_ERROR
5709
Reid Spencer14310612006-12-31 05:40:51 +00005710 // Check the arguments
5711 ValueList Args;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005712 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005713 // Make sure no arguments is a good thing!
5714 if (Ty->getNumParams() != 0)
5715 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005716 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005717 } else { // Has arguments?
5718 // Loop through FunctionType's arguments and ensure they are specified
5719 // correctly!
5720 //
5721 FunctionType::param_iterator I = Ty->param_begin();
5722 FunctionType::param_iterator E = Ty->param_end();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005723 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005724
Reid Spencer14310612006-12-31 05:40:51 +00005725 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5726 if (ArgI->Val->getType() != *I)
5727 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005728 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005729 Args.push_back(ArgI->Val);
5730 }
5731 if (Ty->isVarArg()) {
5732 if (I == E)
5733 for (; ArgI != ArgE; ++ArgI)
5734 Args.push_back(ArgI->Val); // push the remaining varargs
5735 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005736 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005737 }
Reid Spencer14310612006-12-31 05:40:51 +00005738 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005739 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005740 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
5741 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00005742 (yyval.InstVal) = CI;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005743 delete (yyvsp[(6) - (8)].ValueRefList);
5744 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005745 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005746 ;}
5747 break;
5748
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005749 case 278:
5750#line 2861 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005751 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005752 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005753 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005754 ;}
5755 break;
5756
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005757 case 279:
5758#line 2866 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005759 {
5760 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005761 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005762 ;}
5763 break;
5764
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005765 case 280:
5766#line 2870 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005767 {
5768 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005769 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005770 ;}
5771 break;
5772
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005773 case 281:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005774#line 2877 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005775 {
Reid Spencer14310612006-12-31 05:40:51 +00005776 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005777 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5778 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5779 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005780 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005781 ;}
5782 break;
5783
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005784 case 282:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005785#line 2884 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005786 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005787 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005788 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5789 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005790 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005791 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5792 delete (yyvsp[(2) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005793 ;}
5794 break;
5795
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005796 case 283:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005797#line 2892 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005798 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005799 if (!UpRefs.empty())
5800 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5801 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5802 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005803 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005804 ;}
5805 break;
5806
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005807 case 284:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005808#line 2899 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005809 {
Reid Spencer14310612006-12-31 05:40:51 +00005810 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005811 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5812 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005813 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005814 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5815 delete (yyvsp[(2) - (6)].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005816 ;}
5817 break;
5818
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005819 case 285:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005820#line 2907 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005821 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005822 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
5823 GEN_ERROR("Trying to free nonpointer type " +
5824 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
5825 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005826 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005827 ;}
5828 break;
5829
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005830 case 286:
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005831#line 2915 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005832 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005833 if (!UpRefs.empty())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005834 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5835 if (!isa<PointerType>((yyvsp[(3) - (4)].TypeVal)->get()))
5836 GEN_ERROR("Can't load from nonpointer type: " +
5837 (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5838 if (!cast<PointerType>((yyvsp[(3) - (4)].TypeVal)->get())->getElementType()->isFirstClassType())
5839 GEN_ERROR("Can't load from pointer of non-first-class type: " +
5840 (*(yyvsp[(3) - (4)].TypeVal))->getDescription());
5841 Value* tmpVal = getVal(*(yyvsp[(3) - (4)].TypeVal), (yyvsp[(4) - (4)].ValIDVal));
5842 CHECK_FOR_ERROR
5843 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
5844 delete (yyvsp[(3) - (4)].TypeVal);
5845 ;}
5846 break;
5847
5848 case 287:
5849#line 2929 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5850 {
5851 if (!UpRefs.empty())
5852 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
5853 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal)->get());
5854 if (!PT)
5855 GEN_ERROR("Can't store to a nonpointer type: " +
5856 (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
5857 const Type *ElTy = PT->getElementType();
5858 if (ElTy != (yyvsp[(3) - (6)].ValueVal)->getType())
5859 GEN_ERROR("Can't store '" + (yyvsp[(3) - (6)].ValueVal)->getType()->getDescription() +
5860 "' into space of type '" + ElTy->getDescription() + "'");
5861
5862 Value* tmpVal = getVal(*(yyvsp[(5) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
5863 CHECK_FOR_ERROR
5864 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (6)].ValueVal), tmpVal, (yyvsp[(1) - (6)].BoolVal));
5865 delete (yyvsp[(5) - (6)].TypeVal);
5866 ;}
5867 break;
5868
5869 case 288:
5870#line 2946 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5871 {
5872 if (!UpRefs.empty())
5873 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
5874 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005875 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005876
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005877 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005878 GEN_ERROR("Invalid getelementptr indices for type '" +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005879 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
5880 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005881 CHECK_FOR_ERROR
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005882 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size());
5883 delete (yyvsp[(2) - (4)].TypeVal);
5884 delete (yyvsp[(4) - (4)].ValueList);
Reid Spencer38c91a92007-02-28 02:24:54 +00005885 ;}
5886 break;
5887
5888
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005889/* Line 1267 of yacc.c. */
5890#line 5891 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00005891 default: break;
5892 }
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005893 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Reid Spencer38c91a92007-02-28 02:24:54 +00005894
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005895 YYPOPSTACK (yylen);
5896 yylen = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005897 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005898
5899 *++yyvsp = yyval;
5900
5901
Reid Spencer38c91a92007-02-28 02:24:54 +00005902 /* Now `shift' the result of the reduction. Determine what state
5903 that goes to, based on the state we popped back to and the rule
5904 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005905
5906 yyn = yyr1[yyn];
5907
Reid Spencer38c91a92007-02-28 02:24:54 +00005908 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5909 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005910 yystate = yytable[yystate];
5911 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005912 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005913
5914 goto yynewstate;
5915
5916
Reid Spencer38c91a92007-02-28 02:24:54 +00005917/*------------------------------------.
5918| yyerrlab -- here on detecting error |
5919`------------------------------------*/
5920yyerrlab:
5921 /* If not already recovering from an error, report this error. */
5922 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005923 {
5924 ++yynerrs;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005925#if ! YYERROR_VERBOSE
5926 yyerror (YY_("syntax error"));
5927#else
5928 {
5929 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
5930 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
5931 {
5932 YYSIZE_T yyalloc = 2 * yysize;
5933 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
5934 yyalloc = YYSTACK_ALLOC_MAXIMUM;
5935 if (yymsg != yymsgbuf)
Reid Spencer38c91a92007-02-28 02:24:54 +00005936 YYSTACK_FREE (yymsg);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005937 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
5938 if (yymsg)
5939 yymsg_alloc = yyalloc;
5940 else
5941 {
5942 yymsg = yymsgbuf;
5943 yymsg_alloc = sizeof yymsgbuf;
5944 }
5945 }
5946
5947 if (0 < yysize && yysize <= yymsg_alloc)
5948 {
5949 (void) yysyntax_error (yymsg, yystate, yychar);
5950 yyerror (yymsg);
5951 }
5952 else
5953 {
5954 yyerror (YY_("syntax error"));
5955 if (yysize != 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00005956 goto yyexhaustedlab;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005957 }
5958 }
5959#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005960 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005961
Reid Spencer38c91a92007-02-28 02:24:54 +00005962
Reid Spencer41dff5e2007-01-26 08:05:27 +00005963
5964 if (yyerrstatus == 3)
5965 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005966 /* If just tried and failed to reuse look-ahead token after an
5967 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005968
Reid Spencer38c91a92007-02-28 02:24:54 +00005969 if (yychar <= YYEOF)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005970 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005971 /* Return failure if at end of input. */
5972 if (yychar == YYEOF)
5973 YYABORT;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005974 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005975 else
5976 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005977 yydestruct ("Error: discarding",
5978 yytoken, &yylval);
Reid Spencer38c91a92007-02-28 02:24:54 +00005979 yychar = YYEMPTY;
5980 }
5981 }
5982
5983 /* Else will try to reuse look-ahead token after shifting the error
5984 token. */
5985 goto yyerrlab1;
5986
5987
5988/*---------------------------------------------------.
5989| yyerrorlab -- error raised explicitly by YYERROR. |
5990`---------------------------------------------------*/
5991yyerrorlab:
5992
5993 /* Pacify compilers like GCC when the user code never invokes
5994 YYERROR and the label yyerrorlab therefore never appears in user
5995 code. */
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005996 if (/*CONSTCOND*/ 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00005997 goto yyerrorlab;
5998
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005999 /* Do not reclaim the symbols of the rule which action triggered
6000 this YYERROR. */
6001 YYPOPSTACK (yylen);
6002 yylen = 0;
6003 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer38c91a92007-02-28 02:24:54 +00006004 yystate = *yyssp;
6005 goto yyerrlab1;
6006
6007
6008/*-------------------------------------------------------------.
6009| yyerrlab1 -- common code for both syntax error and YYERROR. |
6010`-------------------------------------------------------------*/
6011yyerrlab1:
6012 yyerrstatus = 3; /* Each real token shifted decrements this. */
6013
6014 for (;;)
6015 {
6016 yyn = yypact[yystate];
6017 if (yyn != YYPACT_NINF)
6018 {
6019 yyn += YYTERROR;
6020 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6021 {
6022 yyn = yytable[yyn];
6023 if (0 < yyn)
6024 break;
6025 }
6026 }
6027
6028 /* Pop the current state because it cannot handle the error token. */
6029 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006030 YYABORT;
6031
Reid Spencere4d87aa2006-12-23 06:05:41 +00006032
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006033 yydestruct ("Error: popping",
6034 yystos[yystate], yyvsp);
6035 YYPOPSTACK (1);
Reid Spencer38c91a92007-02-28 02:24:54 +00006036 yystate = *yyssp;
6037 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006038 }
6039
6040 if (yyn == YYFINAL)
6041 YYACCEPT;
6042
Reid Spencer68a24bd2005-08-27 18:50:39 +00006043 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00006044
6045
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006046 /* Shift the error token. */
Reid Spencer38c91a92007-02-28 02:24:54 +00006047 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00006048
Reid Spencer68a24bd2005-08-27 18:50:39 +00006049 yystate = yyn;
6050 goto yynewstate;
6051
Chris Lattner32980692007-02-19 07:44:24 +00006052
Reid Spencer38c91a92007-02-28 02:24:54 +00006053/*-------------------------------------.
6054| yyacceptlab -- YYACCEPT comes here. |
6055`-------------------------------------*/
6056yyacceptlab:
6057 yyresult = 0;
6058 goto yyreturn;
6059
6060/*-----------------------------------.
6061| yyabortlab -- YYABORT comes here. |
6062`-----------------------------------*/
6063yyabortlab:
6064 yyresult = 1;
6065 goto yyreturn;
6066
6067#ifndef yyoverflow
6068/*-------------------------------------------------.
6069| yyexhaustedlab -- memory exhaustion comes here. |
6070`-------------------------------------------------*/
6071yyexhaustedlab:
6072 yyerror (YY_("memory exhausted"));
6073 yyresult = 2;
6074 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00006075#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00006076
6077yyreturn:
6078 if (yychar != YYEOF && yychar != YYEMPTY)
6079 yydestruct ("Cleanup: discarding lookahead",
6080 yytoken, &yylval);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006081 /* Do not reclaim the symbols of the rule which action triggered
6082 this YYABORT or YYACCEPT. */
6083 YYPOPSTACK (yylen);
6084 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer38c91a92007-02-28 02:24:54 +00006085 while (yyssp != yyss)
6086 {
6087 yydestruct ("Cleanup: popping",
6088 yystos[*yyssp], yyvsp);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006089 YYPOPSTACK (1);
Chris Lattner32980692007-02-19 07:44:24 +00006090 }
Reid Spencer38c91a92007-02-28 02:24:54 +00006091#ifndef yyoverflow
6092 if (yyss != yyssa)
6093 YYSTACK_FREE (yyss);
6094#endif
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006095#if YYERROR_VERBOSE
6096 if (yymsg != yymsgbuf)
6097 YYSTACK_FREE (yymsg);
6098#endif
6099 /* Make sure YYID is used. */
6100 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006101}
Reid Spencer38c91a92007-02-28 02:24:54 +00006102
6103
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006104#line 2963 "/home/laurov/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006105
6106
Reid Spencer14310612006-12-31 05:40:51 +00006107// common code from the two 'RunVMAsmParser' functions
6108static Module* RunParser(Module * M) {
6109
6110 llvmAsmlineno = 1; // Reset the current line number...
6111 CurModule.CurrentModule = M;
6112#if YYDEBUG
6113 yydebug = Debug;
6114#endif
6115
6116 // Check to make sure the parser succeeded
6117 if (yyparse()) {
6118 if (ParserResult)
6119 delete ParserResult;
6120 return 0;
6121 }
6122
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006123 // Emit an error if there are any unresolved types left.
6124 if (!CurModule.LateResolveTypes.empty()) {
6125 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6126 if (DID.Type == ValID::LocalName) {
6127 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6128 } else {
6129 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6130 }
6131 if (ParserResult)
6132 delete ParserResult;
6133 return 0;
6134 }
6135
6136 // Emit an error if there are any unresolved values left.
6137 if (!CurModule.LateResolveValues.empty()) {
6138 Value *V = CurModule.LateResolveValues.back();
6139 std::map<Value*, std::pair<ValID, int> >::iterator I =
6140 CurModule.PlaceHolderInfo.find(V);
6141
6142 if (I != CurModule.PlaceHolderInfo.end()) {
6143 ValID &DID = I->second.first;
6144 if (DID.Type == ValID::LocalName) {
6145 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6146 } else {
6147 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6148 }
6149 if (ParserResult)
6150 delete ParserResult;
6151 return 0;
6152 }
6153 }
6154
Reid Spencer14310612006-12-31 05:40:51 +00006155 // Check to make sure that parsing produced a result
6156 if (!ParserResult)
6157 return 0;
6158
6159 // Reset ParserResult variable while saving its value for the result.
6160 Module *Result = ParserResult;
6161 ParserResult = 0;
6162
6163 return Result;
6164}
6165
Reid Spencer61c83e02006-08-18 08:43:06 +00006166void llvm::GenerateError(const std::string &message, int LineNo) {
6167 if (LineNo == -1) LineNo = llvmAsmlineno;
6168 // TODO: column number in exception
6169 if (TheParseError)
6170 TheParseError->setError(CurFilename, message, LineNo);
6171 TriggerError = 1;
6172}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006173
6174int yyerror(const char *ErrorMsg) {
6175 std::string where
6176 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6177 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006178 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6179 if (yychar != YYEMPTY && yychar != 0)
6180 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6181 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006182 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006183 return 0;
6184}
Reid Spencer38c91a92007-02-28 02:24:54 +00006185