blob: 41bf3b290057da4609c0d3bda94d9ebe332fbedb [file] [log] [blame]
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Anton Korobeynikovf52e6082007-04-29 18:38:24 +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 Korobeynikov178a3522007-01-12 19:22:51 +00007
Anton Korobeynikov38e09802007-04-28 13:48:45 +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.
12
13 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
Anton Korobeynikovf52e6082007-04-29 18:38:24 +000020 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +000022
Anton Korobeynikovf52e6082007-04-29 18:38:24 +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.
Anton Korobeynikov38e09802007-04-28 13:48:45 +000032
Anton Korobeynikovf52e6082007-04-29 18:38:24 +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. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +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. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +000047#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
Anton Korobeynikov38e09802007-04-28 13:48:45 +000054
55/* Pure parsers. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +000056#define YYPURE 0
Anton Korobeynikov38e09802007-04-28 13:48:45 +000057
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
Anton Korobeynikovf52e6082007-04-29 18:38:24 +000061/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
Anton Korobeynikov38e09802007-04-28 13:48:45 +000063#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000064#define yyerror llvmAsmerror
Anton Korobeynikov38e09802007-04-28 13:48:45 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
69
Anton Korobeynikov38e09802007-04-28 13:48:45 +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,
95 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 ALIAS = 286,
106 VOLATILE = 287,
107 THREAD_LOCAL = 288,
108 TO = 289,
109 DOTDOTDOT = 290,
110 NULL_TOK = 291,
111 UNDEF = 292,
112 INTERNAL = 293,
113 LINKONCE = 294,
114 WEAK = 295,
115 APPENDING = 296,
116 DLLIMPORT = 297,
117 DLLEXPORT = 298,
118 EXTERN_WEAK = 299,
119 OPAQUE = 300,
120 EXTERNAL = 301,
121 TARGET = 302,
122 TRIPLE = 303,
123 ALIGN = 304,
124 DEPLIBS = 305,
125 CALL = 306,
126 TAIL = 307,
127 ASM_TOK = 308,
128 MODULE = 309,
129 SIDEEFFECT = 310,
130 CC_TOK = 311,
131 CCC_TOK = 312,
132 FASTCC_TOK = 313,
133 COLDCC_TOK = 314,
134 X86_STDCALLCC_TOK = 315,
135 X86_FASTCALLCC_TOK = 316,
136 DATALAYOUT = 317,
137 RET = 318,
138 BR = 319,
139 SWITCH = 320,
140 INVOKE = 321,
141 UNWIND = 322,
142 UNREACHABLE = 323,
143 ADD = 324,
144 SUB = 325,
145 MUL = 326,
146 UDIV = 327,
147 SDIV = 328,
148 FDIV = 329,
149 UREM = 330,
150 SREM = 331,
151 FREM = 332,
152 AND = 333,
153 OR = 334,
154 XOR = 335,
155 SHL = 336,
156 LSHR = 337,
157 ASHR = 338,
158 ICMP = 339,
159 FCMP = 340,
160 EQ = 341,
161 NE = 342,
162 SLT = 343,
163 SGT = 344,
164 SLE = 345,
165 SGE = 346,
166 ULT = 347,
167 UGT = 348,
168 ULE = 349,
169 UGE = 350,
170 OEQ = 351,
171 ONE = 352,
172 OLT = 353,
173 OGT = 354,
174 OLE = 355,
175 OGE = 356,
176 ORD = 357,
177 UNO = 358,
178 UEQ = 359,
179 UNE = 360,
180 MALLOC = 361,
181 ALLOCA = 362,
182 FREE = 363,
183 LOAD = 364,
184 STORE = 365,
185 GETELEMENTPTR = 366,
186 TRUNC = 367,
187 ZEXT = 368,
188 SEXT = 369,
189 FPTRUNC = 370,
190 FPEXT = 371,
191 BITCAST = 372,
192 UITOFP = 373,
193 SITOFP = 374,
194 FPTOUI = 375,
195 FPTOSI = 376,
196 INTTOPTR = 377,
197 PTRTOINT = 378,
198 PHI_TOK = 379,
199 SELECT = 380,
200 VAARG = 381,
201 EXTRACTELEMENT = 382,
202 INSERTELEMENT = 383,
203 SHUFFLEVECTOR = 384,
204 NORETURN = 385,
205 INREG = 386,
206 SRET = 387,
207 NOUNWIND = 388,
208 DEFAULT = 389,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +0000209 HIDDEN = 390,
210 PROTECTED = 391
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000211 };
212#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +0000213/* Tokens. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000214#define ESINT64VAL 258
215#define EUINT64VAL 259
216#define ESAPINTVAL 260
217#define EUAPINTVAL 261
218#define LOCALVAL_ID 262
219#define GLOBALVAL_ID 263
220#define FPVAL 264
221#define VOID 265
222#define INTTYPE 266
223#define FLOAT 267
224#define DOUBLE 268
225#define LABEL 269
226#define TYPE 270
227#define LOCALVAR 271
228#define GLOBALVAR 272
229#define LABELSTR 273
230#define STRINGCONSTANT 274
231#define ATSTRINGCONSTANT 275
232#define ZEROINITIALIZER 276
233#define TRUETOK 277
234#define FALSETOK 278
235#define BEGINTOK 279
236#define ENDTOK 280
237#define DECLARE 281
238#define DEFINE 282
239#define GLOBAL 283
240#define CONSTANT 284
241#define SECTION 285
242#define ALIAS 286
243#define VOLATILE 287
244#define THREAD_LOCAL 288
245#define TO 289
246#define DOTDOTDOT 290
247#define NULL_TOK 291
248#define UNDEF 292
249#define INTERNAL 293
250#define LINKONCE 294
251#define WEAK 295
252#define APPENDING 296
253#define DLLIMPORT 297
254#define DLLEXPORT 298
255#define EXTERN_WEAK 299
256#define OPAQUE 300
257#define EXTERNAL 301
258#define TARGET 302
259#define TRIPLE 303
260#define ALIGN 304
261#define DEPLIBS 305
262#define CALL 306
263#define TAIL 307
264#define ASM_TOK 308
265#define MODULE 309
266#define SIDEEFFECT 310
267#define CC_TOK 311
268#define CCC_TOK 312
269#define FASTCC_TOK 313
270#define COLDCC_TOK 314
271#define X86_STDCALLCC_TOK 315
272#define X86_FASTCALLCC_TOK 316
273#define DATALAYOUT 317
274#define RET 318
275#define BR 319
276#define SWITCH 320
277#define INVOKE 321
278#define UNWIND 322
279#define UNREACHABLE 323
280#define ADD 324
281#define SUB 325
282#define MUL 326
283#define UDIV 327
284#define SDIV 328
285#define FDIV 329
286#define UREM 330
287#define SREM 331
288#define FREM 332
289#define AND 333
290#define OR 334
291#define XOR 335
292#define SHL 336
293#define LSHR 337
294#define ASHR 338
295#define ICMP 339
296#define FCMP 340
297#define EQ 341
298#define NE 342
299#define SLT 343
300#define SGT 344
301#define SLE 345
302#define SGE 346
303#define ULT 347
304#define UGT 348
305#define ULE 349
306#define UGE 350
307#define OEQ 351
308#define ONE 352
309#define OLT 353
310#define OGT 354
311#define OLE 355
312#define OGE 356
313#define ORD 357
314#define UNO 358
315#define UEQ 359
316#define UNE 360
317#define MALLOC 361
318#define ALLOCA 362
319#define FREE 363
320#define LOAD 364
321#define STORE 365
322#define GETELEMENTPTR 366
323#define TRUNC 367
324#define ZEXT 368
325#define SEXT 369
326#define FPTRUNC 370
327#define FPEXT 371
328#define BITCAST 372
329#define UITOFP 373
330#define SITOFP 374
331#define FPTOUI 375
332#define FPTOSI 376
333#define INTTOPTR 377
334#define PTRTOINT 378
335#define PHI_TOK 379
336#define SELECT 380
337#define VAARG 381
338#define EXTRACTELEMENT 382
339#define INSERTELEMENT 383
340#define SHUFFLEVECTOR 384
341#define NORETURN 385
342#define INREG 386
343#define SRET 387
344#define NOUNWIND 388
345#define DEFAULT 389
346#define HIDDEN 390
Anton Korobeynikovf52e6082007-04-29 18:38:24 +0000347#define PROTECTED 391
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000348
349
350
351
352/* Copy the first part of user declarations. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +0000353#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354
355#include "ParserInternals.h"
356#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000357#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358#include "llvm/Instructions.h"
359#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000360#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000361#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000362#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000363#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000364#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000365#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000366#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000367#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000369#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000371#ifndef NDEBUG
372#define YYDEBUG 1
373#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374
Reid Spencere4f47592006-08-18 17:32:55 +0000375// The following is a gross hack. In order to rid the libAsmParser library of
376// exceptions, we have to have a way of getting the yyparse function to go into
377// an error situation. So, whenever we want an error to occur, the GenerateError
378// function (see bottom of file) sets TriggerError. Then, at the end of each
379// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
380// (a goto) to put YACC in error state. Furthermore, several calls to
381// GenerateError are made from inside productions and they must simulate the
382// previous exception behavior by exiting the production immediately. We have
383// replaced these with the GEN_ERROR macro which calls GeneratError and then
384// immediately invokes YYERROR. This would be so much cleaner if it was a
385// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000386static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000387#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000388#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
389
Reid Spencer68a24bd2005-08-27 18:50:39 +0000390int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
391int yylex(); // declaration" of xxx warnings.
392int yyparse();
393
394namespace llvm {
395 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000396#if YYDEBUG
397static cl::opt<bool>
398Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
399 cl::Hidden, cl::init(false));
400#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000401}
402using namespace llvm;
403
404static Module *ParserResult;
405
406// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
407// relating to upreferences in the input stream.
408//
409//#define DEBUG_UPREFS 1
410#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000411#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412#else
413#define UR_OUT(X)
414#endif
415
416#define YYERROR_VERBOSE 1
417
Chris Lattnerb475c422005-11-12 18:22:38 +0000418static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419
420
421// This contains info used when building the body of a function. It is
422// destroyed when the function is completed.
423//
424typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000425
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426static void
Reid Spencer93c40032007-03-19 18:40:50 +0000427ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000428
429static struct PerModuleInfo {
430 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000431 ValueList Values; // Module level numbered definitions
432 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000433 std::vector<PATypeHolder> Types;
434 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000435
436 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000437 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438 /// that we can resolve them later and print error messages as appropriate.
439 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
440
441 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
442 // references to global values. Global values may be referenced before they
443 // are defined, and if so, the temporary object that they represent is held
444 // here. This is used for forward references of GlobalValues.
445 //
446 typedef std::map<std::pair<const PointerType *,
447 ValID>, GlobalValue*> GlobalRefsType;
448 GlobalRefsType GlobalRefs;
449
450 void ModuleDone() {
451 // If we could not resolve some functions at function compilation time
452 // (calls to functions before they are defined), resolve them now... Types
453 // are resolved when the constant pool has been completely parsed.
454 //
455 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000456 if (TriggerError)
457 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458
459 // Check to make sure that all global value forward references have been
460 // resolved!
461 //
462 if (!GlobalRefs.empty()) {
463 std::string UndefinedReferences = "Unresolved global references exist:\n";
464
465 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
466 I != E; ++I) {
467 UndefinedReferences += " " + I->first.first->getDescription() + " " +
468 I->first.second.getName() + "\n";
469 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000470 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000471 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000472 }
473
474 Values.clear(); // Clear out function local definitions
475 Types.clear();
476 CurrentModule = 0;
477 }
478
Reid Spencer68a24bd2005-08-27 18:50:39 +0000479 // GetForwardRefForGlobal - Check to see if there is a forward reference
480 // for this global. If so, remove it from the GlobalRefs map and return it.
481 // If not, just return null.
482 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
483 // Check to see if there is a forward reference to this global variable...
484 // if there is, eliminate it and patch the reference to use the new def'n.
485 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
486 GlobalValue *Ret = 0;
487 if (I != GlobalRefs.end()) {
488 Ret = I->second;
489 GlobalRefs.erase(I);
490 }
491 return Ret;
492 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000493
494 bool TypeIsUnresolved(PATypeHolder* PATy) {
495 // If it isn't abstract, its resolved
496 const Type* Ty = PATy->get();
497 if (!Ty->isAbstract())
498 return false;
499 // Traverse the type looking for abstract types. If it isn't abstract then
500 // we don't need to traverse that leg of the type.
501 std::vector<const Type*> WorkList, SeenList;
502 WorkList.push_back(Ty);
503 while (!WorkList.empty()) {
504 const Type* Ty = WorkList.back();
505 SeenList.push_back(Ty);
506 WorkList.pop_back();
507 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
508 // Check to see if this is an unresolved type
509 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
510 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
511 for ( ; I != E; ++I) {
512 if (I->second.get() == OpTy)
513 return true;
514 }
515 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
516 const Type* TheTy = SeqTy->getElementType();
517 if (TheTy->isAbstract() && TheTy != Ty) {
518 std::vector<const Type*>::iterator I = SeenList.begin(),
519 E = SeenList.end();
520 for ( ; I != E; ++I)
521 if (*I == TheTy)
522 break;
523 if (I == E)
524 WorkList.push_back(TheTy);
525 }
526 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
527 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
528 const Type* TheTy = StrTy->getElementType(i);
529 if (TheTy->isAbstract() && TheTy != Ty) {
530 std::vector<const Type*>::iterator I = SeenList.begin(),
531 E = SeenList.end();
532 for ( ; I != E; ++I)
533 if (*I == TheTy)
534 break;
535 if (I == E)
536 WorkList.push_back(TheTy);
537 }
538 }
539 }
540 }
541 return false;
542 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000543} CurModule;
544
545static struct PerFunctionInfo {
546 Function *CurrentFunction; // Pointer to current function being created
547
Reid Spencer93c40032007-03-19 18:40:50 +0000548 ValueList Values; // Keep track of #'d definitions
549 unsigned NextValNum;
550 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000551 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000552 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000553 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554
555 /// BBForwardRefs - When we see forward references to basic blocks, keep
556 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000557 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558
559 inline PerFunctionInfo() {
560 CurrentFunction = 0;
561 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000562 Linkage = GlobalValue::ExternalLinkage;
563 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564 }
565
566 inline void FunctionStart(Function *M) {
567 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000568 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000569 }
570
571 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000572 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000573 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000574 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000575 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000576 return;
577 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578
579 // Resolve all forward references now.
580 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
581
582 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000583 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 CurrentFunction = 0;
585 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000586 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000587 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588 }
589} CurFun; // Info for the current function...
590
591static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
592
593
594//===----------------------------------------------------------------------===//
595// Code to handle definitions of all the types
596//===----------------------------------------------------------------------===//
597
Reid Spencer93c40032007-03-19 18:40:50 +0000598static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
599 // Things that have names or are void typed don't get slot numbers
600 if (V->hasName() || (V->getType() == Type::VoidTy))
601 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602
Reid Spencer93c40032007-03-19 18:40:50 +0000603 // In the case of function values, we have to allow for the forward reference
604 // of basic blocks, which are included in the numbering. Consequently, we keep
605 // track of the next insertion location with NextValNum. When a BB gets
606 // inserted, it could change the size of the CurFun.Values vector.
607 if (&ValueTab == &CurFun.Values) {
608 if (ValueTab.size() <= CurFun.NextValNum)
609 ValueTab.resize(CurFun.NextValNum+1);
610 ValueTab[CurFun.NextValNum++] = V;
611 return;
612 }
613 // For all other lists, its okay to just tack it on the back of the vector.
614 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000615}
616
617static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
618 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000619 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000621 if (D.Num < CurModule.Types.size())
622 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000624 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
626 D.destroy(); // Free old strdup'd memory...
627 return N;
628 }
629 break;
630 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000631 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000632 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633 }
634
635 // If we reached here, we referenced either a symbol that we don't know about
636 // or an id number that hasn't been read yet. We may be referencing something
637 // forward, so just create an entry to be resolved later and get to it...
638 //
639 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
640
641
642 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000643 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000644 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000645 return 0;
646 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000647 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000648 return 0;
649 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000650 }
651
Reid Spencer861d9d62006-11-28 07:29:44 +0000652 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000654 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000655
Reid Spencer861d9d62006-11-28 07:29:44 +0000656 Type *Typ = OpaqueType::get();
657 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
658 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000659 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660
Reid Spencer93c40032007-03-19 18:40:50 +0000661// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000662// the provided ValID. If the value exists and has already been defined, return
663// it. Otherwise return null.
664//
Reid Spencer93c40032007-03-19 18:40:50 +0000665static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000666 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000667 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000668 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000669 return 0;
670 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671
672 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000673 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000674 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000675 if (D.Num >= CurFun.Values.size())
676 return 0;
677 Value *Result = CurFun.Values[D.Num];
678 if (Ty != Result->getType()) {
679 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
680 Result->getType()->getDescription() + "' does not match "
681 "expected type, '" + Ty->getDescription() + "'");
682 return 0;
683 }
684 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000685 }
686 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000687 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000688 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000689 Value *Result = CurModule.Values[D.Num];
690 if (Ty != Result->getType()) {
691 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
692 Result->getType()->getDescription() + "' does not match "
693 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000694 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000695 }
696 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000697 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000698
699 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000700 if (!inFunctionScope())
701 return 0;
702 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
703 Value *N = SymTab.lookup(D.Name);
704 if (N == 0)
705 return 0;
706 if (N->getType() != Ty)
707 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000708
709 D.destroy(); // Free old strdup'd memory...
710 return N;
711 }
712 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000713 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
714 Value *N = SymTab.lookup(D.Name);
715 if (N == 0)
716 return 0;
717 if (N->getType() != Ty)
718 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000719
720 D.destroy(); // Free old strdup'd memory...
721 return N;
722 }
723
724 // Check to make sure that "Ty" is an integral type, and that our
725 // value will fit into the specified type...
726 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000727 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000728 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000730 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000731 return 0;
732 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000733 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000734
735 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000736 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
737 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000738 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000739 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000742 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000743 }
744 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000745 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 }
747
748 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000749 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000750 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000751 return 0;
752 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000753 return ConstantFP::get(Ty, D.ConstPoolFP);
754
755 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000757 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000758 return 0;
759 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000760 return ConstantPointerNull::get(cast<PointerType>(Ty));
761
762 case ValID::ConstUndefVal: // Is it an undef value?
763 return UndefValue::get(Ty);
764
Chris Lattner7aa61892005-12-21 17:53:23 +0000765 case ValID::ConstZeroVal: // Is it a zero value?
766 return Constant::getNullValue(Ty);
767
Reid Spencer68a24bd2005-08-27 18:50:39 +0000768 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000770 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000771 return 0;
772 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000773 return D.ConstantValue;
774
Chris Lattner0e9c3762006-01-25 22:27:16 +0000775 case ValID::InlineAsmVal: { // Inline asm expression
776 const PointerType *PTy = dyn_cast<PointerType>(Ty);
777 const FunctionType *FTy =
778 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000780 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000781 return 0;
782 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000783 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
784 D.IAD->HasSideEffects);
785 D.destroy(); // Free InlineAsmDescriptor.
786 return IA;
787 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000788 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000789 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790 return 0;
791 } // End of switch
792
Reid Spencera9720f52007-02-05 17:04:00 +0000793 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794 return 0;
795}
796
Reid Spencer93c40032007-03-19 18:40:50 +0000797// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000798// value is not already defined, it "improvises" by creating a placeholder var
799// that looks and acts just like the requested variable. When the value is
800// defined later, all uses of the placeholder variable are replaced with the
801// real thing.
802//
803static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000805 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 return 0;
807 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000808
809 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000810 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000813
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000815 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000816 return 0;
817 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000818
819 // If we reached here, we referenced either a symbol that we don't know about
820 // or an id number that hasn't been read yet. We may be referencing something
821 // forward, so just create an entry to be resolved later and get to it...
822 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000823 switch (ID.Type) {
824 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000825 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000826 const PointerType *PTy = dyn_cast<PointerType>(Ty);
827 if (!PTy) {
828 GenerateError("Invalid type for reference to global" );
829 return 0;
830 }
831 const Type* ElTy = PTy->getElementType();
832 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
833 V = new Function(FTy, GlobalValue::ExternalLinkage);
834 else
835 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
836 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000837 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000838 default:
839 V = new Argument(Ty);
840 }
841
Reid Spencer68a24bd2005-08-27 18:50:39 +0000842 // Remember where this forward reference came from. FIXME, shouldn't we try
843 // to recycle these things??
844 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
845 llvmAsmlineno)));
846
847 if (inFunctionScope())
848 InsertValue(V, CurFun.LateResolveValues);
849 else
850 InsertValue(V, CurModule.LateResolveValues);
851 return V;
852}
853
Reid Spencer93c40032007-03-19 18:40:50 +0000854/// defineBBVal - This is a definition of a new basic block with the specified
855/// identifier which must be the same as CurFun.NextValNum, if its numeric.
856static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000857 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860
Reid Spencer93c40032007-03-19 18:40:50 +0000861 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000862
Reid Spencer93c40032007-03-19 18:40:50 +0000863 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
864 if (BBI != CurFun.BBForwardRefs.end()) {
865 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866 // The forward declaration could have been inserted anywhere in the
867 // function: insert it into the correct place now.
868 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
869 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000870
Reid Spencer66728ef2007-03-20 01:13:36 +0000871 // We're about to erase the entry, save the key so we can clean it up.
872 ValID Tmp = BBI->first;
873
Reid Spencer93c40032007-03-19 18:40:50 +0000874 // Erase the forward ref from the map as its no longer "forward"
875 CurFun.BBForwardRefs.erase(ID);
876
Reid Spencer66728ef2007-03-20 01:13:36 +0000877 // The key has been removed from the map but so we don't want to leave
878 // strdup'd memory around so destroy it too.
879 Tmp.destroy();
880
Reid Spencer93c40032007-03-19 18:40:50 +0000881 // If its a numbered definition, bump the number and set the BB value.
882 if (ID.Type == ValID::LocalID) {
883 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
884 InsertValue(BB);
885 }
886
887 ID.destroy();
888 return BB;
889 }
890
891 // We haven't seen this BB before and its first mention is a definition.
892 // Just create it and return it.
893 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
894 BB = new BasicBlock(Name, CurFun.CurrentFunction);
895 if (ID.Type == ValID::LocalID) {
896 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
897 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898 }
Reid Spencer93c40032007-03-19 18:40:50 +0000899
900 ID.destroy(); // Free strdup'd memory
901 return BB;
902}
903
904/// getBBVal - get an existing BB value or create a forward reference for it.
905///
906static BasicBlock *getBBVal(const ValID &ID) {
907 assert(inFunctionScope() && "Can't get basic block at global scope!");
908
909 BasicBlock *BB = 0;
910
911 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
912 if (BBI != CurFun.BBForwardRefs.end()) {
913 BB = BBI->second;
914 } if (ID.Type == ValID::LocalName) {
915 std::string Name = ID.Name;
916 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
917 if (N)
918 if (N->getType()->getTypeID() == Type::LabelTyID)
919 BB = cast<BasicBlock>(N);
920 else
921 GenerateError("Reference to label '" + Name + "' is actually of type '"+
922 N->getType()->getDescription() + "'");
923 } else if (ID.Type == ValID::LocalID) {
924 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
925 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
926 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
927 else
928 GenerateError("Reference to label '%" + utostr(ID.Num) +
929 "' is actually of type '"+
930 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
931 }
932 } else {
933 GenerateError("Illegal label reference " + ID.getName());
934 return 0;
935 }
936
937 // If its already been defined, return it now.
938 if (BB) {
939 ID.destroy(); // Free strdup'd memory.
940 return BB;
941 }
942
943 // Otherwise, this block has not been seen before, create it.
944 std::string Name;
945 if (ID.Type == ValID::LocalName)
946 Name = ID.Name;
947 BB = new BasicBlock(Name, CurFun.CurrentFunction);
948
949 // Insert it in the forward refs map.
950 CurFun.BBForwardRefs[ID] = BB;
951
Reid Spencer68a24bd2005-08-27 18:50:39 +0000952 return BB;
953}
954
955
956//===----------------------------------------------------------------------===//
957// Code to handle forward references in instructions
958//===----------------------------------------------------------------------===//
959//
960// This code handles the late binding needed with statements that reference
961// values not defined yet... for example, a forward branch, or the PHI node for
962// a loop body.
963//
964// This keeps a table (CurFun.LateResolveValues) of all such forward references
965// and back patchs after we are done.
966//
967
968// ResolveDefinitions - If we could not resolve some defs at parsing
969// time (forward branches, phi functions for loops, etc...) resolve the
970// defs now...
971//
972static void
Reid Spencer93c40032007-03-19 18:40:50 +0000973ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000974 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000975 while (!LateResolvers.empty()) {
976 Value *V = LateResolvers.back();
977 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000978
Reid Spencer93c40032007-03-19 18:40:50 +0000979 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
980 CurModule.PlaceHolderInfo.find(V);
981 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000982
Reid Spencer93c40032007-03-19 18:40:50 +0000983 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984
Reid Spencer93c40032007-03-19 18:40:50 +0000985 Value *TheRealValue = getExistingVal(V->getType(), DID);
986 if (TriggerError)
987 return;
988 if (TheRealValue) {
989 V->replaceAllUsesWith(TheRealValue);
990 delete V;
991 CurModule.PlaceHolderInfo.erase(PHI);
992 } else if (FutureLateResolvers) {
993 // Functions have their unresolved items forwarded to the module late
994 // resolver table
995 InsertValue(V, *FutureLateResolvers);
996 } else {
997 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
998 GenerateError("Reference to an invalid definition: '" +DID.getName()+
999 "' of type '" + V->getType()->getDescription() + "'",
1000 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001001 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001002 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001003 GenerateError("Reference to an invalid definition: #" +
1004 itostr(DID.Num) + " of type '" +
1005 V->getType()->getDescription() + "'",
1006 PHI->second.second);
1007 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008 }
1009 }
1010 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001011 LateResolvers.clear();
1012}
1013
1014// ResolveTypeTo - A brand new type was just declared. This means that (if
1015// name is not null) things referencing Name can be resolved. Otherwise, things
1016// refering to the number can be resolved. Do this now.
1017//
1018static void ResolveTypeTo(char *Name, const Type *ToTy) {
1019 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +00001020 if (Name) D = ValID::createLocalName(Name);
1021 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022
Reid Spencer861d9d62006-11-28 07:29:44 +00001023 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024 CurModule.LateResolveTypes.find(D);
1025 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001026 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027 CurModule.LateResolveTypes.erase(I);
1028 }
1029}
1030
1031// setValueName - Set the specified value to the name given. The name may be
1032// null potentially, in which case this is a noop. The string passed in is
1033// assumed to be a malloc'd string buffer, and is free'd by this function.
1034//
1035static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001036 if (!NameStr) return;
1037 std::string Name(NameStr); // Copy string
1038 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039
Reid Spencer41dff5e2007-01-26 08:05:27 +00001040 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001041 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001042 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001044
Reid Spencera9720f52007-02-05 17:04:00 +00001045 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001046 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1047 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001048 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001049 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001050 return;
1051 }
1052
1053 // Set the name.
1054 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001055}
1056
1057/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1058/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001059static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001060ParseGlobalVariable(char *NameStr,
1061 GlobalValue::LinkageTypes Linkage,
1062 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001063 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001064 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001065 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001066 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001067 return 0;
1068 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069
1070 const PointerType *PTy = PointerType::get(Ty);
1071
1072 std::string Name;
1073 if (NameStr) {
1074 Name = NameStr; // Copy string
1075 free(NameStr); // Free old string
1076 }
1077
1078 // See if this global value was forward referenced. If so, recycle the
1079 // object.
1080 ValID ID;
1081 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001082 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001083 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001084 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 }
1086
1087 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1088 // Move the global to the end of the list, from whereever it was
1089 // previously inserted.
1090 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1091 CurModule.CurrentModule->getGlobalList().remove(GV);
1092 CurModule.CurrentModule->getGlobalList().push_back(GV);
1093 GV->setInitializer(Initializer);
1094 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001095 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001097 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001099 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001100 }
1101
Reid Spenceref9b9a72007-02-05 20:47:22 +00001102 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001104 // if the global we're parsing has an initializer (is a definition) and
1105 // has external linkage.
1106 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1107 // If there is already a global with external linkage with this name
1108 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1109 // If we allow this GVar to get created, it will be renamed in the
1110 // symbol table because it conflicts with an existing GVar. We can't
1111 // allow redefinition of GVars whose linking indicates that their name
1112 // must stay the same. Issue the error.
1113 GenerateError("Redefinition of global variable named '" + Name +
1114 "' of type '" + Ty->getDescription() + "'");
1115 return 0;
1116 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001117 }
1118
1119 // Otherwise there is no existing GV to use, create one now.
1120 GlobalVariable *GV =
1121 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001122 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001123 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001124 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001125 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126}
1127
1128// setTypeName - Set the specified type to the name given. The name may be
1129// null potentially, in which case this is a noop. The string passed in is
1130// assumed to be a malloc'd string buffer, and is freed by this function.
1131//
1132// This function returns true if the type has already been defined, but is
1133// allowed to be redefined in the specified context. If the name is a new name
1134// for the type plane, it is inserted and false is returned.
1135static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001136 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001137 if (NameStr == 0) return false;
1138
1139 std::string Name(NameStr); // Copy string
1140 free(NameStr); // Free old string
1141
1142 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001143 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001144 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001145 return false;
1146 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147
1148 // Set the type name, checking for conflicts as we do so.
1149 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1150
1151 if (AlreadyExists) { // Inserting a name that is already defined???
1152 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001153 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154
1155 // There is only one case where this is allowed: when we are refining an
1156 // opaque type. In this case, Existing will be an opaque type.
1157 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1158 // We ARE replacing an opaque type!
1159 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1160 return true;
1161 }
1162
1163 // Otherwise, this is an attempt to redefine a type. That's okay if
1164 // the redefinition is identical to the original. This will be so if
1165 // Existing and T point to the same Type object. In this one case we
1166 // allow the equivalent redefinition.
1167 if (Existing == T) return true; // Yes, it's equal.
1168
1169 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001170 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001171 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001172 }
1173
1174 return false;
1175}
1176
1177//===----------------------------------------------------------------------===//
1178// Code for handling upreferences in type names...
1179//
1180
1181// TypeContains - Returns true if Ty directly contains E in it.
1182//
1183static bool TypeContains(const Type *Ty, const Type *E) {
1184 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1185 E) != Ty->subtype_end();
1186}
1187
1188namespace {
1189 struct UpRefRecord {
1190 // NestingLevel - The number of nesting levels that need to be popped before
1191 // this type is resolved.
1192 unsigned NestingLevel;
1193
1194 // LastContainedTy - This is the type at the current binding level for the
1195 // type. Every time we reduce the nesting level, this gets updated.
1196 const Type *LastContainedTy;
1197
1198 // UpRefTy - This is the actual opaque type that the upreference is
1199 // represented with.
1200 OpaqueType *UpRefTy;
1201
1202 UpRefRecord(unsigned NL, OpaqueType *URTy)
1203 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1204 };
1205}
1206
1207// UpRefs - A list of the outstanding upreferences that need to be resolved.
1208static std::vector<UpRefRecord> UpRefs;
1209
1210/// HandleUpRefs - Every time we finish a new layer of types, this function is
1211/// called. It loops through the UpRefs vector, which is a list of the
1212/// currently active types. For each type, if the up reference is contained in
1213/// the newly completed type, we decrement the level count. When the level
1214/// count reaches zero, the upreferenced type is the type that is passed in:
1215/// thus we can complete the cycle.
1216///
1217static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001218 // If Ty isn't abstract, or if there are no up-references in it, then there is
1219 // nothing to resolve here.
1220 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1221
Reid Spencer68a24bd2005-08-27 18:50:39 +00001222 PATypeHolder Ty(ty);
1223 UR_OUT("Type '" << Ty->getDescription() <<
1224 "' newly formed. Resolving upreferences.\n" <<
1225 UpRefs.size() << " upreferences active!\n");
1226
1227 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1228 // to zero), we resolve them all together before we resolve them to Ty. At
1229 // the end of the loop, if there is anything to resolve to Ty, it will be in
1230 // this variable.
1231 OpaqueType *TypeToResolve = 0;
1232
1233 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1234 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1235 << UpRefs[i].second->getDescription() << ") = "
1236 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1237 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1238 // Decrement level of upreference
1239 unsigned Level = --UpRefs[i].NestingLevel;
1240 UpRefs[i].LastContainedTy = Ty;
1241 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1242 if (Level == 0) { // Upreference should be resolved!
1243 if (!TypeToResolve) {
1244 TypeToResolve = UpRefs[i].UpRefTy;
1245 } else {
1246 UR_OUT(" * Resolving upreference for "
1247 << UpRefs[i].second->getDescription() << "\n";
1248 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1249 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1250 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1251 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1252 }
1253 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1254 --i; // Do not skip the next element...
1255 }
1256 }
1257 }
1258
1259 if (TypeToResolve) {
1260 UR_OUT(" * Resolving upreference for "
1261 << UpRefs[i].second->getDescription() << "\n";
1262 std::string OldName = TypeToResolve->getDescription());
1263 TypeToResolve->refineAbstractTypeTo(Ty);
1264 }
1265
1266 return Ty;
1267}
1268
Reid Spencer68a24bd2005-08-27 18:50:39 +00001269//===----------------------------------------------------------------------===//
1270// RunVMAsmParser - Define an interface to this parser
1271//===----------------------------------------------------------------------===//
1272//
Reid Spencer14310612006-12-31 05:40:51 +00001273static Module* RunParser(Module * M);
1274
Reid Spencer68a24bd2005-08-27 18:50:39 +00001275Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1276 set_scan_file(F);
1277
1278 CurFilename = Filename;
1279 return RunParser(new Module(CurFilename));
1280}
1281
1282Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1283 set_scan_string(AsmString);
1284
1285 CurFilename = "from_memory";
1286 if (M == NULL) {
1287 return RunParser(new Module (CurFilename));
1288 } else {
1289 return RunParser(M);
1290 }
1291}
1292
1293
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001294
1295/* Enabling traces. */
1296#ifndef YYDEBUG
1297# define YYDEBUG 0
1298#endif
1299
1300/* Enabling verbose error messages. */
1301#ifdef YYERROR_VERBOSE
1302# undef YYERROR_VERBOSE
1303# define YYERROR_VERBOSE 1
1304#else
1305# define YYERROR_VERBOSE 0
1306#endif
1307
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001308/* Enabling the token table. */
1309#ifndef YYTOKEN_TABLE
1310# define YYTOKEN_TABLE 0
1311#endif
1312
1313#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1314typedef union YYSTYPE
1315#line 955 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
1316{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001317 llvm::Module *ModuleVal;
1318 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001319 llvm::BasicBlock *BasicBlockVal;
1320 llvm::TerminatorInst *TermInstVal;
1321 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001322 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001323
Reid Spencera132e042006-12-03 05:46:11 +00001324 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001325 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001326 llvm::PATypeHolder *TypeVal;
1327 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001328 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001329 llvm::ArgListType *ArgList;
1330 llvm::TypeWithAttrs TypeWithAttrs;
1331 llvm::TypeWithAttrsList *TypeWithAttrsList;
1332 llvm::ValueRefList *ValueRefList;
1333
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001335 std::list<std::pair<llvm::Value*,
1336 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001337 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001338 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339
1340 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001341 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001342 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001343 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001344 int64_t SInt64Val;
1345 uint64_t UInt64Val;
1346 int SIntVal;
1347 unsigned UIntVal;
1348 double FPVal;
1349 bool BoolVal;
1350
1351 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001352 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001353
Reid Spencera132e042006-12-03 05:46:11 +00001354 llvm::Instruction::BinaryOps BinaryOpVal;
1355 llvm::Instruction::TermOps TermOpVal;
1356 llvm::Instruction::MemoryOps MemOpVal;
1357 llvm::Instruction::CastOps CastOpVal;
1358 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001359 llvm::ICmpInst::Predicate IPredicate;
1360 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001361}
1362/* Line 187 of yacc.c. */
1363#line 1364 "llvmAsmParser.tab.c"
1364 YYSTYPE;
1365# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1366# define YYSTYPE_IS_DECLARED 1
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001367# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001368#endif
1369
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001370
Reid Spencer68a24bd2005-08-27 18:50:39 +00001371
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001372/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001373
1374
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001375/* Line 216 of yacc.c. */
1376#line 1377 "llvmAsmParser.tab.c"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001377
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001378#ifdef short
1379# undef short
1380#endif
1381
1382#ifdef YYTYPE_UINT8
1383typedef YYTYPE_UINT8 yytype_uint8;
1384#else
1385typedef unsigned char yytype_uint8;
1386#endif
1387
1388#ifdef YYTYPE_INT8
1389typedef YYTYPE_INT8 yytype_int8;
1390#elif (defined __STDC__ || defined __C99__FUNC__ \
1391 || defined __cplusplus || defined _MSC_VER)
1392typedef signed char yytype_int8;
1393#else
1394typedef short int yytype_int8;
1395#endif
1396
1397#ifdef YYTYPE_UINT16
1398typedef YYTYPE_UINT16 yytype_uint16;
1399#else
1400typedef unsigned short int yytype_uint16;
1401#endif
1402
1403#ifdef YYTYPE_INT16
1404typedef YYTYPE_INT16 yytype_int16;
1405#else
1406typedef short int yytype_int16;
1407#endif
1408
1409#ifndef YYSIZE_T
1410# ifdef __SIZE_TYPE__
1411# define YYSIZE_T __SIZE_TYPE__
1412# elif defined size_t
1413# define YYSIZE_T size_t
1414# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1415 || defined __cplusplus || defined _MSC_VER)
1416# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1417# define YYSIZE_T size_t
1418# else
1419# define YYSIZE_T unsigned int
1420# endif
1421#endif
1422
1423#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1424
1425#ifndef YY_
1426# if YYENABLE_NLS
1427# if ENABLE_NLS
1428# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1429# define YY_(msgid) dgettext ("bison-runtime", msgid)
1430# endif
1431# endif
1432# ifndef YY_
1433# define YY_(msgid) msgid
1434# endif
1435#endif
1436
1437/* Suppress unused-variable warnings by "using" E. */
1438#if ! defined lint || defined __GNUC__
1439# define YYUSE(e) ((void) (e))
1440#else
1441# define YYUSE(e) /* empty */
1442#endif
1443
1444/* Identity function, used to suppress warnings about constant conditions. */
1445#ifndef lint
1446# define YYID(n) (n)
1447#else
1448#if (defined __STDC__ || defined __C99__FUNC__ \
1449 || defined __cplusplus || defined _MSC_VER)
1450static int
1451YYID (int i)
1452#else
1453static int
1454YYID (i)
1455 int i;
1456#endif
1457{
1458 return i;
1459}
1460#endif
1461
1462#if ! defined yyoverflow || YYERROR_VERBOSE
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001463
1464/* The parser invokes alloca or malloc; define the necessary symbols. */
1465
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001466# ifdef YYSTACK_USE_ALLOCA
1467# if YYSTACK_USE_ALLOCA
1468# ifdef __GNUC__
1469# define YYSTACK_ALLOC __builtin_alloca
1470# elif defined __BUILTIN_VA_ARG_INCR
1471# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1472# elif defined _AIX
1473# define YYSTACK_ALLOC __alloca
1474# elif defined _MSC_VER
1475# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1476# define alloca _alloca
Jeff Cohen930c0fe2007-04-29 14:43:31 +00001477# else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001478# define YYSTACK_ALLOC alloca
1479# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1480 || defined __cplusplus || defined _MSC_VER)
1481# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1482# ifndef _STDLIB_H
1483# define _STDLIB_H 1
1484# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001485# endif
1486# endif
1487# endif
1488# endif
1489
1490# ifdef YYSTACK_ALLOC
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001491 /* Pacify GCC's `empty if-body' warning. */
1492# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1493# ifndef YYSTACK_ALLOC_MAXIMUM
1494 /* The OS might guarantee only one guard page at the bottom of the stack,
1495 and a page size can be as small as 4096 bytes. So we cannot safely
1496 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1497 to allow for a few compiler-allocated temporary stack slots. */
1498# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001499# endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001500# else
1501# define YYSTACK_ALLOC YYMALLOC
1502# define YYSTACK_FREE YYFREE
1503# ifndef YYSTACK_ALLOC_MAXIMUM
1504# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1505# endif
1506# if (defined __cplusplus && ! defined _STDLIB_H \
1507 && ! ((defined YYMALLOC || defined malloc) \
1508 && (defined YYFREE || defined free)))
1509# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1510# ifndef _STDLIB_H
1511# define _STDLIB_H 1
1512# endif
1513# endif
1514# ifndef YYMALLOC
1515# define YYMALLOC malloc
1516# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1517 || defined __cplusplus || defined _MSC_VER)
1518void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1519# endif
1520# endif
1521# ifndef YYFREE
1522# define YYFREE free
1523# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1524 || defined __cplusplus || defined _MSC_VER)
1525void free (void *); /* INFRINGES ON USER NAME SPACE */
1526# endif
1527# endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001528# endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001529#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001530
1531
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001532#if (! defined yyoverflow \
1533 && (! defined __cplusplus \
1534 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001535
1536/* A type that is properly aligned for any stack member. */
1537union yyalloc
1538{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001539 yytype_int16 yyss;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001540 YYSTYPE yyvs;
1541 };
1542
1543/* The size of the maximum gap between one aligned stack and the next. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001544# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001545
1546/* The size of an array large to enough to hold all stacks, each with
1547 N elements. */
1548# define YYSTACK_BYTES(N) \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001549 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1550 + YYSTACK_GAP_MAXIMUM)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001551
1552/* Copy COUNT objects from FROM to TO. The source and destination do
1553 not overlap. */
1554# ifndef YYCOPY
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001555# if defined __GNUC__ && 1 < __GNUC__
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001556# define YYCOPY(To, From, Count) \
1557 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1558# else
1559# define YYCOPY(To, From, Count) \
1560 do \
1561 { \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001562 YYSIZE_T yyi; \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001563 for (yyi = 0; yyi < (Count); yyi++) \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001564 (To)[yyi] = (From)[yyi]; \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001565 } \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001566 while (YYID (0))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001567# endif
1568# endif
1569
1570/* Relocate STACK from its old location to the new one. The
1571 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1572 elements in the stack, and YYPTR gives the new location of the
1573 stack. Advance YYPTR to a properly aligned location for the next
1574 stack. */
1575# define YYSTACK_RELOCATE(Stack) \
1576 do \
1577 { \
1578 YYSIZE_T yynewbytes; \
1579 YYCOPY (&yyptr->Stack, Stack, yysize); \
1580 Stack = &yyptr->Stack; \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001581 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001582 yyptr += yynewbytes / sizeof (*yyptr); \
1583 } \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001584 while (YYID (0))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001585
1586#endif
1587
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001588/* YYFINAL -- State number of the termination state. */
1589#define YYFINAL 42
1590/* YYLAST -- Last index in YYTABLE. */
1591#define YYLAST 1491
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001592
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001593/* YYNTOKENS -- Number of terminals. */
1594#define YYNTOKENS 151
1595/* YYNNTS -- Number of nonterminals. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001596#define YYNNTS 82
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001597/* YYNRULES -- Number of rules. */
1598#define YYNRULES 297
1599/* YYNRULES -- Number of states. */
1600#define YYNSTATES 581
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001601
1602/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1603#define YYUNDEFTOK 2
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001604#define YYMAXUTOK 391
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001605
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001606#define YYTRANSLATE(YYX) \
1607 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001608
1609/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001610static const yytype_uint8 yytranslate[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001611{
1612 0, 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,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001616 141, 142, 139, 2, 138, 2, 2, 2, 2, 2,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001618 146, 137, 147, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1620 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001621 2, 143, 140, 145, 2, 2, 2, 2, 2, 150,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1623 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001624 144, 2, 2, 148, 2, 149, 2, 2, 2, 2,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001625 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1626 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1627 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1628 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1629 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1630 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1631 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1633 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1637 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1638 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1639 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1640 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1641 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1642 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1643 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1644 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1645 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1646 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1647 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1648 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1649 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1650 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001651 135, 136
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001652};
1653
1654#if YYDEBUG
1655/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1656 YYRHS. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001657static const yytype_uint16 yyprhs[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001658{
1659 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1660 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1661 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1662 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1663 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1664 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1665 119, 121, 122, 125, 126, 128, 130, 132, 133, 136,
1666 138, 140, 142, 144, 146, 148, 150, 152, 153, 155,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001667 157, 159, 160, 162, 164, 165, 167, 169, 171, 173,
1668 174, 176, 178, 179, 181, 183, 185, 187, 189, 192,
1669 194, 196, 198, 200, 201, 204, 206, 208, 210, 211,
1670 214, 215, 218, 219, 223, 226, 227, 229, 230, 234,
1671 236, 239, 241, 243, 245, 247, 249, 251, 254, 256,
1672 259, 265, 271, 277, 283, 287, 290, 296, 301, 304,
1673 306, 308, 310, 314, 316, 320, 322, 323, 325, 329,
1674 334, 338, 342, 347, 352, 356, 363, 369, 372, 375,
1675 378, 381, 384, 387, 390, 393, 396, 399, 402, 405,
1676 412, 418, 427, 434, 441, 449, 457, 464, 473, 482,
1677 486, 488, 490, 492, 494, 495, 498, 505, 507, 508,
1678 510, 513, 514, 518, 519, 523, 527, 531, 535, 536,
1679 544, 545, 554, 555, 564, 570, 573, 577, 579, 583,
1680 587, 591, 595, 597, 598, 604, 608, 610, 614, 616,
1681 617, 627, 629, 631, 636, 638, 640, 643, 647, 648,
1682 650, 652, 654, 656, 658, 660, 662, 664, 666, 670,
1683 672, 678, 680, 682, 684, 686, 688, 690, 693, 696,
1684 699, 703, 706, 707, 709, 712, 715, 719, 729, 739,
1685 748, 763, 765, 767, 774, 780, 783, 790, 798, 802,
1686 808, 809, 810, 814, 817, 819, 825, 831, 838, 845,
1687 850, 857, 862, 867, 874, 881, 884, 893, 895, 897,
1688 898, 902, 909, 913, 920, 923, 929, 937
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001689};
1690
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001691/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1692static const yytype_int16 yyrhs[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001693{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001694 195, 0, -1, 69, -1, 70, -1, 71, -1, 72,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001695 -1, 73, -1, 74, -1, 75, -1, 76, -1, 77,
1696 -1, 81, -1, 82, -1, 83, -1, 78, -1, 79,
1697 -1, 80, -1, 112, -1, 113, -1, 114, -1, 115,
1698 -1, 116, -1, 117, -1, 118, -1, 119, -1, 120,
1699 -1, 121, -1, 122, -1, 123, -1, 86, -1, 87,
1700 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1701 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1702 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1703 -1, 103, -1, 104, -1, 105, -1, 92, -1, 93,
1704 -1, 94, -1, 95, -1, 22, -1, 23, -1, 11,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001705 -1, 12, -1, 13, -1, 16, -1, 19, -1, 159,
1706 -1, -1, 159, 137, -1, -1, 17, -1, 20, -1,
1707 164, -1, -1, 162, 137, -1, 38, -1, 40, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001708 39, -1, 41, -1, 43, -1, 42, -1, 44, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001709 46, -1, -1, 134, -1, 135, -1, 136, -1, -1,
1710 42, -1, 44, -1, -1, 38, -1, 39, -1, 40,
1711 -1, 43, -1, -1, 40, -1, 38, -1, -1, 57,
1712 -1, 58, -1, 59, -1, 60, -1, 61, -1, 56,
1713 4, -1, 113, -1, 114, -1, 131, -1, 132, -1,
1714 -1, 173, 172, -1, 130, -1, 133, -1, 172, -1,
1715 -1, 175, 174, -1, -1, 49, 4, -1, -1, 138,
1716 49, 4, -1, 30, 19, -1, -1, 178, -1, -1,
1717 138, 181, 180, -1, 178, -1, 49, 4, -1, 11,
1718 -1, 12, -1, 13, -1, 14, -1, 45, -1, 182,
1719 -1, 183, 139, -1, 217, -1, 140, 4, -1, 183,
1720 141, 187, 142, 175, -1, 10, 141, 187, 142, 175,
1721 -1, 143, 4, 144, 183, 145, -1, 146, 4, 144,
1722 183, 147, -1, 148, 188, 149, -1, 148, 149, -1,
1723 146, 148, 188, 149, 147, -1, 146, 148, 149, 147,
1724 -1, 183, 173, -1, 183, -1, 10, -1, 184, -1,
1725 186, 138, 184, -1, 186, -1, 186, 138, 35, -1,
1726 35, -1, -1, 183, -1, 188, 138, 183, -1, 183,
1727 143, 191, 145, -1, 183, 143, 145, -1, 183, 150,
1728 19, -1, 183, 146, 191, 147, -1, 183, 148, 191,
1729 149, -1, 183, 148, 149, -1, 183, 146, 148, 191,
1730 149, 147, -1, 183, 146, 148, 149, 147, -1, 183,
1731 36, -1, 183, 37, -1, 183, 217, -1, 183, 190,
1732 -1, 183, 21, -1, 157, 3, -1, 157, 5, -1,
1733 157, 4, -1, 157, 6, -1, 11, 22, -1, 11,
1734 23, -1, 158, 9, -1, 154, 141, 189, 34, 183,
1735 142, -1, 111, 141, 189, 228, 142, -1, 125, 141,
1736 189, 138, 189, 138, 189, 142, -1, 152, 141, 189,
1737 138, 189, 142, -1, 153, 141, 189, 138, 189, 142,
1738 -1, 84, 155, 141, 189, 138, 189, 142, -1, 85,
1739 156, 141, 189, 138, 189, 142, -1, 127, 141, 189,
1740 138, 189, 142, -1, 128, 141, 189, 138, 189, 138,
1741 189, 142, -1, 129, 141, 189, 138, 189, 138, 189,
1742 142, -1, 191, 138, 189, -1, 189, -1, 28, -1,
1743 29, -1, 33, -1, -1, 185, 217, -1, 117, 141,
1744 194, 34, 183, 142, -1, 196, -1, -1, 197, -1,
1745 196, 197, -1, -1, 27, 198, 213, -1, -1, 26,
1746 199, 214, -1, 54, 53, 203, -1, 161, 15, 183,
1747 -1, 161, 15, 10, -1, -1, 163, 167, 193, 192,
1748 189, 200, 180, -1, -1, 163, 165, 167, 193, 192,
1749 189, 201, 180, -1, -1, 163, 166, 167, 193, 192,
1750 183, 202, 180, -1, 163, 167, 31, 170, 194, -1,
1751 47, 204, -1, 50, 137, 205, -1, 19, -1, 48,
1752 137, 19, -1, 62, 137, 19, -1, 143, 206, 145,
1753 -1, 206, 138, 19, -1, 19, -1, -1, 207, 138,
1754 183, 173, 160, -1, 183, 173, 160, -1, 207, -1,
1755 207, 138, 35, -1, 35, -1, -1, 171, 185, 162,
1756 141, 208, 142, 175, 179, 176, -1, 24, -1, 148,
1757 -1, 169, 167, 209, 210, -1, 25, -1, 149, -1,
1758 220, 212, -1, 168, 167, 209, -1, -1, 55, -1,
1759 3, -1, 4, -1, 9, -1, 22, -1, 23, -1,
1760 36, -1, 37, -1, 21, -1, 146, 191, 147, -1,
1761 190, -1, 53, 215, 19, 138, 19, -1, 7, -1,
1762 8, -1, 159, -1, 162, -1, 217, -1, 216, -1,
1763 183, 218, -1, 220, 221, -1, 211, 221, -1, 222,
1764 161, 223, -1, 222, 225, -1, -1, 18, -1, 63,
1765 219, -1, 63, 10, -1, 64, 14, 218, -1, 64,
1766 11, 218, 138, 14, 218, 138, 14, 218, -1, 65,
1767 157, 218, 138, 14, 218, 143, 224, 145, -1, 65,
1768 157, 218, 138, 14, 218, 143, 145, -1, 66, 171,
1769 185, 218, 141, 227, 142, 175, 34, 14, 218, 67,
1770 14, 218, -1, 67, -1, 68, -1, 224, 157, 216,
1771 138, 14, 218, -1, 157, 216, 138, 14, 218, -1,
1772 161, 230, -1, 183, 143, 218, 138, 218, 145, -1,
1773 226, 138, 143, 218, 138, 218, 145, -1, 183, 218,
1774 173, -1, 227, 138, 183, 218, 173, -1, -1, -1,
1775 228, 138, 219, -1, 52, 51, -1, 51, -1, 152,
1776 183, 218, 138, 218, -1, 153, 183, 218, 138, 218,
1777 -1, 84, 155, 183, 218, 138, 218, -1, 85, 156,
1778 183, 218, 138, 218, -1, 154, 219, 34, 183, -1,
1779 125, 219, 138, 219, 138, 219, -1, 126, 219, 138,
1780 183, -1, 127, 219, 138, 219, -1, 128, 219, 138,
1781 219, 138, 219, -1, 129, 219, 138, 219, 138, 219,
1782 -1, 124, 226, -1, 229, 171, 185, 218, 141, 227,
1783 142, 175, -1, 232, -1, 32, -1, -1, 106, 183,
1784 177, -1, 106, 183, 138, 11, 218, 177, -1, 107,
1785 183, 177, -1, 107, 183, 138, 11, 218, 177, -1,
1786 108, 219, -1, 231, 109, 183, 218, 177, -1, 231,
1787 110, 219, 138, 183, 218, 177, -1, 111, 183, 218,
1788 228, -1
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001789};
1790
1791/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001792static const yytype_uint16 yyrline[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001793{
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001794 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1795 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001796 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117,
Reid Spencer9c9b63a2007-04-28 16:07:31 +00001797 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125,
1798 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130,
1799 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1141, 1141,
1800 1142, 1142, 1146, 1150, 1155, 1155, 1157, 1158, 1163, 1169,
1801 1170, 1171, 1172, 1173, 1177, 1178, 1179, 1183, 1184, 1185,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001802 1186, 1190, 1191, 1192, 1196, 1197, 1198, 1199, 1200, 1204,
1803 1205, 1206, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1222,
1804 1223, 1224, 1225, 1228, 1229, 1234, 1235, 1236, 1239, 1240,
1805 1247, 1248, 1254, 1255, 1263, 1271, 1272, 1277, 1278, 1279,
1806 1284, 1297, 1297, 1297, 1297, 1300, 1304, 1308, 1315, 1320,
1807 1328, 1358, 1389, 1394, 1406, 1416, 1420, 1430, 1437, 1444,
1808 1451, 1456, 1461, 1468, 1469, 1476, 1483, 1491, 1497, 1509,
1809 1537, 1553, 1582, 1610, 1636, 1656, 1682, 1702, 1714, 1721,
1810 1787, 1797, 1807, 1813, 1823, 1829, 1839, 1844, 1849, 1857,
1811 1869, 1891, 1899, 1905, 1916, 1921, 1926, 1932, 1938, 1947,
1812 1951, 1959, 1959, 1962, 1962, 1965, 1976, 1997, 2002, 2010,
1813 2011, 2015, 2015, 2019, 2019, 2022, 2025, 2049, 2060, 2060,
1814 2071, 2070, 2080, 2079, 2090, 2105, 2108, 2114, 2127, 2131,
1815 2136, 2138, 2143, 2148, 2157, 2167, 2178, 2182, 2191, 2200,
1816 2205, 2327, 2327, 2329, 2338, 2338, 2340, 2345, 2357, 2361,
1817 2366, 2370, 2374, 2378, 2382, 2386, 2390, 2394, 2398, 2423,
1818 2427, 2441, 2445, 2449, 2453, 2459, 2459, 2465, 2474, 2478,
1819 2487, 2496, 2505, 2509, 2514, 2518, 2522, 2527, 2537, 2556,
1820 2565, 2645, 2649, 2656, 2667, 2680, 2690, 2701, 2711, 2720,
1821 2729, 2732, 2733, 2740, 2744, 2749, 2770, 2787, 2801, 2815,
1822 2827, 2835, 2842, 2848, 2854, 2860, 2875, 2960, 2965, 2969,
1823 2976, 2983, 2991, 2998, 3006, 3014, 3028, 3045
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001824};
1825#endif
1826
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001827#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1828/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1829 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001830static const char *const yytname[] =
1831{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001832 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1833 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1834 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1835 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1836 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1837 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1838 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1839 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1840 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1841 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1842 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1843 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1844 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1845 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1846 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1847 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1848 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1849 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1850 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1851 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET",
1852 "NOUNWIND", "DEFAULT", "HIDDEN", "PROTECTED", "'='", "','", "'*'",
1853 "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'",
1854 "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps",
1855 "IPredicates", "FPredicates", "IntType", "FPType", "LocalName",
1856 "OptLocalName", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
1857 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1858 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1859 "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1860 "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString",
1861 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1862 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1863 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1864 "ThreadLocal", "AliaseeRef", "Module", "DefinitionList", "Definition",
1865 "@1", "@2", "@3", "@4", "@5", "AsmBlock", "TargetDefinition",
1866 "LibrariesDefinition", "LibList", "ArgListH", "ArgList",
1867 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1868 "FunctionProto", "OptSideEffect", "ConstValueRef", "SymbolicValueRef",
1869 "ValueRef", "ResolvedVal", "BasicBlockList", "BasicBlock",
1870 "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
1871 "ValueRefList", "IndexList", "OptTailCall", "InstVal", "OptVolatile",
1872 "MemoryInst", 0
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001873};
1874#endif
1875
1876# ifdef YYPRINT
1877/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1878 token YYLEX-NUM. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001879static const yytype_uint16 yytoknum[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001880{
1881 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1882 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1883 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1884 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1885 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1886 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1887 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1888 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1889 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1890 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1891 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1892 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1893 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001894 385, 386, 387, 388, 389, 390, 391, 61, 44, 42,
1895 92, 40, 41, 91, 120, 93, 60, 62, 123, 125,
1896 99
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001897};
1898# endif
1899
1900/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001901static const yytype_uint8 yyr1[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001902{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001903 0, 151, 152, 152, 152, 152, 152, 152, 152, 152,
1904 152, 153, 153, 153, 153, 153, 153, 154, 154, 154,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001905 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001906 155, 155, 155, 155, 155, 155, 155, 155, 155, 156,
1907 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
1908 156, 156, 156, 156, 156, 157, 158, 158, 159, 159,
1909 160, 160, 161, 161, 162, 162, 163, 163, 164, 165,
1910 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
1911 167, 168, 168, 168, 169, 169, 169, 169, 169, 170,
1912 170, 170, 171, 171, 171, 171, 171, 171, 171, 172,
1913 172, 172, 172, 173, 173, 174, 174, 174, 175, 175,
1914 176, 176, 177, 177, 178, 179, 179, 180, 180, 181,
1915 181, 182, 182, 182, 182, 183, 183, 183, 183, 183,
1916 183, 183, 183, 183, 183, 183, 183, 183, 184, 185,
1917 185, 186, 186, 187, 187, 187, 187, 188, 188, 189,
1918 189, 189, 189, 189, 189, 189, 189, 189, 189, 189,
1919 189, 189, 189, 189, 189, 189, 189, 189, 189, 190,
1920 190, 190, 190, 190, 190, 190, 190, 190, 190, 191,
1921 191, 192, 192, 193, 193, 194, 194, 195, 195, 196,
1922 196, 198, 197, 199, 197, 197, 197, 197, 200, 197,
1923 201, 197, 202, 197, 197, 197, 197, 203, 204, 204,
1924 205, 206, 206, 206, 207, 207, 208, 208, 208, 208,
1925 209, 210, 210, 211, 212, 212, 213, 214, 215, 215,
1926 216, 216, 216, 216, 216, 216, 216, 216, 216, 216,
1927 216, 217, 217, 217, 217, 218, 218, 219, 220, 220,
1928 221, 222, 222, 222, 223, 223, 223, 223, 223, 223,
1929 223, 223, 223, 224, 224, 225, 226, 226, 227, 227,
1930 227, 228, 228, 229, 229, 230, 230, 230, 230, 230,
1931 230, 230, 230, 230, 230, 230, 230, 230, 231, 231,
1932 232, 232, 232, 232, 232, 232, 232, 232
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001933};
1934
1935/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001936static const yytype_uint8 yyr2[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001937{
1938 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1939 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1940 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1941 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1942 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1943 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1944 1, 0, 2, 0, 1, 1, 1, 0, 2, 1,
1945 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001946 1, 0, 1, 1, 0, 1, 1, 1, 1, 0,
1947 1, 1, 0, 1, 1, 1, 1, 1, 2, 1,
1948 1, 1, 1, 0, 2, 1, 1, 1, 0, 2,
1949 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1950 2, 1, 1, 1, 1, 1, 1, 2, 1, 2,
1951 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
1952 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
1953 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
1954 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
1955 5, 8, 6, 6, 7, 7, 6, 8, 8, 3,
1956 1, 1, 1, 1, 0, 2, 6, 1, 0, 1,
1957 2, 0, 3, 0, 3, 3, 3, 3, 0, 7,
1958 0, 8, 0, 8, 5, 2, 3, 1, 3, 3,
1959 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
1960 9, 1, 1, 4, 1, 1, 2, 3, 0, 1,
1961 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1962 5, 1, 1, 1, 1, 1, 1, 2, 2, 2,
1963 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1964 14, 1, 1, 6, 5, 2, 6, 7, 3, 5,
1965 0, 0, 3, 2, 1, 5, 5, 6, 6, 4,
1966 6, 4, 4, 6, 6, 2, 8, 1, 1, 0,
1967 3, 6, 3, 6, 2, 5, 7, 4
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001968};
1969
1970/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1971 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1972 means the default is an error. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001973static const yytype_uint16 yydefact[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001974{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001975 67, 58, 64, 59, 65, 193, 191, 0, 0, 0,
1976 0, 0, 0, 77, 66, 0, 67, 189, 81, 84,
1977 0, 0, 205, 0, 0, 62, 0, 68, 69, 71,
1978 70, 72, 74, 73, 75, 76, 78, 79, 80, 77,
1979 77, 184, 1, 190, 82, 83, 77, 194, 85, 86,
1980 87, 88, 77, 252, 192, 252, 0, 0, 213, 206,
1981 207, 195, 241, 242, 197, 121, 122, 123, 124, 125,
1982 0, 0, 0, 0, 243, 244, 126, 196, 128, 184,
1983 184, 89, 183, 0, 92, 92, 253, 249, 63, 224,
1984 225, 226, 248, 208, 209, 212, 0, 146, 129, 0,
1985 0, 0, 0, 135, 147, 0, 127, 146, 0, 0,
1986 91, 90, 0, 181, 182, 0, 0, 93, 94, 95,
1987 96, 97, 0, 227, 0, 289, 251, 0, 210, 145,
1988 103, 141, 143, 0, 0, 0, 0, 0, 0, 134,
1989 0, 0, 0, 140, 0, 139, 0, 204, 121, 122,
1990 123, 0, 0, 0, 198, 98, 0, 221, 222, 223,
1991 288, 274, 0, 0, 0, 0, 92, 261, 262, 2,
1992 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
1993 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
1994 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1995 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
1996 0, 250, 92, 265, 0, 287, 211, 138, 0, 108,
1997 0, 0, 137, 0, 148, 108, 200, 202, 0, 185,
1998 166, 167, 162, 164, 163, 165, 168, 161, 157, 158,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002000 0, 0, 0, 0, 160, 159, 117, 0, 273, 255,
2001 0, 254, 0, 0, 55, 0, 0, 29, 30, 31,
2002 32, 33, 34, 35, 36, 37, 38, 0, 53, 54,
2003 49, 50, 51, 52, 39, 40, 41, 42, 43, 44,
2004 45, 46, 47, 48, 0, 112, 112, 294, 0, 0,
2005 285, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2006 0, 0, 99, 100, 101, 102, 104, 144, 142, 131,
2007 132, 133, 136, 130, 117, 117, 0, 0, 0, 0,
2008 0, 0, 0, 0, 150, 180, 0, 0, 0, 154,
2009 0, 151, 0, 0, 0, 0, 199, 219, 230, 231,
2010 232, 237, 233, 234, 235, 236, 228, 0, 239, 246,
2011 245, 247, 0, 256, 0, 0, 0, 0, 0, 290,
2012 0, 292, 271, 0, 0, 0, 0, 0, 0, 0,
2013 0, 0, 0, 0, 0, 0, 105, 106, 107, 109,
2014 201, 203, 0, 0, 0, 271, 0, 0, 0, 0,
2015 0, 149, 135, 147, 0, 152, 153, 0, 0, 0,
2016 0, 0, 119, 117, 218, 103, 216, 0, 229, 0,
2017 0, 0, 0, 0, 0, 0, 0, 0, 0, 297,
2018 0, 0, 0, 281, 282, 0, 0, 0, 0, 279,
2019 0, 112, 0, 0, 0, 0, 0, 0, 0, 0,
2020 0, 179, 156, 0, 0, 0, 0, 114, 120, 118,
2021 61, 0, 108, 0, 238, 0, 0, 270, 0, 0,
2022 112, 113, 112, 0, 0, 0, 0, 0, 0, 275,
2023 276, 270, 0, 295, 0, 186, 0, 0, 170, 0,
2024 0, 0, 0, 155, 0, 0, 0, 60, 215, 217,
2025 103, 115, 0, 0, 0, 0, 0, 277, 278, 291,
2026 293, 272, 0, 0, 280, 283, 284, 0, 112, 0,
2027 0, 0, 176, 0, 0, 172, 173, 169, 61, 116,
2028 110, 240, 0, 0, 103, 0, 108, 266, 0, 108,
2029 296, 174, 175, 0, 0, 0, 214, 0, 220, 0,
2030 259, 0, 0, 268, 0, 0, 267, 286, 171, 177,
2031 178, 111, 257, 0, 258, 0, 103, 0, 0, 0,
2032 269, 0, 0, 0, 0, 264, 0, 0, 263, 0,
2033 260
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002034};
2035
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002036/* YYDEFGOTO[NTERM-NUM]. */
2037static const yytype_int16 yydefgoto[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002038{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002039 -1, 251, 252, 253, 277, 294, 151, 152, 74, 498,
2040 11, 75, 13, 14, 39, 40, 41, 46, 52, 112,
2041 122, 316, 217, 389, 319, 548, 369, 412, 530, 346,
2042 413, 76, 153, 131, 146, 132, 133, 105, 335, 358,
2043 336, 115, 83, 147, 15, 16, 17, 19, 18, 256,
2044 324, 325, 61, 22, 59, 96, 416, 417, 123, 159,
2045 53, 91, 54, 47, 419, 359, 78, 361, 261, 55,
2046 87, 88, 211, 552, 126, 300, 506, 429, 212, 213,
2047 214, 215
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002048};
2049
2050/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2051 STATE-NUM. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002052#define YYPACT_NINF -460
2053static const yytype_int16 yypact[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002054{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002055 30, -460, -460, -460, -460, -460, -460, -4, -118, 45,
2056 -108, 70, 36, 432, -460, 151, 558, -460, 148, 200,
2057 49, 71, -460, 82, 150, -460, 1184, -460, -460, -460,
2058 -460, -460, -460, -460, -460, -460, -460, -460, -460, 189,
2059 189, 250, -460, -460, -460, -460, 189, -460, -460, -460,
2060 -460, -460, 189, 196, -460, -14, 239, 248, 277, -460,
2061 -460, -460, -460, -460, 129, -460, -460, -460, -460, -460,
2062 307, 313, 4, 368, -460, -460, -460, 192, -460, 295,
2063 295, 294, -460, 26, 163, 163, -460, -460, 155, -460,
2064 -460, -460, -460, -460, -460, -460, -114, 54, -460, 194,
2065 195, 932, 129, -460, 192, -117, -460, 54, 26, 26,
2066 -460, -460, 1028, -460, -460, 1198, 336, -460, -460, -460,
2067 -460, -460, 1225, -460, -6, 1362, -460, 322, -460, -460,
2068 192, -460, 204, 201, 1240, 1240, 197, -55, 1240, -460,
2069 205, 1198, 1240, 129, 207, 192, 88, -460, 97, 337,
2070 340, 274, 346, 757, -460, -460, 184, -460, -460, -460,
2071 -460, -460, 305, 1261, 251, 349, 163, -460, -460, -460,
2072 -460, -460, -460, -460, -460, -460, -460, -460, -460, -460,
2073 -460, -460, -460, -460, 395, 443, 1240, 1240, 1240, 1240,
2074 -460, -460, -460, -460, -460, -460, -460, -460, -460, -460,
2075 -460, -460, 1240, 1240, 1240, 1240, 1240, 1240, 1240, 1240,
2076 1240, -460, 163, -460, 137, -460, -460, -80, 120, -460,
2077 31, 109, -460, 215, 192, -460, -460, 192, 1028, -460,
2078 -460, -460, -460, -460, -460, -460, -460, -460, -460, -460,
2079 395, 443, 222, 227, 228, 231, 232, 1042, 1276, 973,
2080 358, 242, 245, 249, -460, -460, 253, 252, -460, 129,
2081 607, -460, 735, 735, -460, 735, 1225, -460, -460, -460,
2082 -460, -460, -460, -460, -460, -460, -460, 1240, -460, -460,
2083 -460, -460, -460, -460, -460, -460, -460, -460, -460, -460,
2084 -460, -460, -460, -460, 1240, 152, 156, -460, 607, 118,
2085 254, 258, 259, 260, 261, 262, 607, 607, 361, 1225,
2086 1240, 1240, -460, -460, -460, -460, -460, -460, -460, 99,
2087 -460, -460, -460, 99, 253, 253, 367, 263, 264, 1198,
2088 1198, 1198, 1198, 1198, -460, -460, -85, 1012, 3, -460,
2089 -27, -460, 1198, 1198, 1198, 29, -460, 1082, -460, -460,
2090 -460, -460, -460, -460, -460, -460, 351, 1198, -460, -460,
2091 -460, -460, 269, -460, 270, 735, 607, 607, 14, -460,
2092 32, -460, -460, 735, 266, 1240, 1240, 1240, 1240, 1240,
2093 273, 276, 1240, 735, 607, 278, -460, -460, -460, -460,
2094 -460, -460, 1240, 1198, 1198, -460, 284, 285, 286, 289,
2095 1198, -460, 265, 757, 9, -460, -460, 290, 291, 396,
2096 415, 431, -460, 253, -460, 192, 300, 297, -460, 422,
2097 7, 429, 430, 304, 308, 309, 735, 445, 735, 312,
2098 316, 735, 317, 192, -460, 321, 326, 735, 735, 192,
2099 327, 329, 1240, 94, 339, 353, -63, 1198, 1198, 1198,
2100 1198, -460, -460, 350, 1198, 1198, 1240, -460, -460, -460,
2101 74, 1118, -460, 355, -460, 735, 735, 1240, 735, 735,
2102 329, -460, 329, 1240, 735, 360, 1240, 1240, 1240, -460,
2103 -460, 1240, 447, -460, 607, -460, 1198, 1198, -460, 362,
2104 357, 363, 364, -460, 365, 370, 179, -460, -460, -460,
2105 192, 85, 484, 366, 372, 607, -24, -460, -460, -460,
2106 -460, -460, 373, 735, -460, -460, -460, 6, 329, 371,
2107 377, 1198, -460, 1198, 1198, -460, -460, -460, 74, -460,
2108 456, -460, 492, 1, -460, 1240, -460, -460, 375, -460,
2109 -460, -460, -460, 379, 381, 383, -460, 505, -460, 735,
2110 -460, 888, 11, -80, 607, 141, -460, 99, -460, -460,
2111 -460, -460, -460, 388, -460, 888, -460, 515, 516, 393,
2112 -80, 735, 735, 518, 482, -460, 735, 536, -460, 735,
2113 -460
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002114};
2115
2116/* YYPGOTO[NTERM-NUM]. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002117static const yytype_int16 yypgoto[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002118{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002119 -460, 426, 427, 428, 314, 315, -163, -460, 0, 27,
2120 469, 10, -460, -460, -460, -460, 236, -460, -460, -460,
2121 -143, -306, -409, -460, -220, -460, -281, 58, -460, -297,
2122 -460, -460, -25, 342, -113, -460, 462, 470, -29, -150,
2123 -208, 198, 257, 335, -460, -460, 556, -460, -460, -460,
2124 -460, -460, -460, -460, -460, -460, -460, -460, 491, -460,
2125 -460, -460, -460, -460, -460, -459, -139, 96, -168, -460,
2126 524, -460, -460, -460, -460, -460, 100, 187, -460, -460,
2127 -460, -460
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002128};
2129
2130/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2131 positive, shift that token. If negative, reduce the rule which
2132 number is the opposite. If zero, do what YYDEFACT says.
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002133 If YYTABLE_NINF, syntax error. */
2134#define YYTABLE_NINF -189
2135static const yytype_int16 yytable[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002136{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002137 10, 77, 265, 254, 86, 323, 460, 229, 100, 156,
2138 12, 89, 264, 388, 255, 371, 10, 388, 157, 23,
2139 297, 138, 264, 266, 127, 426, 12, 390, 391, 25,
2140 -188, 128, 139, 312, 313, 301, 302, 303, 304, 305,
2141 338, 340, 308, 428, 20, -63, 1, 2, 104, 3,
2142 4, 314, 315, 400, 113, 114, 5, 6, 21, 410,
2143 401, 62, 63, 427, 102, 65, 66, 67, 68, 309,
2144 1, 2, 130, 3, 4, 473, 104, 7, 411, 488,
2145 8, 427, 130, 138, 9, 26, 154, 145, 10, 129,
2146 1, 528, 563, 3, 223, 62, 63, 145, 24, 69,
2147 -55, -55, -55, -55, 1, 2, 569, 3, 4, 220,
2148 221, 400, 226, 224, 535, 410, 459, 227, 536, 230,
2149 231, 360, 406, 360, 360, 553, 360, 62, 63, 404,
2150 102, 65, 66, 67, 68, 90, 1, 2, 260, 3,
2151 4, 400, 158, 385, 535, 400, 550, 400, 539, 420,
2152 405, 42, 101, 365, 464, 317, 564, 570, 453, 360,
2153 483, 295, 296, 260, 298, 69, 257, 360, 360, 60,
2154 106, 1, 107, 27, 3, 567, 320, 299, 260, 260,
2155 260, 260, 260, 306, 307, 260, 56, 312, 313, 509,
2156 44, 510, 45, 130, 70, 388, 383, 71, 312, 313,
2157 72, 2, 73, 145, 4, 314, 315, 432, 57, 434,
2158 435, 436, 312, 313, 86, 386, 314, 315, 387, 116,
2159 117, 118, 119, 120, 121, 58, 360, 360, 360, 386,
2160 314, 315, 387, 106, 360, 107, 485, 540, 48, 49,
2161 50, 145, 501, 51, 360, 360, 310, 311, 106, 388,
2162 107, 388, 366, 254, 312, 313, 321, 106, 93, 107,
2163 70, 373, 262, 71, 255, 263, 72, 94, 73, 367,
2164 97, 386, 314, 315, 387, 79, 80, 232, 233, 234,
2165 235, 81, 84, 82, 145, 384, 260, 360, 85, 360,
2166 368, 106, 360, 107, 370, 106, 95, 107, 360, 360,
2167 395, 396, 397, 398, 399, 511, 141, 142, 514, 515,
2168 516, 98, 403, 407, 408, 409, 555, 99, 106, 557,
2169 107, 527, 415, 36, 37, 38, 360, 360, 82, 360,
2170 360, 106, 110, 107, 111, 360, 108, 109, 134, 135,
2171 155, 216, 218, 219, 222, 360, -56, 225, 228, -57,
2172 260, 433, 260, 260, 260, 236, 258, 439, 362, 363,
2173 264, 364, 322, 329, 444, 445, 360, 443, 330, 331,
2174 551, 451, 332, 333, 360, 62, 63, 341, 102, 65,
2175 66, 67, 68, 342, 1, 2, 343, 3, 4, 565,
2176 344, 345, 374, 347, 372, 382, 375, 376, 377, 378,
2177 379, 392, 380, 381, 393, 394, 418, 421, 422, 431,
2178 360, 437, 452, 69, 438, 360, 442, 484, 489, 490,
2179 491, 492, 447, 448, 449, 494, 495, 450, 454, 455,
2180 456, 496, 360, 360, 457, 458, 500, 360, 461, 462,
2181 360, 463, 505, 465, 466, 467, 468, 469, 260, 471,
2182 473, 260, 260, 260, 474, 476, 505, 519, 520, 477,
2183 497, 423, 424, 425, 478, 278, 279, 482, 481, 430,
2184 28, 29, 30, 31, 32, 33, 34, 486, 35, 440,
2185 441, 267, 268, 269, 270, 271, 272, 273, 274, 275,
2186 276, 487, 543, 502, 544, 545, 427, 493, 513, 522,
2187 521, 523, 524, 531, 532, 547, 549, 525, 70, 561,
2188 554, 71, 526, 541, 72, 533, 73, 103, 537, 542,
2189 556, 558, 470, 559, 472, 560, 568, 475, 497, 571,
2190 572, 573, 576, 479, 480, 280, 281, 282, 283, 284,
2191 285, 286, 287, 288, 289, 290, 291, 292, 293, 577,
2192 579, 208, 209, 210, 327, 546, 328, 125, -187, 529,
2193 318, 503, 504, 326, 507, 508, 36, 37, 38, 140,
2194 512, 137, 43, -63, 1, 2, 124, 3, 4, 92,
2195 518, 517, 446, 0, 5, 6, 0, 0, 0, 0,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002197 0, 534, 0, 0, 0, 7, 0, 0, 8, 538,
2198 348, 349, 9, 0, 62, 63, 350, 0, 0, 0,
2199 0, 0, 0, 1, 2, 0, 3, 4, 351, 352,
2200 353, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2201 0, 0, 0, 354, 355, 562, 0, 0, 0, 0,
2202 566, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2203 356, 0, 0, 0, 0, 0, 0, 574, 575, 0,
2204 0, 0, 578, 0, 0, 580, 169, 170, 171, 172,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002205 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002206 183, 240, 241, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002208 0, 0, 0, 0, 0, 0, 0, 0, 242, 190,
2209 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2210 201, 0, 243, 0, 244, 245, 246, 0, 348, 349,
2211 0, 0, 62, 63, 350, 0, 106, 0, 107, 0,
2212 0, 1, 2, 357, 3, 4, 351, 352, 353, 0,
2213 0, 0, 0, 0, 62, 63, 0, 0, 0, 0,
2214 0, 354, 355, 1, 2, 0, 3, 4, 237, 0,
2215 0, 0, 0, 0, 0, 0, 0, 0, 356, 0,
2216 0, 0, 0, 238, 239, 0, 0, 0, 0, 0,
2217 0, 0, 0, 0, 169, 170, 171, 172, 173, 174,
2218 175, 176, 177, 178, 179, 180, 181, 182, 183, 240,
2219 241, 0, 0, 0, 0, 0, 169, 170, 171, 172,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002220 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002221 183, 240, 241, 0, 0, 0, 242, 190, 191, 192,
2222 193, 194, 195, 196, 197, 198, 199, 200, 201, 0,
2223 243, 0, 244, 245, 246, 0, 0, 0, 242, 190,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002224 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002225 201, 357, 243, 0, 244, 245, 246, 0, 0, 0,
2226 0, 348, 349, 0, 0, 0, 106, 350, 107, 0,
2227 247, 0, 0, 248, 0, 249, 0, 250, 0, 351,
2228 352, 353, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 0, 0, 354, 355, 0, 0, 0, 0,
2230 0, 0, 0, 0, 0, 0, 0, 0, 0, 62,
2231 63, 356, 102, 65, 66, 67, 68, 0, 1, 2,
2232 0, 3, 4, 0, 0, 0, 0, 169, 170, 171,
2233 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
2234 182, 183, 240, 241, 0, 0, 0, 69, 0, 0,
2235 62, 63, 0, 102, 148, 149, 150, 68, 0, 1,
2236 2, 0, 3, 4, 0, 0, 0, 0, 0, 242,
2237 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
2238 200, 201, 0, 243, 0, 244, 245, 246, 69, 62,
2239 63, 0, 102, 148, 149, 150, 68, 0, 1, 2,
2240 0, 3, 4, 0, 357, 62, 63, 0, 143, 65,
2241 66, 67, 68, 0, 1, 2, 0, 3, 4, 62,
2242 63, 0, 102, 148, 149, 150, 68, 69, 1, 2,
2243 0, 3, 4, 0, 0, 0, 0, 0, 0, 0,
2244 0, 0, 70, 69, 0, 71, 0, 0, 72, 0,
2245 73, 136, 0, 0, 0, 0, 0, 69, 0, 62,
2246 63, 0, 102, 65, 66, 67, 68, 0, 1, 2,
2247 0, 3, 4, 0, 0, 0, 0, 0, 0, 0,
2248 0, 0, 0, 70, 0, 0, 71, 414, 0, 72,
2249 0, 73, 339, 0, 0, 62, 63, 69, 102, 65,
2250 66, 67, 68, 0, 1, 2, 0, 3, 4, 0,
2251 0, 0, 0, 0, 0, 144, 0, 0, 0, 0,
2252 0, 0, 70, 499, 0, 71, 0, 0, 72, 0,
2253 73, 402, 0, 69, 0, 0, 0, 0, 70, 0,
2254 0, 71, 0, 0, 72, 0, 73, 0, 0, 0,
2255 0, 0, 70, 0, 0, 71, 0, 334, 72, 0,
2256 73, 62, 63, 0, 64, 65, 66, 67, 68, 0,
2257 1, 2, 0, 3, 4, 62, 63, 0, 102, 148,
2258 149, 150, 68, 0, 1, 2, 0, 3, 4, 0,
2259 0, 0, 70, 0, 0, 71, 0, 0, 72, 69,
2260 73, 0, 62, 63, 0, 143, 65, 66, 67, 68,
2261 0, 1, 2, 69, 3, 4, 0, 62, 63, 0,
2262 102, 65, 66, 67, 68, 0, 1, 2, 70, 3,
2263 4, 71, 0, 0, 72, 0, 73, 0, 62, 63,
2264 69, 259, 65, 66, 67, 68, 0, 1, 2, 0,
2265 3, 4, 0, 62, 63, 69, 102, 148, 149, 150,
2266 68, 0, 1, 2, 0, 3, 4, 0, 0, 0,
2267 0, 0, 0, 0, 0, 0, 69, 0, 0, 0,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002269 0, 69, 0, 0, 70, 0, 0, 71, 0, 0,
2270 72, 0, 73, 0, 0, 0, 0, 0, 70, 0,
2271 0, 71, 0, 0, 72, 0, 73, 0, 0, 0,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002272 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002273 0, 0, 0, 0, 0, 70, 0, 0, 71, 0,
2274 0, 72, 0, 73, 0, 0, 0, 0, 0, 0,
2275 70, 0, 0, 71, 0, 0, 72, 0, 73, 0,
2276 0, 0, 0, 0, 160, 0, 0, 0, 0, 0,
2277 0, 70, 0, 0, 71, 0, 0, 72, 0, 73,
2278 0, 0, 0, 161, 162, 0, 70, 0, 0, 71,
2279 0, 0, 72, 0, 337, 163, 164, 165, 166, 167,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002280 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002281 178, 179, 180, 181, 182, 183, 184, 185, 0, 0,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002283 0, 0, 0, 0, 0, 0, 0, 0, 186, 187,
2284 188, 0, 0, 189, 190, 191, 192, 193, 194, 195,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002285 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002286 206, 207
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002287};
2288
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002289static const yytype_int16 yycheck[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002290{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002291 0, 26, 165, 153, 18, 225, 415, 146, 4, 122,
2292 0, 25, 11, 319, 153, 296, 16, 323, 24, 137,
2293 188, 138, 11, 166, 138, 11, 16, 324, 325, 137,
2294 0, 145, 149, 113, 114, 203, 204, 205, 206, 207,
2295 248, 249, 210, 11, 48, 15, 16, 17, 73, 19,
2296 20, 131, 132, 138, 28, 29, 26, 27, 62, 30,
2297 145, 7, 8, 49, 10, 11, 12, 13, 14, 212,
2298 16, 17, 97, 19, 20, 138, 101, 47, 49, 142,
2299 50, 49, 107, 138, 54, 15, 115, 112, 88, 35,
2300 16, 500, 551, 19, 149, 7, 8, 122, 53, 45,
2301 3, 4, 5, 6, 16, 17, 565, 19, 20, 134,
2302 135, 138, 141, 138, 138, 30, 413, 142, 142, 22,
2303 23, 260, 149, 262, 263, 534, 265, 7, 8, 337,
2304 10, 11, 12, 13, 14, 149, 16, 17, 163, 19,
2305 20, 138, 148, 311, 138, 138, 145, 138, 142, 357,
2306 147, 0, 148, 266, 147, 35, 145, 566, 149, 298,
2307 441, 186, 187, 188, 189, 45, 156, 306, 307, 19,
2308 139, 16, 141, 137, 19, 34, 145, 202, 203, 204,
2309 205, 206, 207, 208, 209, 210, 137, 113, 114, 470,
2310 42, 472, 44, 218, 140, 501, 309, 143, 113, 114,
2311 146, 17, 148, 228, 20, 131, 132, 375, 137, 377,
2312 378, 379, 113, 114, 18, 130, 131, 132, 133, 56,
2313 57, 58, 59, 60, 61, 143, 365, 366, 367, 130,
2314 131, 132, 133, 139, 373, 141, 142, 518, 38, 39,
2315 40, 266, 462, 43, 383, 384, 109, 110, 139, 555,
2316 141, 557, 277, 403, 113, 114, 147, 139, 19, 141,
2317 140, 143, 11, 143, 403, 14, 146, 19, 148, 294,
2318 141, 130, 131, 132, 133, 39, 40, 3, 4, 5,
2319 6, 31, 46, 33, 309, 310, 311, 426, 52, 428,
2320 138, 139, 431, 141, 138, 139, 19, 141, 437, 438,
2321 329, 330, 331, 332, 333, 473, 108, 109, 476, 477,
2322 478, 4, 337, 342, 343, 344, 536, 4, 139, 539,
2323 141, 142, 347, 134, 135, 136, 465, 466, 33, 468,
2324 469, 139, 38, 141, 40, 474, 79, 80, 144, 144,
2325 4, 19, 138, 142, 147, 484, 9, 142, 141, 9,
2326 375, 376, 377, 378, 379, 9, 51, 382, 262, 263,
2327 11, 265, 147, 141, 393, 394, 505, 392, 141, 141,
2328 533, 400, 141, 141, 513, 7, 8, 19, 10, 11,
2329 12, 13, 14, 141, 16, 17, 141, 19, 20, 552,
2330 141, 138, 138, 141, 298, 34, 138, 138, 138, 138,
2331 138, 34, 306, 307, 141, 141, 55, 138, 138, 143,
2332 549, 138, 147, 45, 138, 554, 138, 442, 447, 448,
2333 449, 450, 138, 138, 138, 454, 455, 138, 138, 138,
2334 34, 456, 571, 572, 19, 4, 461, 576, 138, 142,
2335 579, 19, 467, 14, 14, 141, 138, 138, 473, 4,
2336 138, 476, 477, 478, 138, 138, 481, 486, 487, 138,
2337 460, 365, 366, 367, 138, 22, 23, 138, 141, 373,
2338 38, 39, 40, 41, 42, 43, 44, 138, 46, 383,
2339 384, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2340 95, 138, 521, 138, 523, 524, 49, 147, 138, 142,
2341 138, 138, 138, 19, 138, 49, 14, 142, 140, 4,
2342 535, 143, 142, 142, 146, 143, 148, 149, 145, 142,
2343 145, 142, 426, 142, 428, 142, 138, 431, 528, 14,
2344 14, 138, 14, 437, 438, 92, 93, 94, 95, 96,
2345 97, 98, 99, 100, 101, 102, 103, 104, 105, 67,
2346 14, 125, 125, 125, 240, 528, 241, 88, 0, 501,
2347 218, 465, 466, 228, 468, 469, 134, 135, 136, 107,
2348 474, 101, 16, 15, 16, 17, 85, 19, 20, 55,
2349 484, 481, 395, -1, 26, 27, -1, -1, -1, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002350 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002351 -1, 505, -1, -1, -1, 47, -1, -1, 50, 513,
2352 3, 4, 54, -1, 7, 8, 9, -1, -1, -1,
2353 -1, -1, -1, 16, 17, -1, 19, 20, 21, 22,
2354 23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2355 -1, -1, -1, 36, 37, 549, -1, -1, -1, -1,
2356 554, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2357 53, -1, -1, -1, -1, -1, -1, 571, 572, -1,
2358 -1, -1, 576, -1, -1, 579, 69, 70, 71, 72,
2359 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2360 83, 84, 85, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002361 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002362 -1, -1, -1, -1, -1, -1, -1, -1, 111, 112,
2363 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2364 123, -1, 125, -1, 127, 128, 129, -1, 3, 4,
2365 -1, -1, 7, 8, 9, -1, 139, -1, 141, -1,
2366 -1, 16, 17, 146, 19, 20, 21, 22, 23, -1,
2367 -1, -1, -1, -1, 7, 8, -1, -1, -1, -1,
2368 -1, 36, 37, 16, 17, -1, 19, 20, 21, -1,
2369 -1, -1, -1, -1, -1, -1, -1, -1, 53, -1,
2370 -1, -1, -1, 36, 37, -1, -1, -1, -1, -1,
2371 -1, -1, -1, -1, 69, 70, 71, 72, 73, 74,
2372 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2373 85, -1, -1, -1, -1, -1, 69, 70, 71, 72,
2374 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2375 83, 84, 85, -1, -1, -1, 111, 112, 113, 114,
2376 115, 116, 117, 118, 119, 120, 121, 122, 123, -1,
2377 125, -1, 127, 128, 129, -1, -1, -1, 111, 112,
2378 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2379 123, 146, 125, -1, 127, 128, 129, -1, -1, -1,
2380 -1, 3, 4, -1, -1, -1, 139, 9, 141, -1,
2381 143, -1, -1, 146, -1, 148, -1, 150, -1, 21,
2382 22, 23, -1, -1, -1, -1, -1, -1, -1, -1,
2383 -1, -1, -1, -1, 36, 37, -1, -1, -1, -1,
2384 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
2385 8, 53, 10, 11, 12, 13, 14, -1, 16, 17,
2386 -1, 19, 20, -1, -1, -1, -1, 69, 70, 71,
2387 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2388 82, 83, 84, 85, -1, -1, -1, 45, -1, -1,
2389 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
2390 17, -1, 19, 20, -1, -1, -1, -1, -1, 111,
2391 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2392 122, 123, -1, 125, -1, 127, 128, 129, 45, 7,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002393 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002394 -1, 19, 20, -1, 146, 7, 8, -1, 10, 11,
2395 12, 13, 14, -1, 16, 17, -1, 19, 20, 7,
2396 8, -1, 10, 11, 12, 13, 14, 45, 16, 17,
2397 -1, 19, 20, -1, -1, -1, -1, -1, -1, -1,
2398 -1, -1, 140, 45, -1, 143, -1, -1, 146, -1,
2399 148, 149, -1, -1, -1, -1, -1, 45, -1, 7,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002400 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002401 -1, 19, 20, -1, -1, -1, -1, -1, -1, -1,
2402 -1, -1, -1, 140, -1, -1, 143, 35, -1, 146,
2403 -1, 148, 149, -1, -1, 7, 8, 45, 10, 11,
2404 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2405 -1, -1, -1, -1, -1, 117, -1, -1, -1, -1,
2406 -1, -1, 140, 35, -1, 143, -1, -1, 146, -1,
2407 148, 149, -1, 45, -1, -1, -1, -1, 140, -1,
2408 -1, 143, -1, -1, 146, -1, 148, -1, -1, -1,
2409 -1, -1, 140, -1, -1, 143, -1, 145, 146, -1,
2410 148, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2411 16, 17, -1, 19, 20, 7, 8, -1, 10, 11,
2412 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2413 -1, -1, 140, -1, -1, 143, -1, -1, 146, 45,
2414 148, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2415 -1, 16, 17, 45, 19, 20, -1, 7, 8, -1,
2416 10, 11, 12, 13, 14, -1, 16, 17, 140, 19,
2417 20, 143, -1, -1, 146, -1, 148, -1, 7, 8,
2418 45, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2419 19, 20, -1, 7, 8, 45, 10, 11, 12, 13,
2420 14, -1, 16, 17, -1, 19, 20, -1, -1, -1,
2421 -1, -1, -1, -1, -1, -1, 45, -1, -1, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002422 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002423 -1, 45, -1, -1, 140, -1, -1, 143, -1, -1,
2424 146, -1, 148, -1, -1, -1, -1, -1, 140, -1,
2425 -1, 143, -1, -1, 146, -1, 148, -1, -1, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002426 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002427 -1, -1, -1, -1, -1, 140, -1, -1, 143, -1,
2428 -1, 146, -1, 148, -1, -1, -1, -1, -1, -1,
2429 140, -1, -1, 143, -1, -1, 146, -1, 148, -1,
2430 -1, -1, -1, -1, 32, -1, -1, -1, -1, -1,
2431 -1, 140, -1, -1, 143, -1, -1, 146, -1, 148,
2432 -1, -1, -1, 51, 52, -1, 140, -1, -1, 143,
2433 -1, -1, 146, -1, 148, 63, 64, 65, 66, 67,
2434 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2435 78, 79, 80, 81, 82, 83, 84, 85, -1, -1,
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002436 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002437 -1, -1, -1, -1, -1, -1, -1, -1, 106, 107,
2438 108, -1, -1, 111, 112, 113, 114, 115, 116, 117,
2439 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2440 128, 129
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002441};
2442
2443/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2444 symbol of state STATE-NUM. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002445static const yytype_uint8 yystos[] =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002446{
2447 0, 16, 17, 19, 20, 26, 27, 47, 50, 54,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002448 159, 161, 162, 163, 164, 195, 196, 197, 199, 198,
2449 48, 62, 204, 137, 53, 137, 15, 137, 38, 39,
2450 40, 41, 42, 43, 44, 46, 134, 135, 136, 165,
2451 166, 167, 0, 197, 42, 44, 168, 214, 38, 39,
2452 40, 43, 169, 211, 213, 220, 137, 137, 143, 205,
2453 19, 203, 7, 8, 10, 11, 12, 13, 14, 45,
2454 140, 143, 146, 148, 159, 162, 182, 183, 217, 167,
2455 167, 31, 33, 193, 167, 167, 18, 221, 222, 25,
2456 149, 212, 221, 19, 19, 19, 206, 141, 4, 4,
2457 4, 148, 10, 149, 183, 188, 139, 141, 193, 193,
2458 38, 40, 170, 28, 29, 192, 56, 57, 58, 59,
2459 60, 61, 171, 209, 209, 161, 225, 138, 145, 35,
2460 183, 184, 186, 187, 144, 144, 149, 188, 138, 149,
2461 187, 192, 192, 10, 117, 183, 185, 194, 11, 12,
2462 13, 157, 158, 183, 189, 4, 185, 24, 148, 210,
2463 32, 51, 52, 63, 64, 65, 66, 67, 68, 69,
2464 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2465 80, 81, 82, 83, 84, 85, 106, 107, 108, 111,
2466 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2467 122, 123, 124, 125, 126, 127, 128, 129, 152, 153,
2468 154, 223, 229, 230, 231, 232, 19, 173, 138, 142,
2469 183, 183, 147, 149, 183, 142, 189, 183, 141, 217,
2470 22, 23, 3, 4, 5, 6, 9, 21, 36, 37,
2471 84, 85, 111, 125, 127, 128, 129, 143, 146, 148,
2472 150, 152, 153, 154, 190, 217, 200, 162, 51, 10,
2473 183, 219, 11, 14, 11, 157, 171, 86, 87, 88,
2474 89, 90, 91, 92, 93, 94, 95, 155, 22, 23,
2475 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
2476 102, 103, 104, 105, 156, 183, 183, 219, 183, 183,
2477 226, 219, 219, 219, 219, 219, 183, 183, 219, 171,
2478 109, 110, 113, 114, 131, 132, 172, 35, 184, 175,
2479 145, 147, 147, 175, 201, 202, 194, 155, 156, 141,
2480 141, 141, 141, 141, 145, 189, 191, 148, 191, 149,
2481 191, 19, 141, 141, 141, 138, 180, 141, 3, 4,
2482 9, 21, 22, 23, 36, 37, 53, 146, 190, 216,
2483 217, 218, 218, 218, 218, 185, 183, 183, 138, 177,
2484 138, 177, 218, 143, 138, 138, 138, 138, 138, 138,
2485 218, 218, 34, 185, 183, 219, 130, 133, 172, 174,
2486 180, 180, 34, 141, 141, 189, 189, 189, 189, 189,
2487 138, 145, 149, 183, 191, 147, 149, 189, 189, 189,
2488 30, 49, 178, 181, 35, 183, 207, 208, 55, 215,
2489 191, 138, 138, 218, 218, 218, 11, 49, 11, 228,
2490 218, 143, 219, 183, 219, 219, 219, 138, 138, 183,
2491 218, 218, 138, 183, 189, 189, 228, 138, 138, 138,
2492 138, 189, 147, 149, 138, 138, 34, 19, 4, 180,
2493 173, 138, 142, 19, 147, 14, 14, 141, 138, 138,
2494 218, 4, 218, 138, 138, 218, 138, 138, 138, 218,
2495 218, 141, 138, 177, 183, 142, 138, 138, 142, 189,
2496 189, 189, 189, 147, 189, 189, 183, 159, 160, 35,
2497 183, 175, 138, 218, 218, 183, 227, 218, 218, 177,
2498 177, 219, 218, 138, 219, 219, 219, 227, 218, 189,
2499 189, 138, 142, 138, 138, 142, 142, 142, 173, 178,
2500 179, 19, 138, 143, 218, 138, 142, 145, 218, 142,
2501 177, 142, 142, 189, 189, 189, 160, 49, 176, 14,
2502 145, 157, 224, 173, 183, 175, 145, 175, 142, 142,
2503 142, 4, 218, 216, 145, 157, 218, 34, 138, 216,
2504 173, 14, 14, 138, 218, 218, 14, 67, 218, 14,
2505 218
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002506};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002507
2508#define yyerrok (yyerrstatus = 0)
2509#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002510#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511#define YYEOF 0
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002512
Reid Spencer68a24bd2005-08-27 18:50:39 +00002513#define YYACCEPT goto yyacceptlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002514#define YYABORT goto yyabortlab
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002515#define YYERROR goto yyerrorlab
2516
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002517
2518/* Like YYERROR except do call yyerror. This remains here temporarily
2519 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002520 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002521
Reid Spencer68a24bd2005-08-27 18:50:39 +00002522#define YYFAIL goto yyerrlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002523
Reid Spencer68a24bd2005-08-27 18:50:39 +00002524#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002525
2526#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002527do \
2528 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002529 { \
2530 yychar = (Token); \
2531 yylval = (Value); \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002532 yytoken = YYTRANSLATE (yychar); \
2533 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002534 goto yybackup; \
2535 } \
2536 else \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002537 { \
2538 yyerror (YY_("syntax error: cannot back up")); \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002539 YYERROR; \
2540 } \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002541while (YYID (0))
2542
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002543
Reid Spencer68a24bd2005-08-27 18:50:39 +00002544#define YYTERROR 1
2545#define YYERRCODE 256
2546
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002547
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002548/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2549 If N is 0, then set CURRENT to the empty location which ends
2550 the previous symbol: RHS[0] (always defined). */
2551
2552#define YYRHSLOC(Rhs, K) ((Rhs)[K])
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002553#ifndef YYLLOC_DEFAULT
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002554# define YYLLOC_DEFAULT(Current, Rhs, N) \
2555 do \
2556 if (YYID (N)) \
2557 { \
2558 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2559 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2560 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2561 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2562 } \
2563 else \
2564 { \
2565 (Current).first_line = (Current).last_line = \
2566 YYRHSLOC (Rhs, 0).last_line; \
2567 (Current).first_column = (Current).last_column = \
2568 YYRHSLOC (Rhs, 0).last_column; \
2569 } \
2570 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571#endif
2572
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002573
2574/* YY_LOCATION_PRINT -- Print the location on the stream.
2575 This macro was not mandated originally: define only if we know
2576 we won't break user code: when these are the locations we know. */
2577
2578#ifndef YY_LOCATION_PRINT
2579# if YYLTYPE_IS_TRIVIAL
2580# define YY_LOCATION_PRINT(File, Loc) \
2581 fprintf (File, "%d.%d-%d.%d", \
2582 (Loc).first_line, (Loc).first_column, \
2583 (Loc).last_line, (Loc).last_column)
2584# else
2585# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2586# endif
2587#endif
2588
2589
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002590/* YYLEX -- calling `yylex' with the right arguments. */
2591
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002592#ifdef YYLEX_PARAM
2593# define YYLEX yylex (YYLEX_PARAM)
2594#else
2595# define YYLEX yylex ()
2596#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002597
2598/* Enable debugging if requested. */
2599#if YYDEBUG
2600
2601# ifndef YYFPRINTF
2602# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2603# define YYFPRINTF fprintf
2604# endif
2605
2606# define YYDPRINTF(Args) \
2607do { \
2608 if (yydebug) \
2609 YYFPRINTF Args; \
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002610} while (YYID (0))
2611
2612# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2613do { \
2614 if (yydebug) \
2615 { \
2616 YYFPRINTF (stderr, "%s ", Title); \
2617 yy_symbol_print (stderr, \
2618 Type, Value); \
2619 YYFPRINTF (stderr, "\n"); \
2620 } \
2621} while (YYID (0))
2622
2623
2624/*--------------------------------.
2625| Print this symbol on YYOUTPUT. |
2626`--------------------------------*/
2627
2628/*ARGSUSED*/
2629#if (defined __STDC__ || defined __C99__FUNC__ \
2630 || defined __cplusplus || defined _MSC_VER)
2631static void
2632yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2633#else
2634static void
2635yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2636 FILE *yyoutput;
2637 int yytype;
2638 YYSTYPE const * const yyvaluep;
2639#endif
2640{
2641 if (!yyvaluep)
2642 return;
2643# ifdef YYPRINT
2644 if (yytype < YYNTOKENS)
2645 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2646# else
2647 YYUSE (yyoutput);
2648# endif
2649 switch (yytype)
2650 {
2651 default:
2652 break;
2653 }
2654}
2655
2656
2657/*--------------------------------.
2658| Print this symbol on YYOUTPUT. |
2659`--------------------------------*/
2660
2661#if (defined __STDC__ || defined __C99__FUNC__ \
2662 || defined __cplusplus || defined _MSC_VER)
2663static void
2664yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2665#else
2666static void
2667yy_symbol_print (yyoutput, yytype, yyvaluep)
2668 FILE *yyoutput;
2669 int yytype;
2670 YYSTYPE const * const yyvaluep;
2671#endif
2672{
2673 if (yytype < YYNTOKENS)
2674 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2675 else
2676 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2677
2678 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2679 YYFPRINTF (yyoutput, ")");
2680}
2681
2682/*------------------------------------------------------------------.
2683| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2684| TOP (included). |
2685`------------------------------------------------------------------*/
2686
2687#if (defined __STDC__ || defined __C99__FUNC__ \
2688 || defined __cplusplus || defined _MSC_VER)
2689static void
2690yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2691#else
2692static void
2693yy_stack_print (bottom, top)
2694 yytype_int16 *bottom;
2695 yytype_int16 *top;
2696#endif
2697{
2698 YYFPRINTF (stderr, "Stack now");
2699 for (; bottom <= top; ++bottom)
2700 YYFPRINTF (stderr, " %d", *bottom);
2701 YYFPRINTF (stderr, "\n");
2702}
2703
2704# define YY_STACK_PRINT(Bottom, Top) \
2705do { \
2706 if (yydebug) \
2707 yy_stack_print ((Bottom), (Top)); \
2708} while (YYID (0))
2709
2710
2711/*------------------------------------------------.
2712| Report that the YYRULE is going to be reduced. |
2713`------------------------------------------------*/
2714
2715#if (defined __STDC__ || defined __C99__FUNC__ \
2716 || defined __cplusplus || defined _MSC_VER)
2717static void
2718yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2719#else
2720static void
2721yy_reduce_print (yyvsp, yyrule)
2722 YYSTYPE *yyvsp;
2723 int yyrule;
2724#endif
2725{
2726 int yynrhs = yyr2[yyrule];
2727 int yyi;
2728 unsigned long int yylno = yyrline[yyrule];
2729 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2730 yyrule - 1, yylno);
2731 /* The symbols being reduced. */
2732 for (yyi = 0; yyi < yynrhs; yyi++)
2733 {
2734 fprintf (stderr, " $%d = ", yyi + 1);
2735 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2736 &(yyvsp[(yyi + 1) - (yynrhs)])
2737 );
2738 fprintf (stderr, "\n");
2739 }
2740}
2741
2742# define YY_REDUCE_PRINT(Rule) \
2743do { \
2744 if (yydebug) \
2745 yy_reduce_print (yyvsp, Rule); \
2746} while (YYID (0))
2747
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002748/* Nonzero means print parse trace. It is left uninitialized so that
2749 multiple parsers can coexist. */
2750int yydebug;
2751#else /* !YYDEBUG */
2752# define YYDPRINTF(Args)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002753# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2754# define YY_STACK_PRINT(Bottom, Top)
2755# define YY_REDUCE_PRINT(Rule)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002756#endif /* !YYDEBUG */
2757
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002758
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002759/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002760#ifndef YYINITDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002761# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002762#endif
2763
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002764/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2765 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002766
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002767 Do not make this value too large; the results are undefined if
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002768 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002769 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002770
2771#ifndef YYMAXDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002772# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002773#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002774
Reid Spencer68a24bd2005-08-27 18:50:39 +00002775
2776
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002777#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002778
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002779# ifndef yystrlen
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002780# if defined __GLIBC__ && defined _STRING_H
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002781# define yystrlen strlen
2782# else
2783/* Return the length of YYSTR. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002784#if (defined __STDC__ || defined __C99__FUNC__ \
2785 || defined __cplusplus || defined _MSC_VER)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002786static YYSIZE_T
2787yystrlen (const char *yystr)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002788#else
2789static YYSIZE_T
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002790yystrlen (yystr)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002791 const char *yystr;
2792#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002793{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002794 YYSIZE_T yylen;
2795 for (yylen = 0; yystr[yylen]; yylen++)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002796 continue;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002797 return yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002798}
2799# endif
2800# endif
2801
2802# ifndef yystpcpy
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002803# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002804# define yystpcpy stpcpy
2805# else
2806/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2807 YYDEST. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002808#if (defined __STDC__ || defined __C99__FUNC__ \
2809 || defined __cplusplus || defined _MSC_VER)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002810static char *
2811yystpcpy (char *yydest, const char *yysrc)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002812#else
2813static char *
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002814yystpcpy (yydest, yysrc)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002815 char *yydest;
2816 const char *yysrc;
2817#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002818{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002819 char *yyd = yydest;
2820 const char *yys = yysrc;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002821
2822 while ((*yyd++ = *yys++) != '\0')
2823 continue;
2824
2825 return yyd - 1;
2826}
2827# endif
2828# endif
2829
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002830# ifndef yytnamerr
2831/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2832 quotes and backslashes, so that it's suitable for yyerror. The
2833 heuristic is that double-quoting is unnecessary unless the string
2834 contains an apostrophe, a comma, or backslash (other than
2835 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2836 null, do not copy; instead, return the length of what the result
2837 would have been. */
2838static YYSIZE_T
2839yytnamerr (char *yyres, const char *yystr)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002840{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002841 if (*yystr == '"')
Jeff Cohen930c0fe2007-04-29 14:43:31 +00002842 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002843 YYSIZE_T yyn = 0;
2844 char const *yyp = yystr;
Jeff Cohen930c0fe2007-04-29 14:43:31 +00002845
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002846 for (;;)
2847 switch (*++yyp)
2848 {
2849 case '\'':
2850 case ',':
2851 goto do_not_strip_quotes;
2852
2853 case '\\':
2854 if (*++yyp != '\\')
2855 goto do_not_strip_quotes;
2856 /* Fall through. */
2857 default:
2858 if (yyres)
2859 yyres[yyn] = *yyp;
2860 yyn++;
2861 break;
2862
2863 case '"':
2864 if (yyres)
2865 yyres[yyn] = '\0';
2866 return yyn;
2867 }
2868 do_not_strip_quotes: ;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002869 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002870
2871 if (! yyres)
2872 return yystrlen (yystr);
2873
2874 return yystpcpy (yyres, yystr) - yyres;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002875}
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002876# endif
Reid Spencer9c9b63a2007-04-28 16:07:31 +00002877
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002878/* Copy into YYRESULT an error message about the unexpected token
2879 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2880 including the terminating null byte. If YYRESULT is null, do not
2881 copy anything; just return the number of bytes that would be
2882 copied. As a special case, return 0 if an ordinary "syntax error"
2883 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2884 size calculation. */
2885static YYSIZE_T
2886yysyntax_error (char *yyresult, int yystate, int yychar)
2887{
2888 int yyn = yypact[yystate];
2889
2890 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2891 return 0;
2892 else
2893 {
2894 int yytype = YYTRANSLATE (yychar);
2895 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2896 YYSIZE_T yysize = yysize0;
2897 YYSIZE_T yysize1;
2898 int yysize_overflow = 0;
2899 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2900 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2901 int yyx;
2902
2903# if 0
2904 /* This is so xgettext sees the translatable formats that are
2905 constructed on the fly. */
2906 YY_("syntax error, unexpected %s");
2907 YY_("syntax error, unexpected %s, expecting %s");
2908 YY_("syntax error, unexpected %s, expecting %s or %s");
2909 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2910 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2911# endif
2912 char *yyfmt;
2913 char const *yyf;
2914 static char const yyunexpected[] = "syntax error, unexpected %s";
2915 static char const yyexpecting[] = ", expecting %s";
2916 static char const yyor[] = " or %s";
2917 char yyformat[sizeof yyunexpected
2918 + sizeof yyexpecting - 1
2919 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2920 * (sizeof yyor - 1))];
2921 char const *yyprefix = yyexpecting;
2922
2923 /* Start YYX at -YYN if negative to avoid negative indexes in
2924 YYCHECK. */
2925 int yyxbegin = yyn < 0 ? -yyn : 0;
2926
2927 /* Stay within bounds of both yycheck and yytname. */
2928 int yychecklim = YYLAST - yyn + 1;
2929 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2930 int yycount = 1;
2931
2932 yyarg[0] = yytname[yytype];
2933 yyfmt = yystpcpy (yyformat, yyunexpected);
2934
2935 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2936 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2937 {
2938 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2939 {
2940 yycount = 1;
2941 yysize = yysize0;
2942 yyformat[sizeof yyunexpected - 1] = '\0';
2943 break;
2944 }
2945 yyarg[yycount++] = yytname[yyx];
2946 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2947 yysize_overflow |= (yysize1 < yysize);
2948 yysize = yysize1;
2949 yyfmt = yystpcpy (yyfmt, yyprefix);
2950 yyprefix = yyor;
2951 }
2952
2953 yyf = YY_(yyformat);
2954 yysize1 = yysize + yystrlen (yyf);
2955 yysize_overflow |= (yysize1 < yysize);
2956 yysize = yysize1;
2957
2958 if (yysize_overflow)
2959 return YYSIZE_MAXIMUM;
2960
2961 if (yyresult)
2962 {
2963 /* Avoid sprintf, as that infringes on the user's name space.
2964 Don't have undefined behavior even if the translation
2965 produced a string with the wrong number of "%s"s. */
2966 char *yyp = yyresult;
2967 int yyi = 0;
2968 while ((*yyp = *yyf) != '\0')
2969 {
2970 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2971 {
2972 yyp += yytnamerr (yyp, yyarg[yyi++]);
2973 yyf += 2;
2974 }
2975 else
2976 {
2977 yyp++;
2978 yyf++;
2979 }
2980 }
2981 }
2982 return yysize;
2983 }
2984}
2985#endif /* YYERROR_VERBOSE */
2986
Jeff Cohen930c0fe2007-04-29 14:43:31 +00002987
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002988/*-----------------------------------------------.
2989| Release the memory associated to this symbol. |
2990`-----------------------------------------------*/
2991
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002992/*ARGSUSED*/
2993#if (defined __STDC__ || defined __C99__FUNC__ \
2994 || defined __cplusplus || defined _MSC_VER)
Jeff Cohen930c0fe2007-04-29 14:43:31 +00002995static void
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002996yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002997#else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002998static void
2999yydestruct (yymsg, yytype, yyvaluep)
3000 const char *yymsg;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003001 int yytype;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003002 YYSTYPE *yyvaluep;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003003#endif
3004{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003005 YYUSE (yyvaluep);
3006
3007 if (!yymsg)
3008 yymsg = "Deleting";
3009 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003010
3011 switch (yytype)
3012 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003013
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003014 default:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003015 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003016 }
3017}
3018
3019
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003020/* Prevent warnings from -Wmissing-prototypes. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003021
3022#ifdef YYPARSE_PARAM
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003023#if defined __STDC__ || defined __cplusplus
3024int yyparse (void *YYPARSE_PARAM);
3025#else
3026int yyparse ();
Christopher Lamb5c104242007-04-22 20:09:11 +00003027#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003028#else /* ! YYPARSE_PARAM */
3029#if defined __STDC__ || defined __cplusplus
3030int yyparse (void);
3031#else
3032int yyparse ();
3033#endif
3034#endif /* ! YYPARSE_PARAM */
Chris Lattner7d9801d2007-02-13 00:58:01 +00003035
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003036
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003037
3038/* The look-ahead symbol. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003039int yychar;
3040
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003041/* The semantic value of the look-ahead symbol. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003042YYSTYPE yylval;
3043
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003044/* Number of syntax errors so far. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003045int yynerrs;
3046
3047
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003048
3049/*----------.
3050| yyparse. |
3051`----------*/
3052
3053#ifdef YYPARSE_PARAM
3054#if (defined __STDC__ || defined __C99__FUNC__ \
3055 || defined __cplusplus || defined _MSC_VER)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003056int
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003057yyparse (void *YYPARSE_PARAM)
3058#else
3059int
3060yyparse (YYPARSE_PARAM)
3061 void *YYPARSE_PARAM;
3062#endif
3063#else /* ! YYPARSE_PARAM */
3064#if (defined __STDC__ || defined __C99__FUNC__ \
3065 || defined __cplusplus || defined _MSC_VER)
3066int
3067yyparse (void)
3068#else
3069int
3070yyparse ()
3071
3072#endif
3073#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003074{
3075
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003076 int yystate;
3077 int yyn;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003078 int yyresult;
3079 /* Number of tokens to shift before error messages enabled. */
3080 int yyerrstatus;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003081 /* Look-ahead token as an internal (translated) token number. */
3082 int yytoken = 0;
3083#if YYERROR_VERBOSE
3084 /* Buffer for error messages, and its allocated size. */
3085 char yymsgbuf[128];
3086 char *yymsg = yymsgbuf;
3087 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3088#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003089
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003090 /* Three stacks and their tools:
3091 `yyss': related to states,
3092 `yyvs': related to semantic values,
3093 `yyls': related to locations.
3094
3095 Refer to the stacks thru separate pointers, to allow yyoverflow
3096 to reallocate them elsewhere. */
3097
3098 /* The state stack. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003099 yytype_int16 yyssa[YYINITDEPTH];
3100 yytype_int16 *yyss = yyssa;
3101 yytype_int16 *yyssp;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003102
3103 /* The semantic value stack. */
3104 YYSTYPE yyvsa[YYINITDEPTH];
3105 YYSTYPE *yyvs = yyvsa;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003106 YYSTYPE *yyvsp;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003107
3108
3109
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003110#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003111
3112 YYSIZE_T yystacksize = YYINITDEPTH;
3113
3114 /* The variables used to return semantic value and location from the
3115 action routines. */
3116 YYSTYPE yyval;
3117
3118
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003119 /* The number of symbols on the RHS of the reduced rule.
3120 Keep to zero when no symbol should be popped. */
3121 int yylen = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003122
3123 YYDPRINTF ((stderr, "Starting parse\n"));
3124
Reid Spencer68a24bd2005-08-27 18:50:39 +00003125 yystate = 0;
3126 yyerrstatus = 0;
3127 yynerrs = 0;
3128 yychar = YYEMPTY; /* Cause a token to be read. */
3129
3130 /* Initialize stack pointers.
3131 Waste one element of value and location stack
3132 so that they stay on the same level as the state stack.
3133 The wasted elements are never initialized. */
3134
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003135 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003136 yyvsp = yyvs;
3137
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003138 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003139
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003140/*------------------------------------------------------------.
3141| yynewstate -- Push a new state, which is found in yystate. |
3142`------------------------------------------------------------*/
3143 yynewstate:
3144 /* In all cases, when you get here, the value and location stacks
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003145 have just been pushed. So pushing a state here evens the stacks. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003146 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003147
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003148 yysetstate:
3149 *yyssp = yystate;
3150
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003151 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003152 {
3153 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003154 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003155
3156#ifdef yyoverflow
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003157 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003158 /* Give user a chance to reallocate the stack. Use copies of
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003159 these so that the &'s don't force the real ones into
3160 memory. */
3161 YYSTYPE *yyvs1 = yyvs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003162 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003163
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003164
3165 /* Each stack pointer address is followed by the size of the
3166 data in use in that stack, in bytes. This used to be a
3167 conditional around just the two extra args, but that might
3168 be undefined if yyoverflow is a macro. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003169 yyoverflow (YY_("memory exhausted"),
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003170 &yyss1, yysize * sizeof (*yyssp),
3171 &yyvs1, yysize * sizeof (*yyvsp),
3172
3173 &yystacksize);
3174
3175 yyss = yyss1;
3176 yyvs = yyvs1;
3177 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003178#else /* no yyoverflow */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003179# ifndef YYSTACK_RELOCATE
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003180 goto yyexhaustedlab;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003181# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003182 /* Extend the stack our own way. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003183 if (YYMAXDEPTH <= yystacksize)
3184 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003185 yystacksize *= 2;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003186 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003187 yystacksize = YYMAXDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003188
3189 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003190 yytype_int16 *yyss1 = yyss;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003191 union yyalloc *yyptr =
3192 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3193 if (! yyptr)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003194 goto yyexhaustedlab;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003195 YYSTACK_RELOCATE (yyss);
3196 YYSTACK_RELOCATE (yyvs);
3197
3198# undef YYSTACK_RELOCATE
3199 if (yyss1 != yyssa)
3200 YYSTACK_FREE (yyss1);
3201 }
3202# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203#endif /* no yyoverflow */
3204
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003205 yyssp = yyss + yysize - 1;
3206 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003207
3208
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003209 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3210 (unsigned long int) yystacksize));
3211
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003212 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003213 YYABORT;
3214 }
3215
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003216 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003217
3218 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003219
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003220/*-----------.
3221| yybackup. |
3222`-----------*/
3223yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003224
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003225 /* Do appropriate processing given the current state. Read a
3226 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003227
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003228 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003229 yyn = yypact[yystate];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003230 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003231 goto yydefault;
3232
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003233 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003234
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003235 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003236 if (yychar == YYEMPTY)
3237 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003238 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003239 yychar = YYLEX;
3240 }
3241
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003242 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003243 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003244 yychar = yytoken = YYEOF;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003245 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003246 }
3247 else
3248 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003249 yytoken = YYTRANSLATE (yychar);
3250 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003251 }
3252
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003253 /* If the proper action on seeing token YYTOKEN is to reduce or to
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003254 detect an error, take that action. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003255 yyn += yytoken;
3256 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003257 goto yydefault;
3258 yyn = yytable[yyn];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003259 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003260 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003261 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003262 goto yyerrlab;
3263 yyn = -yyn;
3264 goto yyreduce;
3265 }
3266
3267 if (yyn == YYFINAL)
3268 YYACCEPT;
3269
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003270 /* Count tokens shifted since error; after three, turn off error
3271 status. */
3272 if (yyerrstatus)
3273 yyerrstatus--;
Christopher Lamb5c104242007-04-22 20:09:11 +00003274
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003275 /* Shift the look-ahead token. */
3276 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3277
3278 /* Discard the shifted token unless it is eof. */
3279 if (yychar != YYEOF)
3280 yychar = YYEMPTY;
3281
Chris Lattner6cdc6822007-04-26 05:31:05 +00003282 yystate = yyn;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003283 *++yyvsp = yylval;
3284
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 goto yynewstate;
3286
Chris Lattner6cdc6822007-04-26 05:31:05 +00003287
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003288/*-----------------------------------------------------------.
3289| yydefault -- do the default action for the current state. |
3290`-----------------------------------------------------------*/
3291yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003292 yyn = yydefact[yystate];
3293 if (yyn == 0)
3294 goto yyerrlab;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003295 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003296
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003297
3298/*-----------------------------.
3299| yyreduce -- Do a reduction. |
3300`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003301yyreduce:
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003302 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003303 yylen = yyr2[yyn];
3304
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003305 /* If YYLEN is nonzero, implement the default value of the action:
3306 `$$ = $1'.
3307
3308 Otherwise, the following line sets YYVAL to garbage.
3309 This behavior is undocumented and Bison
3310 users should not rely upon it. Assigning to YYVAL
3311 unconditionally makes the parser a bit smaller, and it avoids a
3312 GCC warning that YYVAL may be used uninitialized. */
3313 yyval = yyvsp[1-yylen];
3314
3315
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003316 YY_REDUCE_PRINT (yyn);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003317 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003318 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003319 case 29:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003320#line 1117 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3321 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003322 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003323
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003324 case 30:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003325#line 1117 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3326 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003327 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003328
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003329 case 31:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003330#line 1118 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3331 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003332 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003333
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003334 case 32:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003335#line 1118 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3336 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003337 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003338
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003339 case 33:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003340#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3341 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003342 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003343
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003344 case 34:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003345#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3346 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003347 break;
3348
3349 case 35:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003350#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3351 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003352 break;
3353
3354 case 36:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003355#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3356 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003357 break;
3358
3359 case 37:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003360#line 1121 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3361 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003362 break;
3363
3364 case 38:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003365#line 1121 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3366 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003367 break;
3368
3369 case 39:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003370#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3371 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003372 break;
3373
3374 case 40:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003375#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3376 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003377 break;
3378
3379 case 41:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003380#line 1126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3381 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003382 break;
3383
3384 case 42:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003385#line 1126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3386 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003387 break;
3388
3389 case 43:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003390#line 1127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3391 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003392 break;
3393
3394 case 44:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003395#line 1127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3396 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003397 break;
3398
3399 case 45:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003400#line 1128 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3401 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003402 break;
3403
3404 case 46:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003405#line 1128 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3406 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003407 break;
3408
3409 case 47:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003410#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3411 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003412 break;
3413
3414 case 48:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003415#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3416 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003417 break;
3418
3419 case 49:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003420#line 1130 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3421 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003422 break;
3423
3424 case 50:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003425#line 1130 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3426 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003427 break;
3428
3429 case 51:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003430#line 1131 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3431 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003432 break;
3433
3434 case 52:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003435#line 1131 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3436 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003437 break;
3438
3439 case 53:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003440#line 1132 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3441 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003442 break;
3443
3444 case 54:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003445#line 1133 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3446 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003447 break;
3448
3449 case 61:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003450#line 1142 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3451 { (yyval.StrVal) = 0; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003452 break;
3453
3454 case 62:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003455#line 1146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003456 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003457 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003458 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003459 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003460 break;
3461
3462 case 63:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003463#line 1150 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003464 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003465 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003466 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003467 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003468 break;
3469
3470 case 67:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003471#line 1158 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003472 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003473 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003474 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003475 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003476 break;
3477
3478 case 68:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003479#line 1163 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003480 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003481 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003482 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003483 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003484 break;
3485
3486 case 69:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003487#line 1169 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3488 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003489 break;
3490
3491 case 70:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003492#line 1170 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3493 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003494 break;
3495
3496 case 71:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003497#line 1171 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3498 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003499 break;
3500
3501 case 72:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003502#line 1172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3503 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003504 break;
3505
3506 case 73:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003507#line 1173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3508 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003509 break;
3510
3511 case 74:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003512#line 1177 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3513 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003514 break;
3515
3516 case 75:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003517#line 1178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3518 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003519 break;
3520
3521 case 76:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003522#line 1179 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3523 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003524 break;
3525
3526 case 77:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003527#line 1183 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3528 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003529 break;
3530
3531 case 78:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003532#line 1184 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3533 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003534 break;
3535
3536 case 79:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003537#line 1185 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3538 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003539 break;
3540
3541 case 80:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003542#line 1186 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3543 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003544 break;
3545
3546 case 81:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003547#line 1190 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3548 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003549 break;
3550
3551 case 82:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003552#line 1191 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3553 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003554 break;
3555
3556 case 83:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003557#line 1192 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3558 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003559 break;
3560
3561 case 84:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003562#line 1196 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3563 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003564 break;
3565
3566 case 85:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003567#line 1197 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3568 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003569 break;
3570
3571 case 86:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003572#line 1198 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3573 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003574 break;
3575
3576 case 87:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003577#line 1199 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3578 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003579 break;
3580
3581 case 88:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003582#line 1200 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3583 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003584 break;
3585
3586 case 89:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003587#line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3588 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003589 break;
3590
3591 case 90:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003592#line 1205 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3593 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003594 break;
3595
3596 case 91:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003597#line 1206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3598 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003599 break;
3600
3601 case 92:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003602#line 1209 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3603 { (yyval.UIntVal) = CallingConv::C; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003604 break;
3605
3606 case 93:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003607#line 1210 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3608 { (yyval.UIntVal) = CallingConv::C; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003609 break;
3610
3611 case 94:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003612#line 1211 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3613 { (yyval.UIntVal) = CallingConv::Fast; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003614 break;
3615
3616 case 95:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003617#line 1212 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3618 { (yyval.UIntVal) = CallingConv::Cold; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003619 break;
3620
3621 case 96:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003622#line 1213 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3623 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003624 break;
3625
3626 case 97:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003627#line 1214 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3628 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003629 break;
3630
3631 case 98:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003632#line 1215 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3633 {
3634 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
3635 GEN_ERROR("Calling conv too large");
3636 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3637 CHECK_FOR_ERROR
3638 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003639 break;
3640
3641 case 99:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003642#line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3643 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003644 break;
3645
3646 case 100:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003647#line 1223 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3648 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003649 break;
3650
3651 case 101:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003652#line 1224 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3653 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003654 break;
3655
3656 case 102:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003657#line 1225 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3658 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003659 break;
3660
3661 case 103:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003662#line 1228 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3663 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003664 break;
3665
3666 case 104:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003667#line 1229 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3668 {
3669 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3670 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003671 break;
3672
3673 case 105:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003674#line 1234 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3675 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003676 break;
3677
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003678 case 106:
3679#line 1235 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3680 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003681 break;
3682
3683 case 108:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003684#line 1239 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3685 { (yyval.ParamAttrs) = ParamAttr::None; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003686 break;
3687
3688 case 109:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003689#line 1240 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3690 {
3691 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3692 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003693 break;
3694
3695 case 110:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003696#line 1247 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3697 { (yyval.UIntVal) = 0; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003698 break;
3699
3700 case 111:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003701#line 1248 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3702 {
3703 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3704 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3705 GEN_ERROR("Alignment must be a power of two");
3706 CHECK_FOR_ERROR
3707;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003708 break;
3709
3710 case 112:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003711#line 1254 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3712 { (yyval.UIntVal) = 0; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003713 break;
3714
3715 case 113:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003716#line 1255 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003717 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003718 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3719 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3720 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003721 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003722;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003723 break;
3724
3725 case 114:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003726#line 1263 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3727 {
3728 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
3729 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
3730 GEN_ERROR("Invalid character in section name");
3731 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3732 CHECK_FOR_ERROR
3733;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003734 break;
3735
3736 case 115:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003737#line 1271 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3738 { (yyval.StrVal) = 0; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003739 break;
3740
3741 case 116:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003742#line 1272 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3743 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003744 break;
3745
3746 case 117:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003747#line 1277 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3748 {;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003749 break;
3750
3751 case 118:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003752#line 1278 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3753 {;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003754 break;
3755
3756 case 119:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003757#line 1279 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003758 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003759 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
3760 free((yyvsp[(1) - (1)].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003761 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003762 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003763 break;
3764
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003765 case 120:
3766#line 1284 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003767 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003768 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
3769 GEN_ERROR("Alignment must be a power of two");
3770 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003771 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003772 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003773 break;
3774
3775 case 125:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003776#line 1300 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003777 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003778 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003779 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003780 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003781 break;
3782
3783 case 126:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003784#line 1304 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3785 {
3786 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003787 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003788 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003789 break;
3790
3791 case 127:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003792#line 1308 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3793 { // Pointer type?
3794 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
3795 GEN_ERROR("Cannot form a pointer to a basic block");
3796 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3797 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003798 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003799 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003800 break;
3801
3802 case 128:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003803#line 1315 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3804 { // Named types are also simple types...
3805 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003806 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003807 (yyval.TypeVal) = new PATypeHolder(tmp);
3808 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003809 break;
3810
3811 case 129:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003812#line 1320 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3813 { // Type UpReference
3814 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
3815 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3816 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3817 (yyval.TypeVal) = new PATypeHolder(OT);
3818 UR_OUT("New Upreference!\n");
3819 CHECK_FOR_ERROR
3820 ;}
3821 break;
3822
3823 case 130:
3824#line 1328 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003825 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003826 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003827 ParamAttrsVector Attrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003828 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3829 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003830 Attrs.push_back(X);
3831 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003832 unsigned index = 1;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003833 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003834 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003835 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003836 Params.push_back(Ty);
3837 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003838 if (I->Attrs != ParamAttr::None) {
3839 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3840 Attrs.push_back(X);
3841 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003842 }
3843 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3844 if (isVarArg) Params.pop_back();
3845
Reid Spencer7b5d4662007-04-09 06:16:21 +00003846 ParamAttrsList *ActualAttrs = 0;
3847 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003848 ActualAttrs = ParamAttrsList::get(Attrs);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003849 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
3850 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3851 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3852 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003853 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003854 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003855 break;
3856
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003857 case 131:
3858#line 1358 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003859 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003860 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003861 ParamAttrsVector Attrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003862 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3863 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003864 Attrs.push_back(X);
3865 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003866 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003867 unsigned index = 1;
3868 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003869 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003870 Params.push_back(Ty);
3871 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003872 if (I->Attrs != ParamAttr::None) {
3873 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3874 Attrs.push_back(X);
3875 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003876 }
3877 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3878 if (isVarArg) Params.pop_back();
3879
Reid Spencer7b5d4662007-04-09 06:16:21 +00003880 ParamAttrsList *ActualAttrs = 0;
3881 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003882 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003883
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003884 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
3885 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3886 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003887 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003888 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003889 break;
3890
3891 case 132:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003892#line 1389 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3893 { // Sized array type?
3894 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3895 delete (yyvsp[(4) - (5)].TypeVal);
3896 CHECK_FOR_ERROR
3897 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003898 break;
3899
3900 case 133:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003901#line 1394 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3902 { // Vector type?
3903 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
3904 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
3905 GEN_ERROR("Unsigned result not equal to signed result");
3906 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3907 GEN_ERROR("Element type of a VectorType must be primitive");
3908 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
3909 GEN_ERROR("Vector length should be a power of 2");
3910 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3911 delete (yyvsp[(4) - (5)].TypeVal);
3912 CHECK_FOR_ERROR
3913 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003914 break;
3915
3916 case 134:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003917#line 1406 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3918 { // Structure type?
3919 std::vector<const Type*> Elements;
3920 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
3921 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
3922 Elements.push_back(*I);
3923
3924 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3925 delete (yyvsp[(2) - (3)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003926 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003927 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003928 break;
3929
3930 case 135:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003931#line 1416 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3932 { // Empty structure type?
3933 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003934 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003935 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003936 break;
3937
3938 case 136:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003939#line 1420 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3940 {
3941 std::vector<const Type*> Elements;
3942 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
3943 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
3944 Elements.push_back(*I);
3945
3946 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3947 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003948 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003949 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003950 break;
3951
3952 case 137:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003953#line 1430 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3954 { // Empty structure type?
3955 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
3956 CHECK_FOR_ERROR
3957 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003958 break;
3959
3960 case 138:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003961#line 1437 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3962 {
3963 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
3964 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
3965 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003966 break;
3967
3968 case 139:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003969#line 1444 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003970 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003971 if (!UpRefs.empty())
3972 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
3973 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
3974 GEN_ERROR("LLVM functions cannot return aggregate types");
3975 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
3976 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003977 break;
3978
3979 case 140:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003980#line 1451 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003981 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003982 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3983 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003984 break;
3985
3986 case 141:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003987#line 1456 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003988 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003989 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3990 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003991 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003992 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003993 break;
3994
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003995 case 142:
3996#line 1461 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003997 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003998 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003999 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004000 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004001 break;
4002
4003 case 144:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004004#line 1469 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004005 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004006 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004007 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004008 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004009 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004010 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004011 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004012 break;
4013
4014 case 145:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004015#line 1476 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004016 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004017 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
4018 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4019 TWA.Ty = new PATypeHolder(Type::VoidTy);
4020 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004022 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004023 break;
4024
4025 case 146:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004026#line 1483 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004027 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004028 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004029 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004030 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004031 break;
4032
4033 case 147:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004034#line 1491 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004035 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004036 (yyval.TypeList) = new std::list<PATypeHolder>();
4037 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4038 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004039 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004040 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004041 break;
4042
4043 case 148:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004044#line 1497 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4045 {
4046 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4047 delete (yyvsp[(3) - (3)].TypeVal);
4048 CHECK_FOR_ERROR
4049 ;}
4050 break;
4051
4052 case 149:
4053#line 1509 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004054 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004055 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004056 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4057 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004058 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004059 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004060 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004061 const Type *ETy = ATy->getElementType();
4062 int NumElements = ATy->getNumElements();
4063
4064 // Verify that we have the correct size...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004065 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004066 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004067 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004068 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004069
4070 // Verify all elements are correct type!
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004071 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4072 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004073 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4074 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004075 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004076 }
4077
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004078 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4079 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004080 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004081 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004082 break;
4083
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004084 case 150:
4085#line 1537 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004086 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004087 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004088 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4089 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004090 if (ATy == 0)
4091 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004092 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004093
Andrew Lenharth6353e052006-12-08 18:07:09 +00004094 int NumElements = ATy->getNumElements();
4095 if (NumElements != -1 && NumElements != 0)
4096 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004097 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004098 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4099 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004100 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004101 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004102 break;
4103
4104 case 151:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004105#line 1553 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4106 {
4107 if (!UpRefs.empty())
4108 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4109 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
4110 if (ATy == 0)
4111 GEN_ERROR("Cannot make array constant with type: '" +
4112 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
4113
4114 int NumElements = ATy->getNumElements();
4115 const Type *ETy = ATy->getElementType();
4116 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4117 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
4118 GEN_ERROR("Can't build string constant of size " +
4119 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) +
4120 " when array has size " + itostr(NumElements) + "");
4121 std::vector<Constant*> Vals;
4122 if (ETy == Type::Int8Ty) {
4123 for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal);
4124 C != (unsigned char*)EndStr; ++C)
4125 Vals.push_back(ConstantInt::get(ETy, *C));
4126 } else {
4127 free((yyvsp[(3) - (3)].StrVal));
4128 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4129 }
4130 free((yyvsp[(3) - (3)].StrVal));
4131 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4132 delete (yyvsp[(1) - (3)].TypeVal);
4133 CHECK_FOR_ERROR
4134 ;}
4135 break;
4136
4137 case 152:
4138#line 1582 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004139 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004140 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004141 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4142 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004143 if (PTy == 0)
4144 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004145 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004146 const Type *ETy = PTy->getElementType();
4147 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004148
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004149 // Verify that we have the correct size...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004150 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004151 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004152 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004153 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004154
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004155 // Verify all elements are correct type!
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004156 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4157 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004158 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4159 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004160 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004161 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004162
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004163 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4164 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004165 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004166 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004167 break;
4168
4169 case 153:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004170#line 1610 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004171 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004172 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004173 if (STy == 0)
4174 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004175 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
4176
4177 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
4178 GEN_ERROR("Illegal number of initializers for structure type");
4179
4180 // Check to ensure that constants are compatible with the type initializer!
4181 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4182 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
4183 GEN_ERROR("Expected type '" +
4184 STy->getElementType(i)->getDescription() +
4185 "' for element #" + utostr(i) +
4186 " of structure initializer");
4187
4188 // Check to ensure that Type is not packed
4189 if (STy->isPacked())
4190 GEN_ERROR("Unpacked Initializer to vector type '" +
4191 STy->getDescription() + "'");
4192
4193 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4194 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
4195 CHECK_FOR_ERROR
4196 ;}
4197 break;
4198
4199 case 154:
4200#line 1636 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4201 {
4202 if (!UpRefs.empty())
4203 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4204 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
4205 if (STy == 0)
4206 GEN_ERROR("Cannot make struct constant with type: '" +
4207 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004208
4209 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004210 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004211
4212 // Check to ensure that Type is not packed
4213 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004214 GEN_ERROR("Unpacked Initializer to vector type '" +
4215 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004216
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004217 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4218 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004219 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004220 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004221 break;
4222
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004223 case 155:
4224#line 1656 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004225 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004226 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004227 if (STy == 0)
4228 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004229 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004230
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004231 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004232 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004233
4234 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004235 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4236 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004237 GEN_ERROR("Expected type '" +
4238 STy->getElementType(i)->getDescription() +
4239 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004240 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004241
4242 // Check to ensure that Type is packed
4243 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004244 GEN_ERROR("Vector initializer to non-vector type '" +
4245 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004246
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004247 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4248 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004249 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004250 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004251 break;
4252
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004253 case 156:
4254#line 1682 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004255 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004256 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004257 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4258 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004259 if (STy == 0)
4260 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004261 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004262
4263 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004264 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004265
4266 // Check to ensure that Type is packed
4267 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004268 GEN_ERROR("Vector initializer to non-vector type '" +
4269 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004270
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004271 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4272 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004273 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004274 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004275 break;
4276
4277 case 157:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004278#line 1702 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004279 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004280 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004281 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4282 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
4283 if (PTy == 0)
4284 GEN_ERROR("Cannot make null pointer constant with type: '" +
4285 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
4286
4287 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4288 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004289 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004290 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004291 break;
4292
4293 case 158:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004294#line 1714 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004295 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004296 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004297 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4298 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4299 delete (yyvsp[(1) - (2)].TypeVal);
4300 CHECK_FOR_ERROR
4301 ;}
4302 break;
4303
4304 case 159:
4305#line 1721 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4306 {
4307 if (!UpRefs.empty())
4308 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4309 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004310 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004311 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004312
4313 // ConstExprs can exist in the body of a function, thus creating
4314 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004315 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004316 // symbol table instead of the module symbol table for the global symbol,
4317 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004318 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004319 //
4320 Function *SavedCurFn = CurFun.CurrentFunction;
4321 CurFun.CurrentFunction = 0;
4322
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004323 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004324 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004325
4326 CurFun.CurrentFunction = SavedCurFn;
4327
4328 // If this is an initializer for a constant pointer, which is referencing a
4329 // (currently) undefined variable, create a stub now that shall be replaced
4330 // in the future with the right type of variable.
4331 //
4332 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004333 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004334 const PointerType *PT = cast<PointerType>(Ty);
4335
4336 // First check to see if the forward references value is already created!
4337 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004338 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004339
4340 if (I != CurModule.GlobalRefs.end()) {
4341 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004342 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004343 } else {
4344 std::string Name;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004345 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4346 Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4347 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004348 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004349
4350 // Create the forward referenced global.
4351 GlobalValue *GV;
4352 if (const FunctionType *FTy =
4353 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004354 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004355 CurModule.CurrentModule);
4356 } else {
4357 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004358 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004359 Name, CurModule.CurrentModule);
4360 }
4361
4362 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004363 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004364 V = GV;
4365 }
4366 }
4367
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004368 (yyval.ConstVal) = cast<GlobalValue>(V);
4369 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004370 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004372 break;
4373
4374 case 160:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004375#line 1787 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004376 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004377 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004378 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4379 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
4380 GEN_ERROR("Mismatched types for constant expression: " +
4381 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4382 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4383 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004384 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004385 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004386 break;
4387
4388 case 161:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004389#line 1797 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4390 {
4391 if (!UpRefs.empty())
4392 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4393 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
4394 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4395 GEN_ERROR("Cannot create a null initialized value of this type");
4396 (yyval.ConstVal) = Constant::getNullValue(Ty);
4397 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004398 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004399 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004400 break;
4401
4402 case 162:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004403#line 1807 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4404 { // integral constants
4405 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
4406 GEN_ERROR("Constant value doesn't fit in type");
4407 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004408 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004409 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004410 break;
4411
4412 case 163:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004413#line 1813 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4414 { // arbitrary precision integer constants
4415 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4416 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
4417 GEN_ERROR("Constant value does not fit in type");
4418 }
4419 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4420 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4421 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004422 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004423 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004424 break;
4425
4426 case 164:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004427#line 1823 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4428 { // integral constants
4429 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
4430 GEN_ERROR("Constant value doesn't fit in type");
4431 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004432 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004433 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004434 break;
4435
4436 case 165:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004437#line 1829 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4438 { // arbitrary precision integer constants
4439 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4440 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
4441 GEN_ERROR("Constant value does not fit in type");
4442 }
4443 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4444 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4445 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004446 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004447 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004448 break;
4449
4450 case 166:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004451#line 1839 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4452 { // Boolean constants
4453 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4454 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004455 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004456 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004457 break;
4458
4459 case 167:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004460#line 1844 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4461 { // Boolean constants
4462 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4463 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004464 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004465 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004466 break;
4467
4468 case 168:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004469#line 1849 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4470 { // Float & Double constants
4471 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
4472 GEN_ERROR("Floating point constant invalid for type");
4473 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
4474 CHECK_FOR_ERROR
4475 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004476 break;
4477
4478 case 169:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004479#line 1857 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004480 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004481 if (!UpRefs.empty())
4482 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4483 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4484 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4485 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
4486 GEN_ERROR("invalid cast opcode for cast from '" +
4487 Val->getType()->getDescription() + "' to '" +
4488 DestTy->getDescription() + "'");
4489 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4490 delete (yyvsp[(5) - (6)].TypeVal);
4491 ;}
4492 break;
4493
4494 case 170:
4495#line 1869 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4496 {
4497 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004498 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004499
4500 const Type *IdxTy =
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004501 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004502 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004503 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004504 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004505
Chris Lattnerf7469af2007-01-31 04:44:08 +00004506 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004507 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4508 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004509 IdxVec.push_back(C);
4510 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004511 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004512
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004513 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004514
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004515 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004516 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004517 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004518 break;
4519
4520 case 171:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004521#line 1891 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004522 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004523 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
4524 GEN_ERROR("Select condition must be of boolean type");
4525 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
4526 GEN_ERROR("Select operand types must match");
4527 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
4528 CHECK_FOR_ERROR
4529 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004530 break;
4531
4532 case 172:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004533#line 1899 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004534 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004535 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
4536 GEN_ERROR("Binary operator types must match");
4537 CHECK_FOR_ERROR;
4538 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4539 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004540 break;
4541
4542 case 173:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004543#line 1905 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004544 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004545 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
4546 GEN_ERROR("Logical operator types must match");
4547 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4548 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4549 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
4550 GEN_ERROR("Logical operator requires integral operands");
4551 }
4552 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4553 CHECK_FOR_ERROR
4554 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004555 break;
4556
4557 case 174:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004558#line 1916 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004559 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004560 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4561 GEN_ERROR("icmp operand types must match");
4562 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4563 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004564 break;
4565
4566 case 175:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004567#line 1921 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004568 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004569 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
4570 GEN_ERROR("fcmp operand types must match");
4571 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4572 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004573 break;
4574
4575 case 176:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576#line 1926 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004577 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004578 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
4579 GEN_ERROR("Invalid extractelement operands");
4580 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004581 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004582 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004583 break;
4584
4585 case 177:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004586#line 1932 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004587 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004588 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
4589 GEN_ERROR("Invalid insertelement operands");
4590 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004591 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004592 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004593 break;
4594
4595 case 178:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004596#line 1938 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004597 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004598 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
4599 GEN_ERROR("Invalid shufflevector operands");
4600 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004601 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004602 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004603 break;
4604
4605 case 179:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004606#line 1947 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004607 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004608 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004609 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004610 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004611 break;
4612
4613 case 180:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004614#line 1951 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4615 {
4616 (yyval.ConstVector) = new std::vector<Constant*>();
4617 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
4618 CHECK_FOR_ERROR
4619 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004620 break;
4621
4622 case 181:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004623#line 1959 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4624 { (yyval.BoolVal) = false; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004625 break;
4626
4627 case 182:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004628#line 1959 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4629 { (yyval.BoolVal) = true; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004630 break;
4631
4632 case 183:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004633#line 1962 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4634 { (yyval.BoolVal) = true; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004635 break;
4636
4637 case 184:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004638#line 1962 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4639 { (yyval.BoolVal) = false; ;}
4640 break;
4641
4642 case 185:
4643#line 1965 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004644 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004645 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4646 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004647 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4648 if (!Aliasee)
4649 GEN_ERROR("Aliases can be created only to global values");
4650
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004651 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004652 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004653 delete (yyvsp[(1) - (2)].TypeVal);
4654 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004655 break;
4656
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004657 case 186:
4658#line 1976 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004659 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004660 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4661 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4662 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004663 GEN_ERROR("invalid cast opcode for cast from '" +
4664 Val->getType()->getDescription() + "' to '" +
4665 DestTy->getDescription() + "'");
4666
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004667 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004668 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004669 delete (yyvsp[(5) - (6)].TypeVal);
4670 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004671 break;
4672
4673 case 187:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004674#line 1997 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004675 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004676 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004677 CurModule.ModuleDone();
4678 CHECK_FOR_ERROR;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004679 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004680 break;
4681
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004682 case 188:
4683#line 2002 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4684 {
4685 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4686 CurModule.ModuleDone();
4687 CHECK_FOR_ERROR;
4688 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004689 break;
4690
4691 case 191:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004692#line 2015 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4693 { CurFun.isDeclare = false; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004694 break;
4695
4696 case 192:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004697#line 2015 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4698 {
4699 CurFun.FunctionDone();
4700 CHECK_FOR_ERROR
4701 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004702 break;
4703
4704 case 193:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705#line 2019 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4706 { CurFun.isDeclare = true; ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004707 break;
4708
4709 case 194:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004710#line 2019 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004711 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004712 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004713 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004714 break;
4715
4716 case 195:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004717#line 2022 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4718 {
4719 CHECK_FOR_ERROR
4720 ;}
4721 break;
4722
4723 case 196:
4724#line 2025 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004725 {
Reid Spencer14310612006-12-31 05:40:51 +00004726 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004727 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004728 // Eagerly resolve types. This is not an optimization, this is a
4729 // requirement that is due to the fact that we could have this:
4730 //
4731 // %list = type { %list * }
4732 // %list = type { %list * } ; repeated type decl
4733 //
4734 // If types are not resolved eagerly, then the two types will not be
4735 // determined to be the same type!
4736 //
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004737 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004738
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004739 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004740 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004741 // If this is a named type that is not a redefinition, add it to the slot
4742 // table.
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004743 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004744 }
Reid Spencera132e042006-12-03 05:46:11 +00004745
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004746 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004747 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004748 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004749 break;
4750
4751 case 197:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004752#line 2049 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4753 {
4754 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4755
4756 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
4757 CHECK_FOR_ERROR
4758 // If this is a named type that is not a redefinition, add it to the slot
4759 // table.
4760 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
4761 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004762 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004763 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004764 break;
4765
4766 case 198:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004767#line 2060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4768 {
4769 /* "Externally Visible" Linkage */
4770 if ((yyvsp[(5) - (5)].ConstVal) == 0)
4771 GEN_ERROR("Global value initializer is not a constant");
4772 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4773 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
4774 CHECK_FOR_ERROR
4775 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004776 break;
4777
4778 case 199:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004779#line 2067 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004780 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004781 CurGV = 0;
4782 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004783 break;
4784
4785 case 200:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004786#line 2071 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004787 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004788 if ((yyvsp[(6) - (6)].ConstVal) == 0)
4789 GEN_ERROR("Global value initializer is not a constant");
4790 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));
4791 CHECK_FOR_ERROR
4792 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004793 break;
4794
4795 case 201:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004796#line 2076 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004797 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004798 CurGV = 0;
4799 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004800 break;
4801
4802 case 202:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004803#line 2080 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004804 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004805 if (!UpRefs.empty())
4806 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4807 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));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004808 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004809 delete (yyvsp[(6) - (6)].TypeVal);
4810 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004811 break;
4812
4813 case 203:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004814#line 2086 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004815 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004816 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004817 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004818 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004819 break;
4820
4821 case 204:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004822#line 2090 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4823 {
4824 std::string Name((yyvsp[(1) - (5)].StrVal));
4825 if (Name.empty())
4826 GEN_ERROR("Alias name cannot be empty");
4827
4828 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
4829 if (Aliasee == 0)
4830 GEN_ERROR(std::string("Invalid aliasee for alias: ") + (yyvsp[(1) - (5)].StrVal));
4831
4832 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
4833 CurModule.CurrentModule);
4834 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
4835 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004836 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004837 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004838 break;
4839
4840 case 205:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004841#line 2105 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4842 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004843 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004844 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004845 break;
4846
4847 case 206:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004848#line 2108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4849 {
4850 CHECK_FOR_ERROR
4851 ;}
4852 break;
4853
4854 case 207:
4855#line 2114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004856 {
Chris Lattner66316012006-01-24 04:14:29 +00004857 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004858 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
4859 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
4860 free((yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004861
4862 if (AsmSoFar.empty())
4863 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4864 else
4865 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004866 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004867;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004868 break;
4869
4870 case 208:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004871#line 2127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004872 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004873 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
4874 free((yyvsp[(3) - (3)].StrVal));
4875 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004876 break;
4877
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004878 case 209:
4879#line 2131 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004880 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004881 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
4882 free((yyvsp[(3) - (3)].StrVal));
4883 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004884 break;
4885
4886 case 211:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004887#line 2138 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004888 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004889 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
4890 free((yyvsp[(3) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004891 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004892 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004893 break;
4894
4895 case 212:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004896#line 2143 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004897 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004898 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
4899 free((yyvsp[(1) - (1)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004900 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004901 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004902 break;
4903
4904 case 213:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004905#line 2148 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004906 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004907 CHECK_FOR_ERROR
4908 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004909 break;
4910
4911 case 214:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004912#line 2157 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004913 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004914 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004915 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
4916 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004917 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004918 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
4919 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
4920 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004921 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004922 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004923 break;
4924
4925 case 215:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004926#line 2167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004927 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004928 if (!UpRefs.empty())
4929 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4930 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
4931 GEN_ERROR("void typed arguments are invalid");
4932 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
4933 (yyval.ArgList) = new ArgListType;
4934 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004935 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004936 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004937 break;
4938
4939 case 216:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004940#line 2178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004941 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004942 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004943 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004944 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004945 break;
4946
4947 case 217:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004948#line 2182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004949 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004950 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004951 struct ArgListEntry E;
4952 E.Ty = new PATypeHolder(Type::VoidTy);
4953 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004954 E.Attrs = ParamAttr::None;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004955 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004956 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004957 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004958 break;
4959
4960 case 218:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004961#line 2191 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004962 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004963 (yyval.ArgList) = new ArgListType;
4964 struct ArgListEntry E;
4965 E.Ty = new PATypeHolder(Type::VoidTy);
4966 E.Name = 0;
4967 E.Attrs = ParamAttr::None;
4968 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004969 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004970 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004971 break;
4972
4973 case 219:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004974#line 2200 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004975 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004976 (yyval.ArgList) = 0;
4977 CHECK_FOR_ERROR
4978 ;}
4979 break;
4980
4981 case 220:
4982#line 2206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4983 {
4984 UnEscapeLexed((yyvsp[(3) - (9)].StrVal));
4985 std::string FunctionName((yyvsp[(3) - (9)].StrVal));
4986 free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004987
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004988 // Check the function result for abstractness if this is a define. We should
4989 // have no abstract types at this point
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004990 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
4991 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004992
Reid Spencer68a24bd2005-08-27 18:50:39 +00004993 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004994 ParamAttrsVector Attrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004995 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
4996 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00004997 Attrs.push_back(PAWI);
4998 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004999 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005000 unsigned index = 1;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005001 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005002 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005003 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5004 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005005 ParamTypeList.push_back(Ty);
5006 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00005007 if (I->Attrs != ParamAttr::None) {
5008 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5009 Attrs.push_back(PAWI);
5010 }
Reid Spencer14310612006-12-31 05:40:51 +00005011 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005012 }
5013
5014 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5015 if (isVarArg) ParamTypeList.pop_back();
5016
Christopher Lamb5c104242007-04-22 20:09:11 +00005017 ParamAttrsList *PAL = 0;
5018 if (!Attrs.empty())
5019 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005020
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005021 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005022 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005023 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005024
5025 ValID ID;
5026 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005027 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005028 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005029 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005030 }
5031
5032 Function *Fn = 0;
5033 // See if this function was forward referenced. If so, recycle the object.
5034 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5035 // Move the function to the end of the list, from whereever it was
5036 // previously inserted.
5037 Fn = cast<Function>(FWRef);
5038 CurModule.CurrentModule->getFunctionList().remove(Fn);
5039 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5040 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005041 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005042 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005043 // The existing function doesn't have the same type. This is an overload
5044 // error.
5045 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
5046 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005047 // Neither the existing or the current function is a declaration and they
5048 // have the same name and same type. Clearly this is a redefinition.
5049 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005050 } if (Fn->isDeclaration()) {
5051 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005052 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5053 AI != AE; ++AI)
5054 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005055 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005056 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00005057 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00005058 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005059
Reid Spencer68a24bd2005-08-27 18:50:39 +00005060 InsertValue(Fn, CurModule.Values);
5061 }
5062
5063 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005064
5065 if (CurFun.isDeclare) {
5066 // If we have declaration, always overwrite linkage. This will allow us to
5067 // correctly handle cases, when pointer to function is passed as argument to
5068 // another function.
5069 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005070 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005071 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005072 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5073 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5074 if ((yyvsp[(8) - (9)].StrVal)) {
5075 Fn->setSection((yyvsp[(8) - (9)].StrVal));
5076 free((yyvsp[(8) - (9)].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00005077 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005078
5079 // Add all of the arguments we parsed to the function...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005080 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005081 if (isVarArg) { // Nuke the last entry
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005082 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005083 "Not a varargs marker!");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005084 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5085 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086 }
5087 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005088 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005089 unsigned Idx = 1;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005090 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5091 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005092 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00005093 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005094 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005095 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005096 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005097 }
Reid Spencera132e042006-12-03 05:46:11 +00005098
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005099 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005100 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005101 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005102;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005103 break;
5104
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005105 case 223:
5106#line 2329 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005107 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005108 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005109
5110 // Make sure that we keep track of the linkage type even if there was a
5111 // previous "declare".
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005112 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5113 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5114;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005115 break;
5116
5117 case 226:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005118#line 2340 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005119 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005120 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
5121 CHECK_FOR_ERROR
5122;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005123 break;
5124
5125 case 227:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005126#line 2345 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005127 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005128 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5129 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5130 (yyval.FunctionVal) = CurFun.CurrentFunction;
5131 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00005132 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005133 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005134 break;
5135
5136 case 228:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005137#line 2357 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005138 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005139 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005140 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005141 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005142 break;
5143
5144 case 229:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005145#line 2361 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5146 {
5147 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005148 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005149 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005150 break;
5151
5152 case 230:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005153#line 2366 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5154 { // A reference to a direct constant
5155 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005156 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005157 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005158 break;
5159
5160 case 231:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005161#line 2370 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5162 {
5163 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005164 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005165 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005166 break;
5167
5168 case 232:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005169#line 2374 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5170 { // Perhaps it's an FP constant?
5171 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005172 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005173 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005174 break;
5175
5176 case 233:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005177#line 2378 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005178 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005179 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005180 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005181 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005182 break;
5183
5184 case 234:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005185#line 2382 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005186 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005187 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005188 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005189 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005190 break;
5191
5192 case 235:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005193#line 2386 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005194 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005195 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005196 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005197 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005198 break;
5199
5200 case 236:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005201#line 2390 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5202 {
5203 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005204 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005205 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005206 break;
5207
5208 case 237:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005209#line 2394 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5210 { // A vector zero constant.
5211 (yyval.ValIDVal) = ValID::createZeroInit();
5212 CHECK_FOR_ERROR
5213 ;}
5214 break;
5215
5216 case 238:
5217#line 2398 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005218 { // Nonempty unsized packed vector
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005219 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5220 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005221
Reid Spencer9d6565a2007-02-15 02:26:10 +00005222 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005223 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005224 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005225 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005226 ETy,
5227 NumElements)
5228 )
5229 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005230
5231 // Verify all elements are correct type!
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005232 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5233 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005234 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005235 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005236 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005237 }
5238
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005239 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5240 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005241 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005242 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005243 break;
5244
5245 case 239:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005246#line 2423 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005247 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005248 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005249 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005250 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005251 break;
5252
5253 case 240:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005254#line 2427 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5255 {
5256 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5257 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5258 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5259 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5260 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5261 free((yyvsp[(3) - (5)].StrVal));
5262 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005263 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005264 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005265 break;
5266
5267 case 241:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005268#line 2441 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5269 { // Is it an integer reference...?
5270 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005271 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005272 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005273 break;
5274
5275 case 242:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005276#line 2445 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5277 {
5278 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005279 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005280 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005281 break;
5282
5283 case 243:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005284#line 2449 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005285 { // Is it a named reference...?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005286 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005287 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005288 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005289 break;
5290
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005291 case 244:
5292#line 2453 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5293 { // Is it a named reference...?
5294 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005295 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005296 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005297 break;
5298
5299 case 247:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005300#line 2465 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005301 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005302 if (!UpRefs.empty())
5303 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5304 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5305 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005306 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005307 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005308 break;
5309
5310 case 248:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005311#line 2474 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5312 {
5313 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005314 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005315 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005316 break;
5317
5318 case 249:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005319#line 2478 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5320 { // Do not allow functions with 0 basic blocks
5321 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005322 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005323 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005324 break;
5325
5326 case 250:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005327#line 2487 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005328 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005329 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005330 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005331 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5332 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5333 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
5334 CHECK_FOR_ERROR
5335 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005336 break;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005337
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005338 case 251:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005339#line 2496 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5340 {
5341 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
5342 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5343 if (CI2->getParent() == 0)
5344 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5345 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5346 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005347 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005348 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005349 break;
5350
5351 case 252:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005352#line 2505 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5353 { // Empty space between instruction lists
5354 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005355 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005356 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005357 break;
5358
5359 case 253:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005360#line 2509 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5361 { // Labelled (named) basic block
5362 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[(1) - (1)].StrVal)));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005363 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005364 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005365 break;
5366
5367 case 254:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005368#line 2514 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5369 { // Return with a result...
5370 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005371 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005372 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005373 break;
5374
5375 case 255:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005376#line 2518 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5377 { // Return with no result...
5378 (yyval.TermInstVal) = new ReturnInst();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005379 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005380 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005381 break;
5382
5383 case 256:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005384#line 2522 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5385 { // Unconditional Branch...
5386 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005387 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005388 (yyval.TermInstVal) = new BranchInst(tmpBB);
5389 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005390 break;
5391
5392 case 257:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005393#line 2527 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5394 {
5395 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5396 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005397 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005398 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005399 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005400 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5401 CHECK_FOR_ERROR
5402 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5403 ;}
5404 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005405
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005406 case 258:
5407#line 2537 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5408 {
5409 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5410 CHECK_FOR_ERROR
5411 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5412 CHECK_FOR_ERROR
5413 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5414 (yyval.TermInstVal) = S;
5415
5416 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5417 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005418 for (; I != E; ++I) {
5419 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5420 S->addCase(CI, I->second);
5421 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005422 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005423 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005424 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005425 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005426 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005427 break;
5428
5429 case 259:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005430#line 2556 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5431 {
5432 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
5433 CHECK_FOR_ERROR
5434 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
5435 CHECK_FOR_ERROR
5436 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5437 (yyval.TermInstVal) = S;
5438 CHECK_FOR_ERROR
5439 ;}
5440 break;
5441
5442 case 260:
5443#line 2566 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005444 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005445
Reid Spencer14310612006-12-31 05:40:51 +00005446 // Handle the short syntax
5447 const PointerType *PFTy = 0;
5448 const FunctionType *Ty = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005449 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005450 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5451 // Pull out the types of all of the arguments...
5452 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005453 ParamAttrsVector Attrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005454 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
Christopher Lamb5c104242007-04-22 20:09:11 +00005455 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8;
5456 Attrs.push_back(PAWI);
5457 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005458 ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005459 unsigned index = 1;
5460 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005461 const Type *Ty = I->Val->getType();
5462 if (Ty == Type::VoidTy)
5463 GEN_ERROR("Short call syntax cannot be used with varargs");
5464 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005465 if (I->Attrs != ParamAttr::None) {
5466 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5467 Attrs.push_back(PAWI);
5468 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005469 }
5470
Christopher Lamb5c104242007-04-22 20:09:11 +00005471 ParamAttrsList *PAL = 0;
5472 if (!Attrs.empty())
5473 PAL = ParamAttrsList::get(Attrs);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005474 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005475 PFTy = PointerType::get(Ty);
5476 }
5477
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005478 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005479
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005480 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005481 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005482 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005483 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005484 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005485 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005486
Reid Spencer14310612006-12-31 05:40:51 +00005487 // Check the arguments
5488 ValueList Args;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005489 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005490 // Make sure no arguments is a good thing!
5491 if (Ty->getNumParams() != 0)
5492 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005493 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005494 } else { // Has arguments?
5495 // Loop through FunctionType's arguments and ensure they are specified
5496 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005497 FunctionType::param_iterator I = Ty->param_begin();
5498 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005499 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005500
Reid Spencer14310612006-12-31 05:40:51 +00005501 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5502 if (ArgI->Val->getType() != *I)
5503 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005504 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005505 Args.push_back(ArgI->Val);
5506 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005507
Reid Spencer14310612006-12-31 05:40:51 +00005508 if (Ty->isVarArg()) {
5509 if (I == E)
5510 for (; ArgI != ArgE; ++ArgI)
5511 Args.push_back(ArgI->Val); // push the remaining varargs
5512 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005513 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005514 }
Reid Spencer14310612006-12-31 05:40:51 +00005515
5516 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005517 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005518 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5519 (yyval.TermInstVal) = II;
5520 delete (yyvsp[(6) - (14)].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005521 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005522 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005523 break;
5524
5525 case 261:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005526#line 2645 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005527 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005528 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005529 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005530 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005531 break;
5532
5533 case 262:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005534#line 2649 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005535 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005536 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005537 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005538 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005539 break;
5540
5541 case 263:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005542#line 2656 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005543 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005544 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5545 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
5546 CHECK_FOR_ERROR
5547 if (V == 0)
5548 GEN_ERROR("May only switch on a constant pool value");
5549
5550 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
5551 CHECK_FOR_ERROR
5552 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5553 ;}
5554 break;
5555
5556 case 264:
5557#line 2667 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5558 {
5559 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5560 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005561 CHECK_FOR_ERROR
5562
5563 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005564 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005565
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005566 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005567 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005568 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5569 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005570 break;
5571
5572 case 265:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005573#line 2680 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5574 {
5575 // Is this definition named?? if so, assign the name...
5576 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005577 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005578 InsertValue((yyvsp[(2) - (2)].InstVal));
5579 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005580 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005581 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005582 break;
5583
5584 case 266:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005585#line 2690 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5586 { // Used for PHI nodes
5587 if (!UpRefs.empty())
5588 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5589 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5590 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005591 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005592 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005593 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005594 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5595 delete (yyvsp[(1) - (6)].TypeVal);
5596 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005597 break;
5598
5599 case 267:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005600#line 2701 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5601 {
5602 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5603 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
5604 CHECK_FOR_ERROR
5605 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
5606 CHECK_FOR_ERROR
5607 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5608 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005609 break;
5610
5611 case 268:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005612#line 2711 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5613 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005614 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005615 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5616 // Used for call and invoke instructions
5617 (yyval.ValueRefList) = new ValueRefList();
5618 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5619 (yyval.ValueRefList)->push_back(E);
5620 delete (yyvsp[(1) - (3)].TypeVal);
5621 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005622 break;
5623
5624 case 269:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005625#line 2720 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5626 {
5627 if (!UpRefs.empty())
5628 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5629 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5630 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5631 (yyval.ValueRefList)->push_back(E);
5632 delete (yyvsp[(3) - (5)].TypeVal);
5633 CHECK_FOR_ERROR
5634 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005635 break;
5636
5637 case 270:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005638#line 2729 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5639 { (yyval.ValueRefList) = new ValueRefList(); ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005640 break;
5641
5642 case 271:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005643#line 2732 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5644 { (yyval.ValueList) = new std::vector<Value*>(); ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005645 break;
5646
5647 case 272:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005648#line 2733 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005649 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005650 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5651 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005652 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005653 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005654 break;
5655
5656 case 273:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005657#line 2740 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005658 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005659 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005660 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005661 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005662 break;
5663
5664 case 274:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005665#line 2744 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005666 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005667 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005668 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005669 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005670 break;
5671
5672 case 275:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005673#line 2749 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005674 {
Reid Spencer14310612006-12-31 05:40:51 +00005675 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005676 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5677 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5678 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
5679 GEN_ERROR(
5680 "Arithmetic operator requires integer, FP, or packed operands");
5681 if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5682 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5683 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5684 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
5685 GEN_ERROR("Remainder not supported on vector types");
5686 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005687 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005688 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005689 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005690 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5691 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005692 GEN_ERROR("binary operator returned null");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005693 delete (yyvsp[(2) - (5)].TypeVal);
5694 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005695 break;
5696
5697 case 276:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005698#line 2770 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005699 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005700 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005701 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5702 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5703 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5704 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
5705 GEN_ERROR("Logical operator requires integral operands");
5706 }
5707 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005708 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005709 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005710 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005711 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5712 if ((yyval.InstVal) == 0)
5713 GEN_ERROR("binary operator returned null");
5714 delete (yyvsp[(2) - (5)].TypeVal);
5715 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005716 break;
5717
5718 case 277:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005719#line 2787 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005720 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005721 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005722 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5723 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
5724 GEN_ERROR("Vector types not supported by icmp instruction");
5725 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005726 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005727 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005728 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005729 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5730 if ((yyval.InstVal) == 0)
5731 GEN_ERROR("icmp operator returned null");
5732 delete (yyvsp[(3) - (6)].TypeVal);
5733 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005734 break;
5735
5736 case 278:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005737#line 2801 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005738 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005739 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005740 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5741 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
5742 GEN_ERROR("Vector types not supported by fcmp instruction");
5743 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
5744 CHECK_FOR_ERROR
5745 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
5746 CHECK_FOR_ERROR
5747 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5748 if ((yyval.InstVal) == 0)
5749 GEN_ERROR("fcmp operator returned null");
5750 delete (yyvsp[(3) - (6)].TypeVal);
5751 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005752 break;
5753
5754 case 279:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005755#line 2815 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005756 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005757 if (!UpRefs.empty())
5758 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5759 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5760 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5761 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
5762 GEN_ERROR("invalid cast opcode for cast from '" +
5763 Val->getType()->getDescription() + "' to '" +
5764 DestTy->getDescription() + "'");
5765 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5766 delete (yyvsp[(4) - (4)].TypeVal);
5767 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005768 break;
5769
5770 case 280:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005771#line 2827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005772 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005773 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
5774 GEN_ERROR("select condition must be boolean");
5775 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
5776 GEN_ERROR("select value types should match");
5777 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005778 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005779 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005780 break;
5781
5782 case 281:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005783#line 2835 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005784 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005785 if (!UpRefs.empty())
5786 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5787 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5788 delete (yyvsp[(4) - (4)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005789 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005790 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005791 break;
5792
5793 case 282:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005794#line 2842 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005795 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005796 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
5797 GEN_ERROR("Invalid extractelement operands");
5798 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005799 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005800 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005801 break;
5802
5803 case 283:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005804#line 2848 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005805 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005806 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
5807 GEN_ERROR("Invalid insertelement operands");
5808 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005809 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005810 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005811 break;
5812
5813 case 284:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005814#line 2854 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005815 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005816 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
5817 GEN_ERROR("Invalid shufflevector operands");
5818 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005819 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005820 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005821 break;
5822
5823 case 285:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005824#line 2860 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5825 {
5826 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
5827 if (!Ty->isFirstClassType())
5828 GEN_ERROR("PHI node operands must be of first class type");
5829 (yyval.InstVal) = new PHINode(Ty);
5830 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5831 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5832 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
5833 GEN_ERROR("All elements of a PHI node must be of the same type");
5834 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5835 (yyvsp[(2) - (2)].PHIList)->pop_front();
5836 }
5837 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
5838 CHECK_FOR_ERROR
5839 ;}
5840 break;
5841
5842 case 286:
5843#line 2876 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005844 {
Reid Spencer14310612006-12-31 05:40:51 +00005845
5846 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005847 const PointerType *PFTy = 0;
5848 const FunctionType *Ty = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005849 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005850 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5851 // Pull out the types of all of the arguments...
5852 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005853 ParamAttrsVector Attrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005854 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
5855 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005856 Attrs.push_back(PAWI);
5857 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005858 unsigned index = 1;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005859 ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005860 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005861 const Type *Ty = I->Val->getType();
5862 if (Ty == Type::VoidTy)
5863 GEN_ERROR("Short call syntax cannot be used with varargs");
5864 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005865 if (I->Attrs != ParamAttr::None) {
5866 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5867 Attrs.push_back(PAWI);
5868 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005869 }
5870
Christopher Lamb5c104242007-04-22 20:09:11 +00005871 ParamAttrsList *PAL = 0;
5872 if (!Attrs.empty())
5873 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005874
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005875 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005876 PFTy = PointerType::get(Ty);
5877 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005878
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005879 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005880 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005881
Reid Spencer7780acb2007-04-16 06:56:07 +00005882 // Check for call to invalid intrinsic to avoid crashing later.
5883 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005884 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005885 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5886 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005887 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5888 theF->getName() + "'");
5889 }
5890
Reid Spencer14310612006-12-31 05:40:51 +00005891 // Check the arguments
5892 ValueList Args;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005893 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005894 // Make sure no arguments is a good thing!
5895 if (Ty->getNumParams() != 0)
5896 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005897 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005898 } else { // Has arguments?
5899 // Loop through FunctionType's arguments and ensure they are specified
5900 // correctly!
5901 //
5902 FunctionType::param_iterator I = Ty->param_begin();
5903 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005904 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005905
Reid Spencer14310612006-12-31 05:40:51 +00005906 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5907 if (ArgI->Val->getType() != *I)
5908 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005909 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005910 Args.push_back(ArgI->Val);
5911 }
5912 if (Ty->isVarArg()) {
5913 if (I == E)
5914 for (; ArgI != ArgE; ++ArgI)
5915 Args.push_back(ArgI->Val); // push the remaining varargs
5916 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005917 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005918 }
Reid Spencer14310612006-12-31 05:40:51 +00005919 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005920 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005921 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
5922 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
5923 (yyval.InstVal) = CI;
5924 delete (yyvsp[(6) - (8)].ValueRefList);
5925 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005926 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005927 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005928 break;
5929
5930 case 287:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005931#line 2960 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005932 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005933 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005934 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005935 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005936 break;
5937
5938 case 288:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005939#line 2965 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005940 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005941 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005942 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005943 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005944 break;
5945
5946 case 289:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005947#line 2969 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005948 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005949 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005950 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005951 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005952 break;
5953
5954 case 290:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005955#line 2976 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005956 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005957 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005958 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5959 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5960 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005961 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005962 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005963 break;
5964
5965 case 291:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005966#line 2983 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005967 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005968 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005969 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5970 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005971 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005972 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5973 delete (yyvsp[(2) - (6)].TypeVal);
5974 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005975 break;
5976
5977 case 292:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005978#line 2991 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005979 {
Reid Spencer14310612006-12-31 05:40:51 +00005980 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005981 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5982 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5983 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005984 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005985 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005986 break;
5987
5988 case 293:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005989#line 2998 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005990 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005991 if (!UpRefs.empty())
5992 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5993 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005994 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005995 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5996 delete (yyvsp[(2) - (6)].TypeVal);
5997 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005998 break;
5999
6000 case 294:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006001#line 3006 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006002 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006003 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
6004 GEN_ERROR("Trying to free nonpointer type " +
6005 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6006 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006007 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006008 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006009 break;
6010
6011 case 295:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006012#line 3014 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006013 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006014 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006015 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6016 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
6017 GEN_ERROR("Can't load from nonpointer type: " +
6018 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6019 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
6020 GEN_ERROR("Can't load from pointer of non-first-class type: " +
6021 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6022 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006023 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006024 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6025 delete (yyvsp[(3) - (5)].TypeVal);
6026 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006027 break;
6028
6029 case 296:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006030#line 3028 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006031 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006032 if (!UpRefs.empty())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006033 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6034 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
6035 if (!PT)
6036 GEN_ERROR("Can't store to a nonpointer type: " +
6037 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6038 const Type *ElTy = PT->getElementType();
6039 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6040 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
6041 "' into space of type '" + ElTy->getDescription() + "'");
6042
6043 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
6044 CHECK_FOR_ERROR
6045 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6046 delete (yyvsp[(5) - (7)].TypeVal);
6047 ;}
6048 break;
6049
6050 case 297:
6051#line 3045 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6052 {
6053 if (!UpRefs.empty())
6054 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6055 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006056 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006057
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006058 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 +00006059 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006060 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6061 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006062 CHECK_FOR_ERROR
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006063 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size());
6064 delete (yyvsp[(2) - (4)].TypeVal);
6065 delete (yyvsp[(4) - (4)].ValueList);
6066 ;}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006067 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006068
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006069
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006070/* Line 1267 of yacc.c. */
6071#line 6072 "llvmAsmParser.tab.c"
6072 default: break;
Christopher Lamb5c104242007-04-22 20:09:11 +00006073 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006074 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006075
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006076 YYPOPSTACK (yylen);
6077 yylen = 0;
6078 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006079
6080 *++yyvsp = yyval;
6081
6082
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006083 /* Now `shift' the result of the reduction. Determine what state
6084 that goes to, based on the state we popped back to and the rule
6085 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006086
6087 yyn = yyr1[yyn];
6088
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006089 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6090 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006091 yystate = yytable[yystate];
6092 else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006093 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006094
6095 goto yynewstate;
6096
6097
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006098/*------------------------------------.
6099| yyerrlab -- here on detecting error |
6100`------------------------------------*/
6101yyerrlab:
6102 /* If not already recovering from an error, report this error. */
6103 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006104 {
6105 ++yynerrs;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006106#if ! YYERROR_VERBOSE
6107 yyerror (YY_("syntax error"));
6108#else
6109 {
6110 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6111 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6112 {
6113 YYSIZE_T yyalloc = 2 * yysize;
6114 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6115 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6116 if (yymsg != yymsgbuf)
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006117 YYSTACK_FREE (yymsg);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006118 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6119 if (yymsg)
6120 yymsg_alloc = yyalloc;
6121 else
6122 {
6123 yymsg = yymsgbuf;
6124 yymsg_alloc = sizeof yymsgbuf;
6125 }
6126 }
6127
6128 if (0 < yysize && yysize <= yymsg_alloc)
6129 {
6130 (void) yysyntax_error (yymsg, yystate, yychar);
6131 yyerror (yymsg);
6132 }
6133 else
6134 {
6135 yyerror (YY_("syntax error"));
6136 if (yysize != 0)
6137 goto yyexhaustedlab;
6138 }
6139 }
6140#endif
6141 }
6142
6143
6144
6145 if (yyerrstatus == 3)
6146 {
6147 /* If just tried and failed to reuse look-ahead token after an
6148 error, discard it. */
6149
6150 if (yychar <= YYEOF)
6151 {
6152 /* Return failure if at end of input. */
6153 if (yychar == YYEOF)
6154 YYABORT;
Reid Spencer9c9b63a2007-04-28 16:07:31 +00006155 }
6156 else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006157 {
6158 yydestruct ("Error: discarding",
6159 yytoken, &yylval);
6160 yychar = YYEMPTY;
6161 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00006162 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006163
6164 /* Else will try to reuse look-ahead token after shifting the error
6165 token. */
Jeff Cohen930c0fe2007-04-29 14:43:31 +00006166 goto yyerrlab1;
Reid Spencer41dff5e2007-01-26 08:05:27 +00006167
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006168
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006169/*---------------------------------------------------.
6170| yyerrorlab -- error raised explicitly by YYERROR. |
6171`---------------------------------------------------*/
6172yyerrorlab:
6173
6174 /* Pacify compilers like GCC when the user code never invokes
6175 YYERROR and the label yyerrorlab therefore never appears in user
6176 code. */
6177 if (/*CONSTCOND*/ 0)
6178 goto yyerrorlab;
6179
6180 /* Do not reclaim the symbols of the rule which action triggered
6181 this YYERROR. */
6182 YYPOPSTACK (yylen);
6183 yylen = 0;
6184 YY_STACK_PRINT (yyss, yyssp);
6185 yystate = *yyssp;
6186 goto yyerrlab1;
6187
6188
6189/*-------------------------------------------------------------.
6190| yyerrlab1 -- common code for both syntax error and YYERROR. |
6191`-------------------------------------------------------------*/
Jeff Cohen930c0fe2007-04-29 14:43:31 +00006192yyerrlab1:
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006193 yyerrstatus = 3; /* Each real token shifted decrements this. */
6194
6195 for (;;)
6196 {
6197 yyn = yypact[yystate];
6198 if (yyn != YYPACT_NINF)
6199 {
6200 yyn += YYTERROR;
6201 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6202 {
6203 yyn = yytable[yyn];
6204 if (0 < yyn)
6205 break;
6206 }
6207 }
6208
6209 /* Pop the current state because it cannot handle the error token. */
6210 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006211 YYABORT;
6212
Reid Spencere4d87aa2006-12-23 06:05:41 +00006213
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006214 yydestruct ("Error: popping",
6215 yystos[yystate], yyvsp);
6216 YYPOPSTACK (1);
6217 yystate = *yyssp;
6218 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006219 }
6220
6221 if (yyn == YYFINAL)
6222 YYACCEPT;
6223
Reid Spencer68a24bd2005-08-27 18:50:39 +00006224 *++yyvsp = yylval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006225
6226
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006227 /* Shift the error token. */
6228 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
6229
Reid Spencer68a24bd2005-08-27 18:50:39 +00006230 yystate = yyn;
6231 goto yynewstate;
6232
Chris Lattner6cdc6822007-04-26 05:31:05 +00006233
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006234/*-------------------------------------.
6235| yyacceptlab -- YYACCEPT comes here. |
6236`-------------------------------------*/
6237yyacceptlab:
6238 yyresult = 0;
6239 goto yyreturn;
6240
6241/*-----------------------------------.
6242| yyabortlab -- YYABORT comes here. |
6243`-----------------------------------*/
6244yyabortlab:
6245 yyresult = 1;
6246 goto yyreturn;
6247
6248#ifndef yyoverflow
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006249/*-------------------------------------------------.
6250| yyexhaustedlab -- memory exhaustion comes here. |
6251`-------------------------------------------------*/
6252yyexhaustedlab:
6253 yyerror (YY_("memory exhausted"));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006254 yyresult = 2;
6255 /* Fall through. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006256#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006257
6258yyreturn:
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006259 if (yychar != YYEOF && yychar != YYEMPTY)
6260 yydestruct ("Cleanup: discarding lookahead",
6261 yytoken, &yylval);
6262 /* Do not reclaim the symbols of the rule which action triggered
6263 this YYABORT or YYACCEPT. */
6264 YYPOPSTACK (yylen);
6265 YY_STACK_PRINT (yyss, yyssp);
6266 while (yyssp != yyss)
6267 {
6268 yydestruct ("Cleanup: popping",
6269 yystos[*yyssp], yyvsp);
6270 YYPOPSTACK (1);
6271 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006272#ifndef yyoverflow
6273 if (yyss != yyssa)
6274 YYSTACK_FREE (yyss);
6275#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006276#if YYERROR_VERBOSE
6277 if (yymsg != yymsgbuf)
6278 YYSTACK_FREE (yymsg);
6279#endif
6280 /* Make sure YYID is used. */
6281 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006282}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006283
6284
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006285#line 3062 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006286
6287
Reid Spencer14310612006-12-31 05:40:51 +00006288// common code from the two 'RunVMAsmParser' functions
6289static Module* RunParser(Module * M) {
6290
6291 llvmAsmlineno = 1; // Reset the current line number...
6292 CurModule.CurrentModule = M;
6293#if YYDEBUG
6294 yydebug = Debug;
6295#endif
6296
6297 // Check to make sure the parser succeeded
6298 if (yyparse()) {
6299 if (ParserResult)
6300 delete ParserResult;
6301 return 0;
6302 }
6303
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006304 // Emit an error if there are any unresolved types left.
6305 if (!CurModule.LateResolveTypes.empty()) {
6306 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6307 if (DID.Type == ValID::LocalName) {
6308 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6309 } else {
6310 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6311 }
6312 if (ParserResult)
6313 delete ParserResult;
6314 return 0;
6315 }
6316
6317 // Emit an error if there are any unresolved values left.
6318 if (!CurModule.LateResolveValues.empty()) {
6319 Value *V = CurModule.LateResolveValues.back();
6320 std::map<Value*, std::pair<ValID, int> >::iterator I =
6321 CurModule.PlaceHolderInfo.find(V);
6322
6323 if (I != CurModule.PlaceHolderInfo.end()) {
6324 ValID &DID = I->second.first;
6325 if (DID.Type == ValID::LocalName) {
6326 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6327 } else {
6328 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6329 }
6330 if (ParserResult)
6331 delete ParserResult;
6332 return 0;
6333 }
6334 }
6335
Reid Spencer14310612006-12-31 05:40:51 +00006336 // Check to make sure that parsing produced a result
6337 if (!ParserResult)
6338 return 0;
6339
6340 // Reset ParserResult variable while saving its value for the result.
6341 Module *Result = ParserResult;
6342 ParserResult = 0;
6343
6344 return Result;
6345}
6346
Reid Spencer61c83e02006-08-18 08:43:06 +00006347void llvm::GenerateError(const std::string &message, int LineNo) {
6348 if (LineNo == -1) LineNo = llvmAsmlineno;
6349 // TODO: column number in exception
6350 if (TheParseError)
6351 TheParseError->setError(CurFilename, message, LineNo);
6352 TriggerError = 1;
6353}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006354
6355int yyerror(const char *ErrorMsg) {
6356 std::string where
6357 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6358 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006359 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6360 if (yychar != YYEMPTY && yychar != 0)
6361 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6362 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006363 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006364 return 0;
6365}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006366