blob: d09350ced8b871127de36df97ce0c7d0a228fa17 [file] [log] [blame]
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001/* A Bison parser, made by GNU Bison 2.3. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005 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
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* 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.
32
33 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. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000062#define yyparse llvmAsmparse
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,
209 HIDDEN = 390
210 };
211#endif
212/* Tokens. */
213#define ESINT64VAL 258
214#define EUINT64VAL 259
215#define ESAPINTVAL 260
216#define EUAPINTVAL 261
217#define LOCALVAL_ID 262
218#define GLOBALVAL_ID 263
219#define FPVAL 264
220#define VOID 265
221#define INTTYPE 266
222#define FLOAT 267
223#define DOUBLE 268
224#define LABEL 269
225#define TYPE 270
226#define LOCALVAR 271
227#define GLOBALVAR 272
228#define LABELSTR 273
229#define STRINGCONSTANT 274
230#define ATSTRINGCONSTANT 275
231#define ZEROINITIALIZER 276
232#define TRUETOK 277
233#define FALSETOK 278
234#define BEGINTOK 279
235#define ENDTOK 280
236#define DECLARE 281
237#define DEFINE 282
238#define GLOBAL 283
239#define CONSTANT 284
240#define SECTION 285
241#define ALIAS 286
242#define VOLATILE 287
243#define THREAD_LOCAL 288
244#define TO 289
245#define DOTDOTDOT 290
246#define NULL_TOK 291
247#define UNDEF 292
248#define INTERNAL 293
249#define LINKONCE 294
250#define WEAK 295
251#define APPENDING 296
252#define DLLIMPORT 297
253#define DLLEXPORT 298
254#define EXTERN_WEAK 299
255#define OPAQUE 300
256#define EXTERNAL 301
257#define TARGET 302
258#define TRIPLE 303
259#define ALIGN 304
260#define DEPLIBS 305
261#define CALL 306
262#define TAIL 307
263#define ASM_TOK 308
264#define MODULE 309
265#define SIDEEFFECT 310
266#define CC_TOK 311
267#define CCC_TOK 312
268#define FASTCC_TOK 313
269#define COLDCC_TOK 314
270#define X86_STDCALLCC_TOK 315
271#define X86_FASTCALLCC_TOK 316
272#define DATALAYOUT 317
273#define RET 318
274#define BR 319
275#define SWITCH 320
276#define INVOKE 321
277#define UNWIND 322
278#define UNREACHABLE 323
279#define ADD 324
280#define SUB 325
281#define MUL 326
282#define UDIV 327
283#define SDIV 328
284#define FDIV 329
285#define UREM 330
286#define SREM 331
287#define FREM 332
288#define AND 333
289#define OR 334
290#define XOR 335
291#define SHL 336
292#define LSHR 337
293#define ASHR 338
294#define ICMP 339
295#define FCMP 340
296#define EQ 341
297#define NE 342
298#define SLT 343
299#define SGT 344
300#define SLE 345
301#define SGE 346
302#define ULT 347
303#define UGT 348
304#define ULE 349
305#define UGE 350
306#define OEQ 351
307#define ONE 352
308#define OLT 353
309#define OGT 354
310#define OLE 355
311#define OGE 356
312#define ORD 357
313#define UNO 358
314#define UEQ 359
315#define UNE 360
316#define MALLOC 361
317#define ALLOCA 362
318#define FREE 363
319#define LOAD 364
320#define STORE 365
321#define GETELEMENTPTR 366
322#define TRUNC 367
323#define ZEXT 368
324#define SEXT 369
325#define FPTRUNC 370
326#define FPEXT 371
327#define BITCAST 372
328#define UITOFP 373
329#define SITOFP 374
330#define FPTOUI 375
331#define FPTOSI 376
332#define INTTOPTR 377
333#define PTRTOINT 378
334#define PHI_TOK 379
335#define SELECT 380
336#define VAARG 381
337#define EXTRACTELEMENT 382
338#define INSERTELEMENT 383
339#define SHUFFLEVECTOR 384
340#define NORETURN 385
341#define INREG 386
342#define SRET 387
343#define NOUNWIND 388
344#define DEFAULT 389
345#define HIDDEN 390
346
347
348
349
350/* Copy the first part of user declarations. */
351#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352
353#include "ParserInternals.h"
354#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000355#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356#include "llvm/Instructions.h"
357#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000358#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000359#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000360#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000361#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000362#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000363#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000364#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000365#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000367#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000368#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000369#ifndef NDEBUG
370#define YYDEBUG 1
371#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372
Reid Spencere4f47592006-08-18 17:32:55 +0000373// The following is a gross hack. In order to rid the libAsmParser library of
374// exceptions, we have to have a way of getting the yyparse function to go into
375// an error situation. So, whenever we want an error to occur, the GenerateError
376// function (see bottom of file) sets TriggerError. Then, at the end of each
377// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
378// (a goto) to put YACC in error state. Furthermore, several calls to
379// GenerateError are made from inside productions and they must simulate the
380// previous exception behavior by exiting the production immediately. We have
381// replaced these with the GEN_ERROR macro which calls GeneratError and then
382// immediately invokes YYERROR. This would be so much cleaner if it was a
383// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000384static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000385#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000386#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
387
Reid Spencer68a24bd2005-08-27 18:50:39 +0000388int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
389int yylex(); // declaration" of xxx warnings.
390int yyparse();
391
392namespace llvm {
393 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000394#if YYDEBUG
395static cl::opt<bool>
396Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
397 cl::Hidden, cl::init(false));
398#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399}
400using namespace llvm;
401
402static Module *ParserResult;
403
404// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
405// relating to upreferences in the input stream.
406//
407//#define DEBUG_UPREFS 1
408#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000409#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410#else
411#define UR_OUT(X)
412#endif
413
414#define YYERROR_VERBOSE 1
415
Chris Lattnerb475c422005-11-12 18:22:38 +0000416static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000417
418
419// This contains info used when building the body of a function. It is
420// destroyed when the function is completed.
421//
422typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000423
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424static void
Reid Spencer93c40032007-03-19 18:40:50 +0000425ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426
427static struct PerModuleInfo {
428 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000429 ValueList Values; // Module level numbered definitions
430 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000431 std::vector<PATypeHolder> Types;
432 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000433
434 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000435 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436 /// that we can resolve them later and print error messages as appropriate.
437 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
438
439 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
440 // references to global values. Global values may be referenced before they
441 // are defined, and if so, the temporary object that they represent is held
442 // here. This is used for forward references of GlobalValues.
443 //
444 typedef std::map<std::pair<const PointerType *,
445 ValID>, GlobalValue*> GlobalRefsType;
446 GlobalRefsType GlobalRefs;
447
448 void ModuleDone() {
449 // If we could not resolve some functions at function compilation time
450 // (calls to functions before they are defined), resolve them now... Types
451 // are resolved when the constant pool has been completely parsed.
452 //
453 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000454 if (TriggerError)
455 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456
457 // Check to make sure that all global value forward references have been
458 // resolved!
459 //
460 if (!GlobalRefs.empty()) {
461 std::string UndefinedReferences = "Unresolved global references exist:\n";
462
463 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
464 I != E; ++I) {
465 UndefinedReferences += " " + I->first.first->getDescription() + " " +
466 I->first.second.getName() + "\n";
467 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000468 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000469 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000470 }
471
472 Values.clear(); // Clear out function local definitions
473 Types.clear();
474 CurrentModule = 0;
475 }
476
Reid Spencer68a24bd2005-08-27 18:50:39 +0000477 // GetForwardRefForGlobal - Check to see if there is a forward reference
478 // for this global. If so, remove it from the GlobalRefs map and return it.
479 // If not, just return null.
480 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
481 // Check to see if there is a forward reference to this global variable...
482 // if there is, eliminate it and patch the reference to use the new def'n.
483 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
484 GlobalValue *Ret = 0;
485 if (I != GlobalRefs.end()) {
486 Ret = I->second;
487 GlobalRefs.erase(I);
488 }
489 return Ret;
490 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000491
492 bool TypeIsUnresolved(PATypeHolder* PATy) {
493 // If it isn't abstract, its resolved
494 const Type* Ty = PATy->get();
495 if (!Ty->isAbstract())
496 return false;
497 // Traverse the type looking for abstract types. If it isn't abstract then
498 // we don't need to traverse that leg of the type.
499 std::vector<const Type*> WorkList, SeenList;
500 WorkList.push_back(Ty);
501 while (!WorkList.empty()) {
502 const Type* Ty = WorkList.back();
503 SeenList.push_back(Ty);
504 WorkList.pop_back();
505 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
506 // Check to see if this is an unresolved type
507 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
508 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
509 for ( ; I != E; ++I) {
510 if (I->second.get() == OpTy)
511 return true;
512 }
513 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
514 const Type* TheTy = SeqTy->getElementType();
515 if (TheTy->isAbstract() && TheTy != Ty) {
516 std::vector<const Type*>::iterator I = SeenList.begin(),
517 E = SeenList.end();
518 for ( ; I != E; ++I)
519 if (*I == TheTy)
520 break;
521 if (I == E)
522 WorkList.push_back(TheTy);
523 }
524 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
525 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
526 const Type* TheTy = StrTy->getElementType(i);
527 if (TheTy->isAbstract() && TheTy != Ty) {
528 std::vector<const Type*>::iterator I = SeenList.begin(),
529 E = SeenList.end();
530 for ( ; I != E; ++I)
531 if (*I == TheTy)
532 break;
533 if (I == E)
534 WorkList.push_back(TheTy);
535 }
536 }
537 }
538 }
539 return false;
540 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000541} CurModule;
542
543static struct PerFunctionInfo {
544 Function *CurrentFunction; // Pointer to current function being created
545
Reid Spencer93c40032007-03-19 18:40:50 +0000546 ValueList Values; // Keep track of #'d definitions
547 unsigned NextValNum;
548 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000549 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000550 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000551 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552
553 /// BBForwardRefs - When we see forward references to basic blocks, keep
554 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000555 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000556
557 inline PerFunctionInfo() {
558 CurrentFunction = 0;
559 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000560 Linkage = GlobalValue::ExternalLinkage;
561 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562 }
563
564 inline void FunctionStart(Function *M) {
565 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000566 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000567 }
568
569 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000571 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000572 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000573 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000574 return;
575 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576
577 // Resolve all forward references now.
578 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
579
580 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000581 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582 CurrentFunction = 0;
583 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000584 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000585 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586 }
587} CurFun; // Info for the current function...
588
589static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
590
591
592//===----------------------------------------------------------------------===//
593// Code to handle definitions of all the types
594//===----------------------------------------------------------------------===//
595
Reid Spencer93c40032007-03-19 18:40:50 +0000596static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
597 // Things that have names or are void typed don't get slot numbers
598 if (V->hasName() || (V->getType() == Type::VoidTy))
599 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600
Reid Spencer93c40032007-03-19 18:40:50 +0000601 // In the case of function values, we have to allow for the forward reference
602 // of basic blocks, which are included in the numbering. Consequently, we keep
603 // track of the next insertion location with NextValNum. When a BB gets
604 // inserted, it could change the size of the CurFun.Values vector.
605 if (&ValueTab == &CurFun.Values) {
606 if (ValueTab.size() <= CurFun.NextValNum)
607 ValueTab.resize(CurFun.NextValNum+1);
608 ValueTab[CurFun.NextValNum++] = V;
609 return;
610 }
611 // For all other lists, its okay to just tack it on the back of the vector.
612 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613}
614
615static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
616 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000617 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000619 if (D.Num < CurModule.Types.size())
620 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000622 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
624 D.destroy(); // Free old strdup'd memory...
625 return N;
626 }
627 break;
628 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000629 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000630 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631 }
632
633 // If we reached here, we referenced either a symbol that we don't know about
634 // or an id number that hasn't been read yet. We may be referencing something
635 // forward, so just create an entry to be resolved later and get to it...
636 //
637 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
638
639
640 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000641 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000642 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000643 return 0;
644 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000645 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000646 return 0;
647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648 }
649
Reid Spencer861d9d62006-11-28 07:29:44 +0000650 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000652 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653
Reid Spencer861d9d62006-11-28 07:29:44 +0000654 Type *Typ = OpaqueType::get();
655 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
656 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000657 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000658
Reid Spencer93c40032007-03-19 18:40:50 +0000659// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660// the provided ValID. If the value exists and has already been defined, return
661// it. Otherwise return null.
662//
Reid Spencer93c40032007-03-19 18:40:50 +0000663static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000664 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000665 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000667 return 0;
668 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669
670 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000672 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000673 if (D.Num >= CurFun.Values.size())
674 return 0;
675 Value *Result = CurFun.Values[D.Num];
676 if (Ty != Result->getType()) {
677 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
678 Result->getType()->getDescription() + "' does not match "
679 "expected type, '" + Ty->getDescription() + "'");
680 return 0;
681 }
682 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000683 }
684 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000685 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000686 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000687 Value *Result = CurModule.Values[D.Num];
688 if (Ty != Result->getType()) {
689 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
690 Result->getType()->getDescription() + "' does not match "
691 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000692 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000693 }
694 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000695 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000696
697 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000698 if (!inFunctionScope())
699 return 0;
700 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
701 Value *N = SymTab.lookup(D.Name);
702 if (N == 0)
703 return 0;
704 if (N->getType() != Ty)
705 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000706
707 D.destroy(); // Free old strdup'd memory...
708 return N;
709 }
710 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000711 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
712 Value *N = SymTab.lookup(D.Name);
713 if (N == 0)
714 return 0;
715 if (N->getType() != Ty)
716 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717
718 D.destroy(); // Free old strdup'd memory...
719 return N;
720 }
721
722 // Check to make sure that "Ty" is an integral type, and that our
723 // value will fit into the specified type...
724 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000725 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000726 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000728 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000729 return 0;
730 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000731 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732
733 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000734 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
735 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000736 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000737 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000738 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000740 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 }
742 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000743 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000744 }
745
746 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000747 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000748 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000749 return 0;
750 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000751 return ConstantFP::get(Ty, D.ConstPoolFP);
752
753 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000754 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000755 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 return 0;
757 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000758 return ConstantPointerNull::get(cast<PointerType>(Ty));
759
760 case ValID::ConstUndefVal: // Is it an undef value?
761 return UndefValue::get(Ty);
762
Chris Lattner7aa61892005-12-21 17:53:23 +0000763 case ValID::ConstZeroVal: // Is it a zero value?
764 return Constant::getNullValue(Ty);
765
Reid Spencer68a24bd2005-08-27 18:50:39 +0000766 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 return D.ConstantValue;
772
Chris Lattner0e9c3762006-01-25 22:27:16 +0000773 case ValID::InlineAsmVal: { // Inline asm expression
774 const PointerType *PTy = dyn_cast<PointerType>(Ty);
775 const FunctionType *FTy =
776 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000778 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000781 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
782 D.IAD->HasSideEffects);
783 D.destroy(); // Free InlineAsmDescriptor.
784 return IA;
785 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000787 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000788 return 0;
789 } // End of switch
790
Reid Spencera9720f52007-02-05 17:04:00 +0000791 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792 return 0;
793}
794
Reid Spencer93c40032007-03-19 18:40:50 +0000795// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796// value is not already defined, it "improvises" by creating a placeholder var
797// that looks and acts just like the requested variable. When the value is
798// defined later, all uses of the placeholder variable are replaced with the
799// real thing.
800//
801static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000803 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return 0;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806
807 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000808 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000811
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000813 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 return 0;
815 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816
817 // If we reached here, we referenced either a symbol that we don't know about
818 // or an id number that hasn't been read yet. We may be referencing something
819 // forward, so just create an entry to be resolved later and get to it...
820 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000821 switch (ID.Type) {
822 case ValID::GlobalName:
823 case ValID::GlobalID:
824 const PointerType *PTy = dyn_cast<PointerType>(Ty);
825 if (!PTy) {
826 GenerateError("Invalid type for reference to global" );
827 return 0;
828 }
829 const Type* ElTy = PTy->getElementType();
830 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
831 V = new Function(FTy, GlobalValue::ExternalLinkage);
832 else
833 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
834 break;
835 default:
836 V = new Argument(Ty);
837 }
838
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839 // Remember where this forward reference came from. FIXME, shouldn't we try
840 // to recycle these things??
841 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
842 llvmAsmlineno)));
843
844 if (inFunctionScope())
845 InsertValue(V, CurFun.LateResolveValues);
846 else
847 InsertValue(V, CurModule.LateResolveValues);
848 return V;
849}
850
Reid Spencer93c40032007-03-19 18:40:50 +0000851/// defineBBVal - This is a definition of a new basic block with the specified
852/// identifier which must be the same as CurFun.NextValNum, if its numeric.
853static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000854 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000855
Reid Spencer68a24bd2005-08-27 18:50:39 +0000856 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000857
Reid Spencer93c40032007-03-19 18:40:50 +0000858 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859
Reid Spencer93c40032007-03-19 18:40:50 +0000860 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
861 if (BBI != CurFun.BBForwardRefs.end()) {
862 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863 // The forward declaration could have been inserted anywhere in the
864 // function: insert it into the correct place now.
865 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
866 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000867
Reid Spencer66728ef2007-03-20 01:13:36 +0000868 // We're about to erase the entry, save the key so we can clean it up.
869 ValID Tmp = BBI->first;
870
Reid Spencer93c40032007-03-19 18:40:50 +0000871 // Erase the forward ref from the map as its no longer "forward"
872 CurFun.BBForwardRefs.erase(ID);
873
Reid Spencer66728ef2007-03-20 01:13:36 +0000874 // The key has been removed from the map but so we don't want to leave
875 // strdup'd memory around so destroy it too.
876 Tmp.destroy();
877
Reid Spencer93c40032007-03-19 18:40:50 +0000878 // If its a numbered definition, bump the number and set the BB value.
879 if (ID.Type == ValID::LocalID) {
880 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
881 InsertValue(BB);
882 }
883
884 ID.destroy();
885 return BB;
886 }
887
888 // We haven't seen this BB before and its first mention is a definition.
889 // Just create it and return it.
890 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
891 BB = new BasicBlock(Name, CurFun.CurrentFunction);
892 if (ID.Type == ValID::LocalID) {
893 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
894 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000895 }
Reid Spencer93c40032007-03-19 18:40:50 +0000896
897 ID.destroy(); // Free strdup'd memory
898 return BB;
899}
900
901/// getBBVal - get an existing BB value or create a forward reference for it.
902///
903static BasicBlock *getBBVal(const ValID &ID) {
904 assert(inFunctionScope() && "Can't get basic block at global scope!");
905
906 BasicBlock *BB = 0;
907
908 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
909 if (BBI != CurFun.BBForwardRefs.end()) {
910 BB = BBI->second;
911 } if (ID.Type == ValID::LocalName) {
912 std::string Name = ID.Name;
913 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
914 if (N)
915 if (N->getType()->getTypeID() == Type::LabelTyID)
916 BB = cast<BasicBlock>(N);
917 else
918 GenerateError("Reference to label '" + Name + "' is actually of type '"+
919 N->getType()->getDescription() + "'");
920 } else if (ID.Type == ValID::LocalID) {
921 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
922 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
923 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
924 else
925 GenerateError("Reference to label '%" + utostr(ID.Num) +
926 "' is actually of type '"+
927 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
928 }
929 } else {
930 GenerateError("Illegal label reference " + ID.getName());
931 return 0;
932 }
933
934 // If its already been defined, return it now.
935 if (BB) {
936 ID.destroy(); // Free strdup'd memory.
937 return BB;
938 }
939
940 // Otherwise, this block has not been seen before, create it.
941 std::string Name;
942 if (ID.Type == ValID::LocalName)
943 Name = ID.Name;
944 BB = new BasicBlock(Name, CurFun.CurrentFunction);
945
946 // Insert it in the forward refs map.
947 CurFun.BBForwardRefs[ID] = BB;
948
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949 return BB;
950}
951
952
953//===----------------------------------------------------------------------===//
954// Code to handle forward references in instructions
955//===----------------------------------------------------------------------===//
956//
957// This code handles the late binding needed with statements that reference
958// values not defined yet... for example, a forward branch, or the PHI node for
959// a loop body.
960//
961// This keeps a table (CurFun.LateResolveValues) of all such forward references
962// and back patchs after we are done.
963//
964
965// ResolveDefinitions - If we could not resolve some defs at parsing
966// time (forward branches, phi functions for loops, etc...) resolve the
967// defs now...
968//
969static void
Reid Spencer93c40032007-03-19 18:40:50 +0000970ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000972 while (!LateResolvers.empty()) {
973 Value *V = LateResolvers.back();
974 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000975
Reid Spencer93c40032007-03-19 18:40:50 +0000976 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
977 CurModule.PlaceHolderInfo.find(V);
978 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979
Reid Spencer93c40032007-03-19 18:40:50 +0000980 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981
Reid Spencer93c40032007-03-19 18:40:50 +0000982 Value *TheRealValue = getExistingVal(V->getType(), DID);
983 if (TriggerError)
984 return;
985 if (TheRealValue) {
986 V->replaceAllUsesWith(TheRealValue);
987 delete V;
988 CurModule.PlaceHolderInfo.erase(PHI);
989 } else if (FutureLateResolvers) {
990 // Functions have their unresolved items forwarded to the module late
991 // resolver table
992 InsertValue(V, *FutureLateResolvers);
993 } else {
994 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
995 GenerateError("Reference to an invalid definition: '" +DID.getName()+
996 "' of type '" + V->getType()->getDescription() + "'",
997 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000998 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000999 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001000 GenerateError("Reference to an invalid definition: #" +
1001 itostr(DID.Num) + " of type '" +
1002 V->getType()->getDescription() + "'",
1003 PHI->second.second);
1004 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001005 }
1006 }
1007 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008 LateResolvers.clear();
1009}
1010
1011// ResolveTypeTo - A brand new type was just declared. This means that (if
1012// name is not null) things referencing Name can be resolved. Otherwise, things
1013// refering to the number can be resolved. Do this now.
1014//
1015static void ResolveTypeTo(char *Name, const Type *ToTy) {
1016 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +00001017 if (Name) D = ValID::createLocalName(Name);
1018 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019
Reid Spencer861d9d62006-11-28 07:29:44 +00001020 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021 CurModule.LateResolveTypes.find(D);
1022 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001023 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024 CurModule.LateResolveTypes.erase(I);
1025 }
1026}
1027
1028// setValueName - Set the specified value to the name given. The name may be
1029// null potentially, in which case this is a noop. The string passed in is
1030// assumed to be a malloc'd string buffer, and is free'd by this function.
1031//
1032static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001033 if (!NameStr) return;
1034 std::string Name(NameStr); // Copy string
1035 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036
Reid Spencer41dff5e2007-01-26 08:05:27 +00001037 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001038 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001039 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001041
Reid Spencera9720f52007-02-05 17:04:00 +00001042 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001043 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1044 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001045 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001046 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001047 return;
1048 }
1049
1050 // Set the name.
1051 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052}
1053
1054/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1055/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001056static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001057ParseGlobalVariable(char *NameStr,
1058 GlobalValue::LinkageTypes Linkage,
1059 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001060 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001061 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001062 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001063 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001064 return 0;
1065 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001066
1067 const PointerType *PTy = PointerType::get(Ty);
1068
1069 std::string Name;
1070 if (NameStr) {
1071 Name = NameStr; // Copy string
1072 free(NameStr); // Free old string
1073 }
1074
1075 // See if this global value was forward referenced. If so, recycle the
1076 // object.
1077 ValID ID;
1078 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001079 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001080 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001081 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082 }
1083
1084 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1085 // Move the global to the end of the list, from whereever it was
1086 // previously inserted.
1087 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1088 CurModule.CurrentModule->getGlobalList().remove(GV);
1089 CurModule.CurrentModule->getGlobalList().push_back(GV);
1090 GV->setInitializer(Initializer);
1091 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001092 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001093 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001094 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001095 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001096 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001097 }
1098
Reid Spenceref9b9a72007-02-05 20:47:22 +00001099 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001100 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001101 // if the global we're parsing has an initializer (is a definition) and
1102 // has external linkage.
1103 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1104 // If there is already a global with external linkage with this name
1105 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1106 // If we allow this GVar to get created, it will be renamed in the
1107 // symbol table because it conflicts with an existing GVar. We can't
1108 // allow redefinition of GVars whose linking indicates that their name
1109 // must stay the same. Issue the error.
1110 GenerateError("Redefinition of global variable named '" + Name +
1111 "' of type '" + Ty->getDescription() + "'");
1112 return 0;
1113 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001114 }
1115
1116 // Otherwise there is no existing GV to use, create one now.
1117 GlobalVariable *GV =
1118 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001119 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001120 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001121 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001122 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001123}
1124
1125// setTypeName - Set the specified type to the name given. The name may be
1126// null potentially, in which case this is a noop. The string passed in is
1127// assumed to be a malloc'd string buffer, and is freed by this function.
1128//
1129// This function returns true if the type has already been defined, but is
1130// allowed to be redefined in the specified context. If the name is a new name
1131// for the type plane, it is inserted and false is returned.
1132static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001133 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001134 if (NameStr == 0) return false;
1135
1136 std::string Name(NameStr); // Copy string
1137 free(NameStr); // Free old string
1138
1139 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001140 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001141 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001142 return false;
1143 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001144
1145 // Set the type name, checking for conflicts as we do so.
1146 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1147
1148 if (AlreadyExists) { // Inserting a name that is already defined???
1149 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001150 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151
1152 // There is only one case where this is allowed: when we are refining an
1153 // opaque type. In this case, Existing will be an opaque type.
1154 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1155 // We ARE replacing an opaque type!
1156 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1157 return true;
1158 }
1159
1160 // Otherwise, this is an attempt to redefine a type. That's okay if
1161 // the redefinition is identical to the original. This will be so if
1162 // Existing and T point to the same Type object. In this one case we
1163 // allow the equivalent redefinition.
1164 if (Existing == T) return true; // Yes, it's equal.
1165
1166 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001167 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001168 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001169 }
1170
1171 return false;
1172}
1173
1174//===----------------------------------------------------------------------===//
1175// Code for handling upreferences in type names...
1176//
1177
1178// TypeContains - Returns true if Ty directly contains E in it.
1179//
1180static bool TypeContains(const Type *Ty, const Type *E) {
1181 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1182 E) != Ty->subtype_end();
1183}
1184
1185namespace {
1186 struct UpRefRecord {
1187 // NestingLevel - The number of nesting levels that need to be popped before
1188 // this type is resolved.
1189 unsigned NestingLevel;
1190
1191 // LastContainedTy - This is the type at the current binding level for the
1192 // type. Every time we reduce the nesting level, this gets updated.
1193 const Type *LastContainedTy;
1194
1195 // UpRefTy - This is the actual opaque type that the upreference is
1196 // represented with.
1197 OpaqueType *UpRefTy;
1198
1199 UpRefRecord(unsigned NL, OpaqueType *URTy)
1200 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1201 };
1202}
1203
1204// UpRefs - A list of the outstanding upreferences that need to be resolved.
1205static std::vector<UpRefRecord> UpRefs;
1206
1207/// HandleUpRefs - Every time we finish a new layer of types, this function is
1208/// called. It loops through the UpRefs vector, which is a list of the
1209/// currently active types. For each type, if the up reference is contained in
1210/// the newly completed type, we decrement the level count. When the level
1211/// count reaches zero, the upreferenced type is the type that is passed in:
1212/// thus we can complete the cycle.
1213///
1214static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001215 // If Ty isn't abstract, or if there are no up-references in it, then there is
1216 // nothing to resolve here.
1217 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1218
Reid Spencer68a24bd2005-08-27 18:50:39 +00001219 PATypeHolder Ty(ty);
1220 UR_OUT("Type '" << Ty->getDescription() <<
1221 "' newly formed. Resolving upreferences.\n" <<
1222 UpRefs.size() << " upreferences active!\n");
1223
1224 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1225 // to zero), we resolve them all together before we resolve them to Ty. At
1226 // the end of the loop, if there is anything to resolve to Ty, it will be in
1227 // this variable.
1228 OpaqueType *TypeToResolve = 0;
1229
1230 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1231 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1232 << UpRefs[i].second->getDescription() << ") = "
1233 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1234 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1235 // Decrement level of upreference
1236 unsigned Level = --UpRefs[i].NestingLevel;
1237 UpRefs[i].LastContainedTy = Ty;
1238 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1239 if (Level == 0) { // Upreference should be resolved!
1240 if (!TypeToResolve) {
1241 TypeToResolve = UpRefs[i].UpRefTy;
1242 } else {
1243 UR_OUT(" * Resolving upreference for "
1244 << UpRefs[i].second->getDescription() << "\n";
1245 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1246 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1247 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1248 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1249 }
1250 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1251 --i; // Do not skip the next element...
1252 }
1253 }
1254 }
1255
1256 if (TypeToResolve) {
1257 UR_OUT(" * Resolving upreference for "
1258 << UpRefs[i].second->getDescription() << "\n";
1259 std::string OldName = TypeToResolve->getDescription());
1260 TypeToResolve->refineAbstractTypeTo(Ty);
1261 }
1262
1263 return Ty;
1264}
1265
Reid Spencer68a24bd2005-08-27 18:50:39 +00001266//===----------------------------------------------------------------------===//
1267// RunVMAsmParser - Define an interface to this parser
1268//===----------------------------------------------------------------------===//
1269//
Reid Spencer14310612006-12-31 05:40:51 +00001270static Module* RunParser(Module * M);
1271
Reid Spencer68a24bd2005-08-27 18:50:39 +00001272Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1273 set_scan_file(F);
1274
1275 CurFilename = Filename;
1276 return RunParser(new Module(CurFilename));
1277}
1278
1279Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1280 set_scan_string(AsmString);
1281
1282 CurFilename = "from_memory";
1283 if (M == NULL) {
1284 return RunParser(new Module (CurFilename));
1285 } else {
1286 return RunParser(M);
1287 }
1288}
1289
1290
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001291
1292/* Enabling traces. */
1293#ifndef YYDEBUG
1294# define YYDEBUG 0
1295#endif
1296
1297/* Enabling verbose error messages. */
1298#ifdef YYERROR_VERBOSE
1299# undef YYERROR_VERBOSE
1300# define YYERROR_VERBOSE 1
1301#else
1302# define YYERROR_VERBOSE 0
1303#endif
1304
1305/* Enabling the token table. */
1306#ifndef YYTOKEN_TABLE
1307# define YYTOKEN_TABLE 0
1308#endif
1309
1310#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1311typedef union YYSTYPE
1312#line 954 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
1313{
Reid Spencer68a24bd2005-08-27 18:50:39 +00001314 llvm::Module *ModuleVal;
1315 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001316 llvm::BasicBlock *BasicBlockVal;
1317 llvm::TerminatorInst *TermInstVal;
1318 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001319 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001320
Reid Spencera132e042006-12-03 05:46:11 +00001321 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001322 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001323 llvm::PATypeHolder *TypeVal;
1324 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001325 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001326 llvm::ArgListType *ArgList;
1327 llvm::TypeWithAttrs TypeWithAttrs;
1328 llvm::TypeWithAttrsList *TypeWithAttrsList;
1329 llvm::ValueRefList *ValueRefList;
1330
Reid Spencer68a24bd2005-08-27 18:50:39 +00001331 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001332 std::list<std::pair<llvm::Value*,
1333 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001335 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001336
1337 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001338 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001339 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001340 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001341 int64_t SInt64Val;
1342 uint64_t UInt64Val;
1343 int SIntVal;
1344 unsigned UIntVal;
1345 double FPVal;
1346 bool BoolVal;
1347
1348 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001349 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350
Reid Spencera132e042006-12-03 05:46:11 +00001351 llvm::Instruction::BinaryOps BinaryOpVal;
1352 llvm::Instruction::TermOps TermOpVal;
1353 llvm::Instruction::MemoryOps MemOpVal;
1354 llvm::Instruction::CastOps CastOpVal;
1355 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001356 llvm::ICmpInst::Predicate IPredicate;
1357 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001358}
1359/* Line 187 of yacc.c. */
1360#line 1361 "llvmAsmParser.tab.c"
1361 YYSTYPE;
1362# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1363# define YYSTYPE_IS_DECLARED 1
1364# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365#endif
1366
Reid Spencer41dff5e2007-01-26 08:05:27 +00001367
Reid Spencer68a24bd2005-08-27 18:50:39 +00001368
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001369/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370
1371
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001372/* Line 216 of yacc.c. */
1373#line 1374 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001374
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001375#ifdef short
1376# undef short
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001377#endif
1378
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001379#ifdef YYTYPE_UINT8
1380typedef YYTYPE_UINT8 yytype_uint8;
Reid Spencer7780acb2007-04-16 06:56:07 +00001381#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001382typedef unsigned char yytype_uint8;
Reid Spencer7780acb2007-04-16 06:56:07 +00001383#endif
1384
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001385#ifdef YYTYPE_INT8
1386typedef YYTYPE_INT8 yytype_int8;
1387#elif (defined __STDC__ || defined __C99__FUNC__ \
1388 || defined __cplusplus || defined _MSC_VER)
1389typedef signed char yytype_int8;
1390#else
1391typedef short int yytype_int8;
1392#endif
1393
1394#ifdef YYTYPE_UINT16
1395typedef YYTYPE_UINT16 yytype_uint16;
1396#else
1397typedef unsigned short int yytype_uint16;
1398#endif
1399
1400#ifdef YYTYPE_INT16
1401typedef YYTYPE_INT16 yytype_int16;
1402#else
1403typedef short int yytype_int16;
1404#endif
1405
1406#ifndef YYSIZE_T
1407# ifdef __SIZE_TYPE__
1408# define YYSIZE_T __SIZE_TYPE__
1409# elif defined size_t
1410# define YYSIZE_T size_t
1411# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1412 || defined __cplusplus || defined _MSC_VER)
1413# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1414# define YYSIZE_T size_t
1415# else
1416# define YYSIZE_T unsigned int
1417# endif
1418#endif
1419
1420#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1421
1422#ifndef YY_
1423# if YYENABLE_NLS
1424# if ENABLE_NLS
1425# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1426# define YY_(msgid) dgettext ("bison-runtime", msgid)
1427# endif
1428# endif
1429# ifndef YY_
1430# define YY_(msgid) msgid
1431# endif
1432#endif
1433
1434/* Suppress unused-variable warnings by "using" E. */
1435#if ! defined lint || defined __GNUC__
1436# define YYUSE(e) ((void) (e))
1437#else
1438# define YYUSE(e) /* empty */
1439#endif
1440
1441/* Identity function, used to suppress warnings about constant conditions. */
1442#ifndef lint
1443# define YYID(n) (n)
1444#else
1445#if (defined __STDC__ || defined __C99__FUNC__ \
1446 || defined __cplusplus || defined _MSC_VER)
1447static int
1448YYID (int i)
1449#else
1450static int
1451YYID (i)
1452 int i;
1453#endif
1454{
1455 return i;
1456}
1457#endif
1458
1459#if ! defined yyoverflow || YYERROR_VERBOSE
1460
1461/* The parser invokes alloca or malloc; define the necessary symbols. */
1462
1463# ifdef YYSTACK_USE_ALLOCA
1464# if YYSTACK_USE_ALLOCA
1465# ifdef __GNUC__
1466# define YYSTACK_ALLOC __builtin_alloca
1467# elif defined __BUILTIN_VA_ARG_INCR
1468# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1469# elif defined _AIX
1470# define YYSTACK_ALLOC __alloca
1471# elif defined _MSC_VER
1472# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1473# define alloca _alloca
1474# else
1475# define YYSTACK_ALLOC alloca
1476# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1477 || defined __cplusplus || defined _MSC_VER)
1478# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1479# ifndef _STDLIB_H
1480# define _STDLIB_H 1
1481# endif
1482# endif
1483# endif
1484# endif
1485# endif
1486
1487# ifdef YYSTACK_ALLOC
1488 /* Pacify GCC's `empty if-body' warning. */
1489# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1490# ifndef YYSTACK_ALLOC_MAXIMUM
1491 /* The OS might guarantee only one guard page at the bottom of the stack,
1492 and a page size can be as small as 4096 bytes. So we cannot safely
1493 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1494 to allow for a few compiler-allocated temporary stack slots. */
1495# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1496# endif
1497# else
1498# define YYSTACK_ALLOC YYMALLOC
1499# define YYSTACK_FREE YYFREE
1500# ifndef YYSTACK_ALLOC_MAXIMUM
1501# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1502# endif
1503# if (defined __cplusplus && ! defined _STDLIB_H \
1504 && ! ((defined YYMALLOC || defined malloc) \
1505 && (defined YYFREE || defined free)))
1506# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1507# ifndef _STDLIB_H
1508# define _STDLIB_H 1
1509# endif
1510# endif
1511# ifndef YYMALLOC
1512# define YYMALLOC malloc
1513# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1514 || defined __cplusplus || defined _MSC_VER)
1515void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1516# endif
1517# endif
1518# ifndef YYFREE
1519# define YYFREE free
1520# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1521 || defined __cplusplus || defined _MSC_VER)
1522void free (void *); /* INFRINGES ON USER NAME SPACE */
1523# endif
1524# endif
1525# endif
1526#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1527
1528
1529#if (! defined yyoverflow \
1530 && (! defined __cplusplus \
1531 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1532
1533/* A type that is properly aligned for any stack member. */
1534union yyalloc
1535{
1536 yytype_int16 yyss;
1537 YYSTYPE yyvs;
1538 };
1539
1540/* The size of the maximum gap between one aligned stack and the next. */
1541# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1542
1543/* The size of an array large to enough to hold all stacks, each with
1544 N elements. */
1545# define YYSTACK_BYTES(N) \
1546 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1547 + YYSTACK_GAP_MAXIMUM)
1548
1549/* Copy COUNT objects from FROM to TO. The source and destination do
1550 not overlap. */
1551# ifndef YYCOPY
1552# if defined __GNUC__ && 1 < __GNUC__
1553# define YYCOPY(To, From, Count) \
1554 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1555# else
1556# define YYCOPY(To, From, Count) \
1557 do \
1558 { \
1559 YYSIZE_T yyi; \
1560 for (yyi = 0; yyi < (Count); yyi++) \
1561 (To)[yyi] = (From)[yyi]; \
1562 } \
1563 while (YYID (0))
1564# endif
1565# endif
1566
1567/* Relocate STACK from its old location to the new one. The
1568 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1569 elements in the stack, and YYPTR gives the new location of the
1570 stack. Advance YYPTR to a properly aligned location for the next
1571 stack. */
1572# define YYSTACK_RELOCATE(Stack) \
1573 do \
1574 { \
1575 YYSIZE_T yynewbytes; \
1576 YYCOPY (&yyptr->Stack, Stack, yysize); \
1577 Stack = &yyptr->Stack; \
1578 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1579 yyptr += yynewbytes / sizeof (*yyptr); \
1580 } \
1581 while (YYID (0))
1582
1583#endif
1584
1585/* YYFINAL -- State number of the termination state. */
1586#define YYFINAL 41
1587/* YYLAST -- Last index in YYTABLE. */
1588#define YYLAST 1600
1589
1590/* YYNTOKENS -- Number of terminals. */
1591#define YYNTOKENS 150
1592/* YYNNTS -- Number of nonterminals. */
1593#define YYNNTS 82
1594/* YYNRULES -- Number of rules. */
1595#define YYNRULES 296
1596/* YYNRULES -- Number of states. */
1597#define YYNSTATES 580
1598
1599/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1600#define YYUNDEFTOK 2
1601#define YYMAXUTOK 390
1602
1603#define YYTRANSLATE(YYX) \
1604 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1605
1606/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1607static const yytype_uint8 yytranslate[] =
1608{
1609 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1613 140, 141, 138, 2, 137, 2, 2, 2, 2, 2,
1614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1615 145, 136, 146, 2, 2, 2, 2, 2, 2, 2,
1616 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1618 2, 142, 139, 144, 2, 2, 2, 2, 2, 149,
1619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1620 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1621 143, 2, 2, 147, 2, 148, 2, 2, 2, 2,
1622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1623 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1624 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1625 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, 1, 2, 3, 4,
1635 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1636 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1637 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1638 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1639 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1640 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1641 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1642 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1643 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1644 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1645 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1646 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1647 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1648 135
1649};
1650
1651#if YYDEBUG
1652/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1653 YYRHS. */
1654static const yytype_uint16 yyprhs[] =
1655{
1656 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1657 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1658 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1659 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1660 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1661 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1662 119, 121, 122, 125, 126, 128, 130, 132, 133, 136,
1663 138, 140, 142, 144, 146, 148, 150, 152, 153, 155,
1664 157, 158, 160, 162, 163, 165, 167, 169, 171, 172,
1665 174, 176, 177, 179, 181, 183, 185, 187, 190, 192,
1666 194, 196, 198, 199, 202, 204, 206, 208, 209, 212,
1667 213, 216, 217, 221, 224, 225, 227, 228, 232, 234,
1668 237, 239, 241, 243, 245, 247, 249, 252, 254, 257,
1669 263, 269, 275, 281, 285, 288, 294, 299, 302, 304,
1670 306, 308, 312, 314, 318, 320, 321, 323, 327, 332,
1671 336, 340, 345, 350, 354, 361, 367, 370, 373, 376,
1672 379, 382, 385, 388, 391, 394, 397, 400, 403, 410,
1673 416, 425, 432, 439, 447, 455, 462, 471, 480, 484,
1674 486, 488, 490, 492, 493, 496, 503, 505, 506, 508,
1675 511, 512, 516, 517, 521, 525, 529, 533, 534, 542,
1676 543, 552, 553, 562, 568, 571, 575, 577, 581, 585,
1677 589, 593, 595, 596, 602, 606, 608, 612, 614, 615,
1678 625, 627, 629, 634, 636, 638, 641, 645, 646, 648,
1679 650, 652, 654, 656, 658, 660, 662, 664, 668, 670,
1680 676, 678, 680, 682, 684, 686, 688, 691, 694, 697,
1681 701, 704, 705, 707, 710, 713, 717, 727, 737, 746,
1682 761, 763, 765, 772, 778, 781, 788, 796, 800, 806,
1683 807, 808, 812, 815, 817, 823, 829, 836, 843, 848,
1684 855, 860, 865, 872, 879, 882, 891, 893, 895, 896,
1685 900, 907, 911, 918, 921, 927, 935
1686};
1687
1688/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1689static const yytype_int16 yyrhs[] =
1690{
1691 194, 0, -1, 69, -1, 70, -1, 71, -1, 72,
1692 -1, 73, -1, 74, -1, 75, -1, 76, -1, 77,
1693 -1, 81, -1, 82, -1, 83, -1, 78, -1, 79,
1694 -1, 80, -1, 112, -1, 113, -1, 114, -1, 115,
1695 -1, 116, -1, 117, -1, 118, -1, 119, -1, 120,
1696 -1, 121, -1, 122, -1, 123, -1, 86, -1, 87,
1697 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1698 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1699 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1700 -1, 103, -1, 104, -1, 105, -1, 92, -1, 93,
1701 -1, 94, -1, 95, -1, 22, -1, 23, -1, 11,
1702 -1, 12, -1, 13, -1, 16, -1, 19, -1, 158,
1703 -1, -1, 158, 136, -1, -1, 17, -1, 20, -1,
1704 163, -1, -1, 161, 136, -1, 38, -1, 40, -1,
1705 39, -1, 41, -1, 43, -1, 42, -1, 44, -1,
1706 46, -1, -1, 134, -1, 135, -1, -1, 42, -1,
1707 44, -1, -1, 38, -1, 39, -1, 40, -1, 43,
1708 -1, -1, 40, -1, 38, -1, -1, 57, -1, 58,
1709 -1, 59, -1, 60, -1, 61, -1, 56, 4, -1,
1710 113, -1, 114, -1, 131, -1, 132, -1, -1, 172,
1711 171, -1, 130, -1, 133, -1, 171, -1, -1, 174,
1712 173, -1, -1, 49, 4, -1, -1, 137, 49, 4,
1713 -1, 30, 19, -1, -1, 177, -1, -1, 137, 180,
1714 179, -1, 177, -1, 49, 4, -1, 11, -1, 12,
1715 -1, 13, -1, 14, -1, 45, -1, 181, -1, 182,
1716 138, -1, 216, -1, 139, 4, -1, 182, 140, 186,
1717 141, 174, -1, 10, 140, 186, 141, 174, -1, 142,
1718 4, 143, 182, 144, -1, 145, 4, 143, 182, 146,
1719 -1, 147, 187, 148, -1, 147, 148, -1, 145, 147,
1720 187, 148, 146, -1, 145, 147, 148, 146, -1, 182,
1721 172, -1, 182, -1, 10, -1, 183, -1, 185, 137,
1722 183, -1, 185, -1, 185, 137, 35, -1, 35, -1,
1723 -1, 182, -1, 187, 137, 182, -1, 182, 142, 190,
1724 144, -1, 182, 142, 144, -1, 182, 149, 19, -1,
1725 182, 145, 190, 146, -1, 182, 147, 190, 148, -1,
1726 182, 147, 148, -1, 182, 145, 147, 190, 148, 146,
1727 -1, 182, 145, 147, 148, 146, -1, 182, 36, -1,
1728 182, 37, -1, 182, 216, -1, 182, 189, -1, 182,
1729 21, -1, 156, 3, -1, 156, 5, -1, 156, 4,
1730 -1, 156, 6, -1, 11, 22, -1, 11, 23, -1,
1731 157, 9, -1, 153, 140, 188, 34, 182, 141, -1,
1732 111, 140, 188, 227, 141, -1, 125, 140, 188, 137,
1733 188, 137, 188, 141, -1, 151, 140, 188, 137, 188,
1734 141, -1, 152, 140, 188, 137, 188, 141, -1, 84,
1735 154, 140, 188, 137, 188, 141, -1, 85, 155, 140,
1736 188, 137, 188, 141, -1, 127, 140, 188, 137, 188,
1737 141, -1, 128, 140, 188, 137, 188, 137, 188, 141,
1738 -1, 129, 140, 188, 137, 188, 137, 188, 141, -1,
1739 190, 137, 188, -1, 188, -1, 28, -1, 29, -1,
1740 33, -1, -1, 184, 216, -1, 117, 140, 193, 34,
1741 182, 141, -1, 195, -1, -1, 196, -1, 195, 196,
1742 -1, -1, 27, 197, 212, -1, -1, 26, 198, 213,
1743 -1, 54, 53, 202, -1, 160, 15, 182, -1, 160,
1744 15, 10, -1, -1, 162, 166, 192, 191, 188, 199,
1745 179, -1, -1, 162, 164, 166, 192, 191, 188, 200,
1746 179, -1, -1, 162, 165, 166, 192, 191, 182, 201,
1747 179, -1, 162, 166, 31, 169, 193, -1, 47, 203,
1748 -1, 50, 136, 204, -1, 19, -1, 48, 136, 19,
1749 -1, 62, 136, 19, -1, 142, 205, 144, -1, 205,
1750 137, 19, -1, 19, -1, -1, 206, 137, 182, 172,
1751 159, -1, 182, 172, 159, -1, 206, -1, 206, 137,
1752 35, -1, 35, -1, -1, 170, 184, 161, 140, 207,
1753 141, 174, 178, 175, -1, 24, -1, 147, -1, 168,
1754 166, 208, 209, -1, 25, -1, 148, -1, 219, 211,
1755 -1, 167, 166, 208, -1, -1, 55, -1, 3, -1,
1756 4, -1, 9, -1, 22, -1, 23, -1, 36, -1,
1757 37, -1, 21, -1, 145, 190, 146, -1, 189, -1,
1758 53, 214, 19, 137, 19, -1, 7, -1, 8, -1,
1759 158, -1, 161, -1, 216, -1, 215, -1, 182, 217,
1760 -1, 219, 220, -1, 210, 220, -1, 221, 160, 222,
1761 -1, 221, 224, -1, -1, 18, -1, 63, 218, -1,
1762 63, 10, -1, 64, 14, 217, -1, 64, 11, 217,
1763 137, 14, 217, 137, 14, 217, -1, 65, 156, 217,
1764 137, 14, 217, 142, 223, 144, -1, 65, 156, 217,
1765 137, 14, 217, 142, 144, -1, 66, 170, 184, 217,
1766 140, 226, 141, 174, 34, 14, 217, 67, 14, 217,
1767 -1, 67, -1, 68, -1, 223, 156, 215, 137, 14,
1768 217, -1, 156, 215, 137, 14, 217, -1, 160, 229,
1769 -1, 182, 142, 217, 137, 217, 144, -1, 225, 137,
1770 142, 217, 137, 217, 144, -1, 182, 217, 172, -1,
1771 226, 137, 182, 217, 172, -1, -1, -1, 227, 137,
1772 218, -1, 52, 51, -1, 51, -1, 151, 182, 217,
1773 137, 217, -1, 152, 182, 217, 137, 217, -1, 84,
1774 154, 182, 217, 137, 217, -1, 85, 155, 182, 217,
1775 137, 217, -1, 153, 218, 34, 182, -1, 125, 218,
1776 137, 218, 137, 218, -1, 126, 218, 137, 182, -1,
1777 127, 218, 137, 218, -1, 128, 218, 137, 218, 137,
1778 218, -1, 129, 218, 137, 218, 137, 218, -1, 124,
1779 225, -1, 228, 170, 184, 217, 140, 226, 141, 174,
1780 -1, 231, -1, 32, -1, -1, 106, 182, 176, -1,
1781 106, 182, 137, 11, 217, 176, -1, 107, 182, 176,
1782 -1, 107, 182, 137, 11, 217, 176, -1, 108, 218,
1783 -1, 230, 109, 182, 217, 176, -1, 230, 110, 218,
1784 137, 182, 217, 176, -1, 111, 182, 217, 227, -1
1785};
1786
1787/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1788static const yytype_uint16 yyrline[] =
1789{
1790 0, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1110,
1791 1110, 1111, 1111, 1111, 1111, 1111, 1111, 1112, 1112, 1112,
1792 1112, 1112, 1112, 1113, 1113, 1113, 1113, 1113, 1113, 1116,
1793 1116, 1117, 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1124,
1794 1124, 1125, 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129,
1795 1129, 1130, 1130, 1131, 1132, 1137, 1138, 1138, 1140, 1140,
1796 1141, 1141, 1145, 1149, 1154, 1154, 1156, 1157, 1162, 1168,
1797 1169, 1170, 1171, 1172, 1176, 1177, 1178, 1182, 1183, 1184,
1798 1188, 1189, 1190, 1194, 1195, 1196, 1197, 1198, 1202, 1203,
1799 1204, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1220, 1221,
1800 1222, 1223, 1226, 1227, 1232, 1233, 1234, 1237, 1238, 1245,
1801 1246, 1252, 1253, 1261, 1269, 1270, 1275, 1276, 1277, 1282,
1802 1295, 1295, 1295, 1295, 1298, 1302, 1306, 1313, 1318, 1326,
1803 1356, 1387, 1392, 1404, 1414, 1418, 1428, 1435, 1442, 1449,
1804 1454, 1459, 1466, 1467, 1474, 1481, 1489, 1495, 1507, 1535,
1805 1551, 1580, 1608, 1634, 1654, 1680, 1700, 1712, 1719, 1785,
1806 1795, 1805, 1811, 1821, 1827, 1837, 1842, 1847, 1855, 1867,
1807 1889, 1897, 1903, 1914, 1919, 1924, 1930, 1936, 1945, 1949,
1808 1957, 1957, 1960, 1960, 1963, 1974, 1995, 2000, 2008, 2009,
1809 2013, 2013, 2017, 2017, 2020, 2023, 2047, 2058, 2058, 2069,
1810 2068, 2078, 2077, 2088, 2103, 2106, 2112, 2125, 2129, 2134,
1811 2136, 2141, 2146, 2155, 2165, 2176, 2180, 2189, 2198, 2203,
1812 2325, 2325, 2327, 2336, 2336, 2338, 2343, 2355, 2359, 2364,
1813 2368, 2372, 2376, 2380, 2384, 2388, 2392, 2396, 2421, 2425,
1814 2439, 2443, 2447, 2451, 2457, 2457, 2463, 2472, 2476, 2485,
1815 2494, 2503, 2507, 2512, 2516, 2520, 2525, 2535, 2554, 2563,
1816 2643, 2647, 2654, 2665, 2678, 2688, 2699, 2709, 2718, 2727,
1817 2730, 2731, 2738, 2742, 2747, 2768, 2785, 2799, 2813, 2825,
1818 2833, 2840, 2846, 2852, 2858, 2873, 2958, 2963, 2967, 2974,
1819 2981, 2989, 2996, 3004, 3012, 3026, 3043
1820};
1821#endif
1822
1823#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1824/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1825 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1826static const char *const yytname[] =
1827{
1828 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1829 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1830 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1831 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1832 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1833 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1834 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1835 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1836 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1837 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1838 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1839 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1840 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1841 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1842 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1843 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1844 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1845 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1846 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1847 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET",
1848 "NOUNWIND", "DEFAULT", "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('",
1849 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1850 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1851 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1852 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1853 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1854 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1855 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1856 "SectionString", "OptSection", "GlobalVarAttributes",
1857 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1858 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1859 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1860 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1861 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1862 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1863 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1864 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1865 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1866 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1867 "OptVolatile", "MemoryInst", 0
1868};
1869#endif
1870
1871# ifdef YYPRINT
1872/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1873 token YYLEX-NUM. */
1874static const yytype_uint16 yytoknum[] =
1875{
1876 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1877 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1878 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1879 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1880 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1881 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1882 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1883 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1884 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1885 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1886 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1887 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1888 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1889 385, 386, 387, 388, 389, 390, 61, 44, 42, 92,
1890 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
1891};
1892# endif
1893
1894/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1895static const yytype_uint8 yyr1[] =
1896{
1897 0, 150, 151, 151, 151, 151, 151, 151, 151, 151,
1898 151, 152, 152, 152, 152, 152, 152, 153, 153, 153,
1899 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1900 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
1901 155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
1902 155, 155, 155, 155, 155, 156, 157, 157, 158, 158,
1903 159, 159, 160, 160, 161, 161, 162, 162, 163, 164,
1904 164, 164, 164, 164, 165, 165, 165, 166, 166, 166,
1905 167, 167, 167, 168, 168, 168, 168, 168, 169, 169,
1906 169, 170, 170, 170, 170, 170, 170, 170, 171, 171,
1907 171, 171, 172, 172, 173, 173, 173, 174, 174, 175,
1908 175, 176, 176, 177, 178, 178, 179, 179, 180, 180,
1909 181, 181, 181, 181, 182, 182, 182, 182, 182, 182,
1910 182, 182, 182, 182, 182, 182, 182, 183, 184, 184,
1911 185, 185, 186, 186, 186, 186, 187, 187, 188, 188,
1912 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
1913 188, 188, 188, 188, 188, 188, 188, 188, 189, 189,
1914 189, 189, 189, 189, 189, 189, 189, 189, 190, 190,
1915 191, 191, 192, 192, 193, 193, 194, 194, 195, 195,
1916 197, 196, 198, 196, 196, 196, 196, 199, 196, 200,
1917 196, 201, 196, 196, 196, 196, 202, 203, 203, 204,
1918 205, 205, 205, 206, 206, 207, 207, 207, 207, 208,
1919 209, 209, 210, 211, 211, 212, 213, 214, 214, 215,
1920 215, 215, 215, 215, 215, 215, 215, 215, 215, 215,
1921 216, 216, 216, 216, 217, 217, 218, 219, 219, 220,
1922 221, 221, 221, 222, 222, 222, 222, 222, 222, 222,
1923 222, 222, 223, 223, 224, 225, 225, 226, 226, 226,
1924 227, 227, 228, 228, 229, 229, 229, 229, 229, 229,
1925 229, 229, 229, 229, 229, 229, 229, 230, 230, 231,
1926 231, 231, 231, 231, 231, 231, 231
1927};
1928
1929/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1930static const yytype_uint8 yyr2[] =
1931{
1932 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1933 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1934 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1935 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1936 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1937 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1938 1, 0, 2, 0, 1, 1, 1, 0, 2, 1,
1939 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1940 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1941 1, 0, 1, 1, 1, 1, 1, 2, 1, 1,
1942 1, 1, 0, 2, 1, 1, 1, 0, 2, 0,
1943 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
1944 1, 1, 1, 1, 1, 1, 2, 1, 2, 5,
1945 5, 5, 5, 3, 2, 5, 4, 2, 1, 1,
1946 1, 3, 1, 3, 1, 0, 1, 3, 4, 3,
1947 3, 4, 4, 3, 6, 5, 2, 2, 2, 2,
1948 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1949 8, 6, 6, 7, 7, 6, 8, 8, 3, 1,
1950 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
1951 0, 3, 0, 3, 3, 3, 3, 0, 7, 0,
1952 8, 0, 8, 5, 2, 3, 1, 3, 3, 3,
1953 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1954 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1955 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1956 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1957 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1958 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1959 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1960 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1961 6, 3, 6, 2, 5, 7, 4
1962};
1963
1964/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1965 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1966 means the default is an error. */
1967static const yytype_uint16 yydefact[] =
1968{
1969 67, 58, 64, 59, 65, 192, 190, 0, 0, 0,
1970 0, 0, 0, 77, 66, 0, 67, 188, 80, 83,
1971 0, 0, 204, 0, 0, 62, 0, 68, 69, 71,
1972 70, 72, 74, 73, 75, 76, 78, 79, 77, 77,
1973 183, 1, 189, 81, 82, 77, 193, 84, 85, 86,
1974 87, 77, 251, 191, 251, 0, 0, 212, 205, 206,
1975 194, 240, 241, 196, 120, 121, 122, 123, 124, 0,
1976 0, 0, 0, 242, 243, 125, 195, 127, 183, 183,
1977 88, 182, 0, 91, 91, 252, 248, 63, 223, 224,
1978 225, 247, 207, 208, 211, 0, 145, 128, 0, 0,
1979 0, 0, 134, 146, 0, 126, 145, 0, 0, 90,
1980 89, 0, 180, 181, 0, 0, 92, 93, 94, 95,
1981 96, 0, 226, 0, 288, 250, 0, 209, 144, 102,
1982 140, 142, 0, 0, 0, 0, 0, 0, 133, 0,
1983 0, 0, 139, 0, 138, 0, 203, 120, 121, 122,
1984 0, 0, 0, 197, 97, 0, 220, 221, 222, 287,
1985 273, 0, 0, 0, 0, 91, 260, 261, 2, 3,
1986 4, 5, 6, 7, 8, 9, 10, 14, 15, 16,
1987 11, 12, 13, 0, 0, 0, 0, 0, 0, 17,
1988 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1989 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1990 249, 91, 264, 0, 286, 210, 137, 0, 107, 0,
1991 0, 136, 0, 147, 107, 199, 201, 0, 184, 165,
1992 166, 161, 163, 162, 164, 167, 160, 156, 157, 0,
1993 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1994 0, 0, 0, 159, 158, 116, 0, 272, 254, 0,
1995 253, 0, 0, 55, 0, 0, 29, 30, 31, 32,
1996 33, 34, 35, 36, 37, 38, 0, 53, 54, 49,
1997 50, 51, 52, 39, 40, 41, 42, 43, 44, 45,
1998 46, 47, 48, 0, 111, 111, 293, 0, 0, 284,
1999 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2000 0, 98, 99, 100, 101, 103, 143, 141, 130, 131,
2001 132, 135, 129, 116, 116, 0, 0, 0, 0, 0,
2002 0, 0, 0, 149, 179, 0, 0, 0, 153, 0,
2003 150, 0, 0, 0, 0, 198, 218, 229, 230, 231,
2004 236, 232, 233, 234, 235, 227, 0, 238, 245, 244,
2005 246, 0, 255, 0, 0, 0, 0, 0, 289, 0,
2006 291, 270, 0, 0, 0, 0, 0, 0, 0, 0,
2007 0, 0, 0, 0, 0, 104, 105, 106, 108, 200,
2008 202, 0, 0, 0, 270, 0, 0, 0, 0, 0,
2009 148, 134, 146, 0, 151, 152, 0, 0, 0, 0,
2010 0, 118, 116, 217, 102, 215, 0, 228, 0, 0,
2011 0, 0, 0, 0, 0, 0, 0, 0, 296, 0,
2012 0, 0, 280, 281, 0, 0, 0, 0, 278, 0,
2013 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2014 178, 155, 0, 0, 0, 0, 113, 119, 117, 61,
2015 0, 107, 0, 237, 0, 0, 269, 0, 0, 111,
2016 112, 111, 0, 0, 0, 0, 0, 0, 274, 275,
2017 269, 0, 294, 0, 185, 0, 0, 169, 0, 0,
2018 0, 0, 154, 0, 0, 0, 60, 214, 216, 102,
2019 114, 0, 0, 0, 0, 0, 276, 277, 290, 292,
2020 271, 0, 0, 279, 282, 283, 0, 111, 0, 0,
2021 0, 175, 0, 0, 171, 172, 168, 61, 115, 109,
2022 239, 0, 0, 102, 0, 107, 265, 0, 107, 295,
2023 173, 174, 0, 0, 0, 213, 0, 219, 0, 258,
2024 0, 0, 267, 0, 0, 266, 285, 170, 176, 177,
2025 110, 256, 0, 257, 0, 102, 0, 0, 0, 268,
2026 0, 0, 0, 0, 263, 0, 0, 262, 0, 259
2027};
2028
2029/* YYDEFGOTO[NTERM-NUM]. */
2030static const yytype_int16 yydefgoto[] =
2031{
2032 -1, 250, 251, 252, 276, 293, 150, 151, 73, 497,
2033 11, 74, 13, 14, 38, 39, 40, 45, 51, 111,
2034 121, 315, 216, 388, 318, 547, 368, 411, 529, 345,
2035 412, 75, 152, 130, 145, 131, 132, 104, 334, 357,
2036 335, 114, 82, 146, 15, 16, 17, 19, 18, 255,
2037 323, 324, 60, 22, 58, 95, 415, 416, 122, 158,
2038 52, 90, 53, 46, 418, 358, 77, 360, 260, 54,
2039 86, 87, 210, 551, 125, 299, 505, 428, 211, 212,
2040 213, 214
2041};
2042
2043/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2044 STATE-NUM. */
2045#define YYPACT_NINF -472
2046static const yytype_int16 yypact[] =
2047{
2048 50, -472, -472, -472, -472, -472, -472, -20, -110, 93,
2049 -64, 160, 68, 14, -472, 185, 203, -472, 77, 199,
2050 76, 81, -472, 79, 205, -472, 1214, -472, -472, -472,
2051 -472, -472, -472, -472, -472, -472, -472, -472, 56, 56,
2052 137, -472, -472, -472, -472, 56, -472, -472, -472, -472,
2053 -472, 56, 210, -472, 2, 236, 246, 277, -472, -472,
2054 -472, -472, -472, 170, -472, -472, -472, -472, -472, 315,
2055 318, 6, 368, -472, -472, -472, 154, -472, 287, 287,
2056 255, -472, 207, 281, 281, -472, -472, 82, -472, -472,
2057 -472, -472, -472, -472, -472, -1, 1109, -472, 184, 188,
2058 685, 170, -472, 154, -49, -472, 1109, 207, 207, -472,
2059 -472, 777, -472, -472, 1230, 326, -472, -472, -472, -472,
2060 -472, 1269, -472, -7, 1471, -472, 324, -472, -472, 154,
2061 -472, 208, 206, 1312, 1312, 200, -43, 1312, -472, 213,
2062 1230, 1312, 170, 215, 154, 316, -472, 40, 339, 350,
2063 256, 352, 856, -472, -472, 86, -472, -472, -472, -472,
2064 -472, 311, 1372, 187, 356, 281, -472, -472, -472, -472,
2065 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2066 -472, -472, -472, 394, 177, 1312, 1312, 1312, 1312, -472,
2067 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2068 -472, 1312, 1312, 1312, 1312, 1312, 1312, 1312, 1312, 1312,
2069 -472, 281, -472, 122, -472, -472, -40, 1126, -472, 67,
2070 49, -472, 222, 154, -472, -472, 154, 777, -472, -472,
2071 -472, -472, -472, -472, -472, -472, -472, -472, -472, 394,
2072 177, 229, 232, 234, 237, 243, 1156, 1386, 898, 367,
2073 249, 251, 252, -472, -472, 257, 258, -472, 170, 606,
2074 -472, 733, 733, -472, 733, 1269, -472, -472, -472, -472,
2075 -472, -472, -472, -472, -472, -472, 1312, -472, -472, -472,
2076 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2077 -472, -472, -472, 1312, -89, 108, -472, 606, 116, 259,
2078 260, 262, 263, 266, 267, 606, 606, 361, 1269, 1312,
2079 1312, -472, -472, -472, -472, -472, -472, -472, 41, -472,
2080 -472, -472, 41, 257, 257, 371, 268, 270, 1230, 1230,
2081 1230, 1230, 1230, -472, -472, 15, 937, -113, -472, -35,
2082 -472, 1230, 1230, 1230, 29, -472, 1170, -472, -472, -472,
2083 -472, -472, -472, -472, -472, 351, 1230, -472, -472, -472,
2084 -472, 274, -472, 275, 733, 606, 606, 12, -472, 19,
2085 -472, -472, 733, 265, 1312, 1312, 1312, 1312, 1312, 278,
2086 284, 1312, 733, 606, 285, -472, -472, -472, -472, -472,
2087 -472, 1312, 1230, 1230, -472, 286, 289, 290, 291, 1230,
2088 -472, 283, 856, -30, -472, -472, 296, 297, 403, 419,
2089 436, -472, 257, -472, 154, 305, 302, -472, 425, -8,
2090 431, 432, 308, 312, 317, 733, 449, 733, 321, 327,
2091 733, 328, 154, -472, 329, 330, 733, 733, 154, 323,
2092 332, 1312, 126, 333, 334, -57, 1230, 1230, 1230, 1230,
2093 -472, -472, 331, 1230, 1230, 1312, -472, -472, -472, 13,
2094 1200, -472, 335, -472, 733, 733, 1312, 733, 733, 332,
2095 -472, 332, 1312, 733, 336, 1312, 1312, 1312, -472, -472,
2096 1312, 426, -472, 606, -472, 1230, 1230, -472, 337, 349,
2097 355, 358, -472, 357, 359, 149, -472, -472, -472, 154,
2098 1, 457, 360, 354, 606, -2, -472, -472, -472, -472,
2099 -472, 362, 733, -472, -472, -472, 28, 332, 363, 364,
2100 1230, -472, 1230, 1230, -472, -472, -472, 13, -472, 450,
2101 -472, 487, -3, -472, 1312, -472, -472, 370, -472, -472,
2102 -472, -472, 376, 377, 378, -472, 498, -472, 733, -472,
2103 986, 3, -40, 606, 83, -472, 41, -472, -472, -472,
2104 -472, -472, 366, -472, 986, -472, 494, 497, 375, -40,
2105 733, 733, 506, 455, -472, 733, 510, -472, 733, -472
2106};
2107
2108/* YYPGOTO[NTERM-NUM]. */
2109static const yytype_int16 yypgoto[] =
2110{
2111 -472, 401, 404, 405, 292, 294, -161, -472, 0, 8,
2112 443, 9, -472, -472, -472, -472, 44, -472, -472, -472,
2113 -147, -307, -409, -472, -220, -472, -283, 36, -472, -284,
2114 -472, -472, -25, 320, -114, -472, 433, 438, -29, -150,
2115 -226, 198, 238, 313, -472, -472, 525, -472, -472, -472,
2116 -472, -472, -472, -472, -472, -472, -472, -472, 458, -472,
2117 -472, -472, -472, -472, -472, -471, -139, 96, -168, -472,
2118 489, -472, -472, -472, -472, -472, 64, 151, -472, -472,
2119 -472, -472
2120};
2121
2122/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2123 positive, shift that token. If negative, reduce the rule which
2124 number is the opposite. If zero, do what YYDEFACT says.
2125 If YYTABLE_NINF, syntax error. */
2126#define YYTABLE_NINF -188
2127static const yytype_int16 yytable[] =
2128{
2129 10, 76, 253, 264, 322, 459, 228, 155, 263, 12,
2130 99, 387, 370, 254, 263, 387, 10, 156, 265, 296,
2131 85, 337, 339, 425, 399, 12, 23, 88, 20, 1,
2132 427, 409, 3, 404, 300, 301, 302, 303, 304, 389,
2133 390, 307, 21, -55, -55, -55, -55, 103, 367, 105,
2134 -187, 106, 28, 29, 30, 31, 32, 33, 34, 409,
2135 35, 426, 229, 230, 308, -63, 1, 2, 426, 3,
2136 4, 129, 25, 311, 312, 103, 5, 6, 410, 562,
2137 472, 129, 78, 79, 487, 153, 144, 10, 137, 83,
2138 527, 313, 314, 568, 137, 84, 144, 7, 1, 138,
2139 8, 3, 399, 2, 9, 222, 4, 399, 219, 220,
2140 403, 225, 223, 405, 311, 312, 226, 566, 452, 43,
2141 359, 44, 359, 359, 552, 359, 311, 312, 458, 399,
2142 419, 385, 313, 314, 386, 534, 126, 259, 463, 535,
2143 157, 549, 384, 127, 313, 314, 24, 563, 36, 37,
2144 89, 364, 399, 100, 311, 312, 569, 482, 359, 400,
2145 294, 295, 259, 297, 256, 534, 359, 359, 80, 538,
2146 81, 385, 313, 314, 386, 26, 298, 259, 259, 259,
2147 259, 259, 305, 306, 259, 41, 508, 105, 509, 106,
2148 36, 37, 129, 387, 382, 320, 311, 312, 261, 277,
2149 278, 262, 144, -186, 27, 105, 431, 106, 433, 434,
2150 435, 319, 55, 385, 313, 314, 386, 56, -63, 1,
2151 2, 57, 3, 4, 59, 359, 359, 359, 85, 5,
2152 6, 309, 310, 359, 539, 112, 113, 47, 48, 49,
2153 144, 500, 50, 359, 359, 369, 105, 387, 106, 387,
2154 7, 365, 253, 8, 105, 92, 106, 9, 372, 231,
2155 232, 233, 234, 254, 105, 93, 106, 484, 366, 279,
2156 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
2157 290, 291, 292, 144, 383, 259, 359, 105, 359, 106,
2158 526, 359, 105, 109, 106, 110, 94, 359, 359, 394,
2159 395, 396, 397, 398, 510, 140, 141, 513, 514, 515,
2160 96, 402, 406, 407, 408, 554, 107, 108, 556, 97,
2161 81, 414, 98, 61, 62, 359, 359, 133, 359, 359,
2162 154, 134, 1, 2, 359, 3, 4, 115, 116, 117,
2163 118, 119, 120, 215, 359, 217, 221, 218, -56, 259,
2164 432, 259, 259, 259, 224, 227, 438, 361, 362, -57,
2165 363, 235, 257, 443, 444, 359, 442, 263, 321, 328,
2166 450, 550, 329, 359, 330, 61, 62, 331, 101, 64,
2167 65, 66, 67, 332, 1, 2, 340, 3, 4, 341,
2168 564, 342, 343, 371, 344, 381, 373, 374, 346, 375,
2169 376, 379, 380, 377, 378, 391, 417, 430, 392, 359,
2170 393, 420, 421, 68, 359, 436, 483, 488, 489, 490,
2171 491, 437, 441, 446, 493, 494, 447, 448, 449, 451,
2172 495, 359, 359, 453, 454, 499, 359, 455, 456, 359,
2173 457, 504, 460, 461, 462, 464, 465, 259, 466, 467,
2174 259, 259, 259, 470, 468, 504, 518, 519, 472, 496,
2175 422, 423, 424, 480, 473, 475, 476, 477, 429, 481,
2176 485, 486, 501, 512, 520, 426, 530, 492, 439, 440,
2177 266, 267, 268, 269, 270, 271, 272, 273, 274, 275,
2178 521, 542, 522, 543, 544, 523, 532, 531, 524, 546,
2179 525, 548, 560, 567, 540, 541, 536, 69, 570, 553,
2180 70, 571, 572, 71, 555, 72, 102, 557, 558, 559,
2181 575, 469, 576, 471, 578, 207, 474, 496, 208, 209,
2182 124, 326, 478, 479, 327, 545, 528, 317, 136, 139,
2183 325, 42, 123, 91, 516, 445, 0, 0, 0, 0,
2184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2185 502, 503, 0, 506, 507, 0, 0, 0, 0, 511,
2186 0, 0, 0, 0, 0, 0, 0, 0, 0, 517,
2187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2189 533, 0, 0, 0, 0, 0, 0, 0, 537, 347,
2190 348, 0, 0, 61, 62, 349, 0, 0, 0, 0,
2191 0, 0, 1, 2, 0, 3, 4, 350, 351, 352,
2192 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2193 0, 0, 353, 354, 561, 0, 0, 0, 0, 565,
2194 0, 0, 0, 0, 0, 0, 0, 0, 0, 355,
2195 0, 0, 0, 0, 0, 0, 573, 574, 0, 0,
2196 0, 577, 0, 0, 579, 168, 169, 170, 171, 172,
2197 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2198 239, 240, 61, 62, 0, 101, 64, 65, 66, 67,
2199 0, 1, 2, 0, 3, 4, 0, 0, 0, 0,
2200 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2201 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2202 68, 242, 0, 243, 244, 245, 347, 348, 0, 0,
2203 61, 62, 349, 0, 105, 0, 106, 0, 0, 1,
2204 2, 356, 3, 4, 350, 351, 352, 0, 0, 0,
2205 0, 0, 0, 0, 0, 0, 0, 0, 0, 353,
2206 354, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2207 0, 0, 0, 0, 61, 62, 355, 142, 64, 65,
2208 66, 67, 0, 1, 2, 0, 3, 4, 0, 0,
2209 0, 0, 168, 169, 170, 171, 172, 173, 174, 175,
2210 176, 177, 178, 179, 180, 181, 182, 239, 240, 0,
2211 0, 0, 68, 0, 69, 0, 0, 70, 0, 0,
2212 71, 0, 72, 135, 0, 0, 0, 0, 0, 0,
2213 0, 0, 0, 0, 241, 189, 190, 191, 192, 193,
2214 194, 195, 196, 197, 198, 199, 200, 0, 242, 0,
2215 243, 244, 245, 61, 62, 0, 0, 0, 0, 0,
2216 0, 0, 1, 2, 0, 3, 4, 236, 356, 0,
2217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2218 0, 0, 237, 238, 143, 0, 0, 0, 0, 0,
2219 0, 0, 0, 0, 0, 61, 62, 0, 101, 147,
2220 148, 149, 67, 0, 1, 2, 69, 3, 4, 70,
2221 0, 0, 71, 0, 72, 168, 169, 170, 171, 172,
2222 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2223 239, 240, 0, 68, 61, 62, 0, 101, 147, 148,
2224 149, 67, 0, 1, 2, 0, 3, 4, 0, 0,
2225 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2226 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2227 0, 242, 68, 243, 244, 245, 0, 0, 0, 347,
2228 348, 0, 0, 0, 105, 349, 106, 0, 246, 0,
2229 0, 247, 0, 248, 0, 249, 0, 350, 351, 352,
2230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2231 0, 0, 353, 354, 0, 0, 0, 0, 0, 0,
2232 0, 0, 0, 0, 0, 0, 0, 69, 0, 355,
2233 70, 0, 0, 71, 0, 72, 338, 0, 0, 0,
2234 0, 0, 0, 0, 0, 168, 169, 170, 171, 172,
2235 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2236 239, 240, 0, 0, 0, 0, 69, 0, 0, 70,
2237 0, 0, 71, 0, 72, 401, 0, 0, 0, 0,
2238 0, 0, 0, 0, 0, 0, 0, 241, 189, 190,
2239 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2240 0, 242, 0, 243, 244, 245, 61, 62, 0, 101,
2241 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
2242 0, 356, 0, 61, 62, 0, 101, 64, 65, 66,
2243 67, 0, 1, 2, 128, 3, 4, 0, 0, 0,
2244 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
2245 0, 316, 0, 61, 62, 0, 101, 147, 148, 149,
2246 67, 68, 1, 2, 0, 3, 4, 61, 62, 0,
2247 101, 64, 65, 66, 67, 0, 1, 2, 0, 3,
2248 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2249 0, 68, 0, 0, 0, 413, 0, 61, 62, 0,
2250 101, 64, 65, 66, 67, 68, 1, 2, 0, 3,
2251 4, 61, 62, 0, 63, 64, 65, 66, 67, 0,
2252 1, 2, 0, 3, 4, 498, 0, 61, 62, 0,
2253 101, 147, 148, 149, 67, 68, 1, 2, 69, 3,
2254 4, 70, 0, 0, 71, 0, 72, 0, 0, 68,
2255 0, 0, 0, 0, 0, 69, 0, 0, 70, 0,
2256 0, 71, 0, 72, 0, 68, 61, 62, 0, 142,
2257 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
2258 0, 0, 0, 0, 0, 69, 0, 0, 70, 0,
2259 333, 71, 0, 72, 0, 0, 0, 0, 0, 69,
2260 0, 0, 70, 0, 68, 71, 0, 72, 0, 61,
2261 62, 0, 101, 64, 65, 66, 67, 0, 1, 2,
2262 0, 3, 4, 0, 0, 0, 0, 0, 0, 69,
2263 0, 0, 70, 0, 0, 71, 0, 72, 0, 0,
2264 0, 0, 0, 69, 0, 0, 70, 68, 0, 71,
2265 0, 72, 0, 0, 0, 0, 0, 0, 0, 69,
2266 0, 0, 70, 0, 0, 71, 0, 72, 0, 61,
2267 62, 0, 258, 64, 65, 66, 67, 0, 1, 2,
2268 0, 3, 4, 61, 62, 0, 101, 147, 148, 149,
2269 67, 0, 1, 2, 0, 3, 4, 0, 69, 0,
2270 0, 70, 0, 0, 71, 0, 72, 68, 0, 0,
2271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2272 0, 68, 0, 0, 0, 0, 0, 0, 0, 0,
2273 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2274 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
2275 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2277 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2279 0, 0, 0, 159, 0, 0, 0, 0, 0, 0,
2280 0, 69, 0, 0, 70, 0, 0, 71, 0, 72,
2281 0, 0, 160, 161, 0, 69, 0, 0, 70, 0,
2282 0, 71, 0, 336, 162, 163, 164, 165, 166, 167,
2283 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2284 178, 179, 180, 181, 182, 183, 184, 0, 0, 0,
2285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 0, 0, 0, 0, 0, 0, 0, 185, 186, 187,
2287 0, 0, 188, 189, 190, 191, 192, 193, 194, 195,
2288 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2289 206
2290};
2291
2292static const yytype_int16 yycheck[] =
2293{
2294 0, 26, 152, 164, 224, 414, 145, 121, 11, 0,
2295 4, 318, 295, 152, 11, 322, 16, 24, 165, 187,
2296 18, 247, 248, 11, 137, 16, 136, 25, 48, 16,
2297 11, 30, 19, 146, 202, 203, 204, 205, 206, 323,
2298 324, 209, 62, 3, 4, 5, 6, 72, 137, 138,
2299 0, 140, 38, 39, 40, 41, 42, 43, 44, 30,
2300 46, 49, 22, 23, 211, 15, 16, 17, 49, 19,
2301 20, 96, 136, 113, 114, 100, 26, 27, 49, 550,
2302 137, 106, 38, 39, 141, 114, 111, 87, 137, 45,
2303 499, 131, 132, 564, 137, 51, 121, 47, 16, 148,
2304 50, 19, 137, 17, 54, 148, 20, 137, 133, 134,
2305 336, 140, 137, 148, 113, 114, 141, 34, 148, 42,
2306 259, 44, 261, 262, 533, 264, 113, 114, 412, 137,
2307 356, 130, 131, 132, 133, 137, 137, 162, 146, 141,
2308 147, 144, 310, 144, 131, 132, 53, 144, 134, 135,
2309 148, 265, 137, 147, 113, 114, 565, 440, 297, 144,
2310 185, 186, 187, 188, 155, 137, 305, 306, 31, 141,
2311 33, 130, 131, 132, 133, 15, 201, 202, 203, 204,
2312 205, 206, 207, 208, 209, 0, 469, 138, 471, 140,
2313 134, 135, 217, 500, 308, 146, 113, 114, 11, 22,
2314 23, 14, 227, 0, 136, 138, 374, 140, 376, 377,
2315 378, 144, 136, 130, 131, 132, 133, 136, 15, 16,
2316 17, 142, 19, 20, 19, 364, 365, 366, 18, 26,
2317 27, 109, 110, 372, 517, 28, 29, 38, 39, 40,
2318 265, 461, 43, 382, 383, 137, 138, 554, 140, 556,
2319 47, 276, 402, 50, 138, 19, 140, 54, 142, 3,
2320 4, 5, 6, 402, 138, 19, 140, 141, 293, 92,
2321 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2322 103, 104, 105, 308, 309, 310, 425, 138, 427, 140,
2323 141, 430, 138, 38, 140, 40, 19, 436, 437, 328,
2324 329, 330, 331, 332, 472, 107, 108, 475, 476, 477,
2325 140, 336, 341, 342, 343, 535, 78, 79, 538, 4,
2326 33, 346, 4, 7, 8, 464, 465, 143, 467, 468,
2327 4, 143, 16, 17, 473, 19, 20, 56, 57, 58,
2328 59, 60, 61, 19, 483, 137, 146, 141, 9, 374,
2329 375, 376, 377, 378, 141, 140, 381, 261, 262, 9,
2330 264, 9, 51, 392, 393, 504, 391, 11, 146, 140,
2331 399, 532, 140, 512, 140, 7, 8, 140, 10, 11,
2332 12, 13, 14, 140, 16, 17, 19, 19, 20, 140,
2333 551, 140, 140, 297, 137, 34, 137, 137, 140, 137,
2334 137, 305, 306, 137, 137, 34, 55, 142, 140, 548,
2335 140, 137, 137, 45, 553, 137, 441, 446, 447, 448,
2336 449, 137, 137, 137, 453, 454, 137, 137, 137, 146,
2337 455, 570, 571, 137, 137, 460, 575, 34, 19, 578,
2338 4, 466, 137, 141, 19, 14, 14, 472, 140, 137,
2339 475, 476, 477, 4, 137, 480, 485, 486, 137, 459,
2340 364, 365, 366, 140, 137, 137, 137, 137, 372, 137,
2341 137, 137, 137, 137, 137, 49, 19, 146, 382, 383,
2342 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2343 141, 520, 137, 522, 523, 137, 142, 137, 141, 49,
2344 141, 14, 4, 137, 141, 141, 144, 139, 14, 534,
2345 142, 14, 137, 145, 144, 147, 148, 141, 141, 141,
2346 14, 425, 67, 427, 14, 124, 430, 527, 124, 124,
2347 87, 239, 436, 437, 240, 527, 500, 217, 100, 106,
2348 227, 16, 84, 54, 480, 394, -1, -1, -1, -1,
2349 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2350 464, 465, -1, 467, 468, -1, -1, -1, -1, 473,
2351 -1, -1, -1, -1, -1, -1, -1, -1, -1, 483,
2352 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2353 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2354 504, -1, -1, -1, -1, -1, -1, -1, 512, 3,
2355 4, -1, -1, 7, 8, 9, -1, -1, -1, -1,
2356 -1, -1, 16, 17, -1, 19, 20, 21, 22, 23,
2357 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2358 -1, -1, 36, 37, 548, -1, -1, -1, -1, 553,
2359 -1, -1, -1, -1, -1, -1, -1, -1, -1, 53,
2360 -1, -1, -1, -1, -1, -1, 570, 571, -1, -1,
2361 -1, 575, -1, -1, 578, 69, 70, 71, 72, 73,
2362 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2363 84, 85, 7, 8, -1, 10, 11, 12, 13, 14,
2364 -1, 16, 17, -1, 19, 20, -1, -1, -1, -1,
2365 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2366 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2367 45, 125, -1, 127, 128, 129, 3, 4, -1, -1,
2368 7, 8, 9, -1, 138, -1, 140, -1, -1, 16,
2369 17, 145, 19, 20, 21, 22, 23, -1, -1, -1,
2370 -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
2371 37, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2372 -1, -1, -1, -1, 7, 8, 53, 10, 11, 12,
2373 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2374 -1, -1, 69, 70, 71, 72, 73, 74, 75, 76,
2375 77, 78, 79, 80, 81, 82, 83, 84, 85, -1,
2376 -1, -1, 45, -1, 139, -1, -1, 142, -1, -1,
2377 145, -1, 147, 148, -1, -1, -1, -1, -1, -1,
2378 -1, -1, -1, -1, 111, 112, 113, 114, 115, 116,
2379 117, 118, 119, 120, 121, 122, 123, -1, 125, -1,
2380 127, 128, 129, 7, 8, -1, -1, -1, -1, -1,
2381 -1, -1, 16, 17, -1, 19, 20, 21, 145, -1,
2382 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2383 -1, -1, 36, 37, 117, -1, -1, -1, -1, -1,
2384 -1, -1, -1, -1, -1, 7, 8, -1, 10, 11,
2385 12, 13, 14, -1, 16, 17, 139, 19, 20, 142,
2386 -1, -1, 145, -1, 147, 69, 70, 71, 72, 73,
2387 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2388 84, 85, -1, 45, 7, 8, -1, 10, 11, 12,
2389 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2390 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2391 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2392 -1, 125, 45, 127, 128, 129, -1, -1, -1, 3,
2393 4, -1, -1, -1, 138, 9, 140, -1, 142, -1,
2394 -1, 145, -1, 147, -1, 149, -1, 21, 22, 23,
2395 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2396 -1, -1, 36, 37, -1, -1, -1, -1, -1, -1,
2397 -1, -1, -1, -1, -1, -1, -1, 139, -1, 53,
2398 142, -1, -1, 145, -1, 147, 148, -1, -1, -1,
2399 -1, -1, -1, -1, -1, 69, 70, 71, 72, 73,
2400 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2401 84, 85, -1, -1, -1, -1, 139, -1, -1, 142,
2402 -1, -1, 145, -1, 147, 148, -1, -1, -1, -1,
2403 -1, -1, -1, -1, -1, -1, -1, 111, 112, 113,
2404 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2405 -1, 125, -1, 127, 128, 129, 7, 8, -1, 10,
2406 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2407 -1, 145, -1, 7, 8, -1, 10, 11, 12, 13,
2408 14, -1, 16, 17, 35, 19, 20, -1, -1, -1,
2409 -1, -1, -1, -1, 45, -1, -1, -1, -1, -1,
2410 -1, 35, -1, 7, 8, -1, 10, 11, 12, 13,
2411 14, 45, 16, 17, -1, 19, 20, 7, 8, -1,
2412 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2413 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2414 -1, 45, -1, -1, -1, 35, -1, 7, 8, -1,
2415 10, 11, 12, 13, 14, 45, 16, 17, -1, 19,
2416 20, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2417 16, 17, -1, 19, 20, 35, -1, 7, 8, -1,
2418 10, 11, 12, 13, 14, 45, 16, 17, 139, 19,
2419 20, 142, -1, -1, 145, -1, 147, -1, -1, 45,
2420 -1, -1, -1, -1, -1, 139, -1, -1, 142, -1,
2421 -1, 145, -1, 147, -1, 45, 7, 8, -1, 10,
2422 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2423 -1, -1, -1, -1, -1, 139, -1, -1, 142, -1,
2424 144, 145, -1, 147, -1, -1, -1, -1, -1, 139,
2425 -1, -1, 142, -1, 45, 145, -1, 147, -1, 7,
2426 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2427 -1, 19, 20, -1, -1, -1, -1, -1, -1, 139,
2428 -1, -1, 142, -1, -1, 145, -1, 147, -1, -1,
2429 -1, -1, -1, 139, -1, -1, 142, 45, -1, 145,
2430 -1, 147, -1, -1, -1, -1, -1, -1, -1, 139,
2431 -1, -1, 142, -1, -1, 145, -1, 147, -1, 7,
2432 8, -1, 10, 11, 12, 13, 14, -1, 16, 17,
2433 -1, 19, 20, 7, 8, -1, 10, 11, 12, 13,
2434 14, -1, 16, 17, -1, 19, 20, -1, 139, -1,
2435 -1, 142, -1, -1, 145, -1, 147, 45, -1, -1,
2436 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2437 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2438 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2439 -1, 139, -1, -1, 142, -1, -1, 145, -1, 147,
2440 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2441 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2442 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2443 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2444 -1, -1, -1, 32, -1, -1, -1, -1, -1, -1,
2445 -1, 139, -1, -1, 142, -1, -1, 145, -1, 147,
2446 -1, -1, 51, 52, -1, 139, -1, -1, 142, -1,
2447 -1, 145, -1, 147, 63, 64, 65, 66, 67, 68,
2448 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2449 79, 80, 81, 82, 83, 84, 85, -1, -1, -1,
2450 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2451 -1, -1, -1, -1, -1, -1, -1, 106, 107, 108,
2452 -1, -1, 111, 112, 113, 114, 115, 116, 117, 118,
2453 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2454 129
2455};
2456
2457/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2458 symbol of state STATE-NUM. */
2459static const yytype_uint8 yystos[] =
2460{
2461 0, 16, 17, 19, 20, 26, 27, 47, 50, 54,
2462 158, 160, 161, 162, 163, 194, 195, 196, 198, 197,
2463 48, 62, 203, 136, 53, 136, 15, 136, 38, 39,
2464 40, 41, 42, 43, 44, 46, 134, 135, 164, 165,
2465 166, 0, 196, 42, 44, 167, 213, 38, 39, 40,
2466 43, 168, 210, 212, 219, 136, 136, 142, 204, 19,
2467 202, 7, 8, 10, 11, 12, 13, 14, 45, 139,
2468 142, 145, 147, 158, 161, 181, 182, 216, 166, 166,
2469 31, 33, 192, 166, 166, 18, 220, 221, 25, 148,
2470 211, 220, 19, 19, 19, 205, 140, 4, 4, 4,
2471 147, 10, 148, 182, 187, 138, 140, 192, 192, 38,
2472 40, 169, 28, 29, 191, 56, 57, 58, 59, 60,
2473 61, 170, 208, 208, 160, 224, 137, 144, 35, 182,
2474 183, 185, 186, 143, 143, 148, 187, 137, 148, 186,
2475 191, 191, 10, 117, 182, 184, 193, 11, 12, 13,
2476 156, 157, 182, 188, 4, 184, 24, 147, 209, 32,
2477 51, 52, 63, 64, 65, 66, 67, 68, 69, 70,
2478 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2479 81, 82, 83, 84, 85, 106, 107, 108, 111, 112,
2480 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2481 123, 124, 125, 126, 127, 128, 129, 151, 152, 153,
2482 222, 228, 229, 230, 231, 19, 172, 137, 141, 182,
2483 182, 146, 148, 182, 141, 188, 182, 140, 216, 22,
2484 23, 3, 4, 5, 6, 9, 21, 36, 37, 84,
2485 85, 111, 125, 127, 128, 129, 142, 145, 147, 149,
2486 151, 152, 153, 189, 216, 199, 161, 51, 10, 182,
2487 218, 11, 14, 11, 156, 170, 86, 87, 88, 89,
2488 90, 91, 92, 93, 94, 95, 154, 22, 23, 92,
2489 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2490 103, 104, 105, 155, 182, 182, 218, 182, 182, 225,
2491 218, 218, 218, 218, 218, 182, 182, 218, 170, 109,
2492 110, 113, 114, 131, 132, 171, 35, 183, 174, 144,
2493 146, 146, 174, 200, 201, 193, 154, 155, 140, 140,
2494 140, 140, 140, 144, 188, 190, 147, 190, 148, 190,
2495 19, 140, 140, 140, 137, 179, 140, 3, 4, 9,
2496 21, 22, 23, 36, 37, 53, 145, 189, 215, 216,
2497 217, 217, 217, 217, 184, 182, 182, 137, 176, 137,
2498 176, 217, 142, 137, 137, 137, 137, 137, 137, 217,
2499 217, 34, 184, 182, 218, 130, 133, 171, 173, 179,
2500 179, 34, 140, 140, 188, 188, 188, 188, 188, 137,
2501 144, 148, 182, 190, 146, 148, 188, 188, 188, 30,
2502 49, 177, 180, 35, 182, 206, 207, 55, 214, 190,
2503 137, 137, 217, 217, 217, 11, 49, 11, 227, 217,
2504 142, 218, 182, 218, 218, 218, 137, 137, 182, 217,
2505 217, 137, 182, 188, 188, 227, 137, 137, 137, 137,
2506 188, 146, 148, 137, 137, 34, 19, 4, 179, 172,
2507 137, 141, 19, 146, 14, 14, 140, 137, 137, 217,
2508 4, 217, 137, 137, 217, 137, 137, 137, 217, 217,
2509 140, 137, 176, 182, 141, 137, 137, 141, 188, 188,
2510 188, 188, 146, 188, 188, 182, 158, 159, 35, 182,
2511 174, 137, 217, 217, 182, 226, 217, 217, 176, 176,
2512 218, 217, 137, 218, 218, 218, 226, 217, 188, 188,
2513 137, 141, 137, 137, 141, 141, 141, 172, 177, 178,
2514 19, 137, 142, 217, 137, 141, 144, 217, 141, 176,
2515 141, 141, 188, 188, 188, 159, 49, 175, 14, 144,
2516 156, 223, 172, 182, 174, 144, 174, 141, 141, 141,
2517 4, 217, 215, 144, 156, 217, 34, 137, 215, 172,
2518 14, 14, 137, 217, 217, 14, 67, 217, 14, 217
2519};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002520
2521#define yyerrok (yyerrstatus = 0)
2522#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002523#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002524#define YYEOF 0
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002525
Reid Spencer68a24bd2005-08-27 18:50:39 +00002526#define YYACCEPT goto yyacceptlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002527#define YYABORT goto yyabortlab
2528#define YYERROR goto yyerrorlab
2529
2530
2531/* Like YYERROR except do call yyerror. This remains here temporarily
2532 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002533 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002534
Reid Spencer68a24bd2005-08-27 18:50:39 +00002535#define YYFAIL goto yyerrlab
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002536
Reid Spencer68a24bd2005-08-27 18:50:39 +00002537#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002538
2539#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002540do \
2541 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002542 { \
2543 yychar = (Token); \
2544 yylval = (Value); \
2545 yytoken = YYTRANSLATE (yychar); \
2546 YYPOPSTACK (1); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002547 goto yybackup; \
2548 } \
2549 else \
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002550 { \
2551 yyerror (YY_("syntax error: cannot back up")); \
2552 YYERROR; \
2553 } \
2554while (YYID (0))
2555
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002556
Reid Spencer68a24bd2005-08-27 18:50:39 +00002557#define YYTERROR 1
2558#define YYERRCODE 256
2559
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002560
2561/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2562 If N is 0, then set CURRENT to the empty location which ends
2563 the previous symbol: RHS[0] (always defined). */
2564
2565#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2566#ifndef YYLLOC_DEFAULT
2567# define YYLLOC_DEFAULT(Current, Rhs, N) \
2568 do \
2569 if (YYID (N)) \
2570 { \
2571 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2572 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2573 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2574 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2575 } \
2576 else \
2577 { \
2578 (Current).first_line = (Current).last_line = \
2579 YYRHSLOC (Rhs, 0).last_line; \
2580 (Current).first_column = (Current).last_column = \
2581 YYRHSLOC (Rhs, 0).last_column; \
2582 } \
2583 while (YYID (0))
Reid Spencer68a24bd2005-08-27 18:50:39 +00002584#endif
2585
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002586
2587/* YY_LOCATION_PRINT -- Print the location on the stream.
2588 This macro was not mandated originally: define only if we know
2589 we won't break user code: when these are the locations we know. */
2590
2591#ifndef YY_LOCATION_PRINT
2592# if YYLTYPE_IS_TRIVIAL
2593# define YY_LOCATION_PRINT(File, Loc) \
2594 fprintf (File, "%d.%d-%d.%d", \
2595 (Loc).first_line, (Loc).first_column, \
2596 (Loc).last_line, (Loc).last_column)
2597# else
2598# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2599# endif
2600#endif
2601
2602
2603/* YYLEX -- calling `yylex' with the right arguments. */
2604
Reid Spencer41dff5e2007-01-26 08:05:27 +00002605#ifdef YYLEX_PARAM
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002606# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002607#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002608# define YYLEX yylex ()
Chris Lattner6cdc6822007-04-26 05:31:05 +00002609#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002610
2611/* Enable debugging if requested. */
2612#if YYDEBUG
2613
2614# ifndef YYFPRINTF
2615# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2616# define YYFPRINTF fprintf
2617# endif
2618
2619# define YYDPRINTF(Args) \
2620do { \
2621 if (yydebug) \
2622 YYFPRINTF Args; \
2623} while (YYID (0))
2624
2625# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2626do { \
2627 if (yydebug) \
2628 { \
2629 YYFPRINTF (stderr, "%s ", Title); \
2630 yy_symbol_print (stderr, \
2631 Type, Value); \
2632 YYFPRINTF (stderr, "\n"); \
2633 } \
2634} while (YYID (0))
2635
2636
2637/*--------------------------------.
2638| Print this symbol on YYOUTPUT. |
2639`--------------------------------*/
2640
2641/*ARGSUSED*/
2642#if (defined __STDC__ || defined __C99__FUNC__ \
2643 || defined __cplusplus || defined _MSC_VER)
2644static void
2645yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Chris Lattner6cdc6822007-04-26 05:31:05 +00002646#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002647static void
2648yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2649 FILE *yyoutput;
2650 int yytype;
2651 YYSTYPE const * const yyvaluep;
Chris Lattner6cdc6822007-04-26 05:31:05 +00002652#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002653{
2654 if (!yyvaluep)
2655 return;
2656# ifdef YYPRINT
2657 if (yytype < YYNTOKENS)
2658 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2659# else
2660 YYUSE (yyoutput);
2661# endif
2662 switch (yytype)
2663 {
2664 default:
2665 break;
2666 }
2667}
2668
2669
2670/*--------------------------------.
2671| Print this symbol on YYOUTPUT. |
2672`--------------------------------*/
2673
2674#if (defined __STDC__ || defined __C99__FUNC__ \
2675 || defined __cplusplus || defined _MSC_VER)
2676static void
2677yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2678#else
2679static void
2680yy_symbol_print (yyoutput, yytype, yyvaluep)
2681 FILE *yyoutput;
2682 int yytype;
2683 YYSTYPE const * const yyvaluep;
Christopher Lamb5c104242007-04-22 20:09:11 +00002684#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002685{
2686 if (yytype < YYNTOKENS)
2687 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2688 else
2689 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002690
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002691 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2692 YYFPRINTF (yyoutput, ")");
2693}
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002694
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002695/*------------------------------------------------------------------.
2696| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2697| TOP (included). |
2698`------------------------------------------------------------------*/
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002699
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002700#if (defined __STDC__ || defined __C99__FUNC__ \
2701 || defined __cplusplus || defined _MSC_VER)
2702static void
2703yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2704#else
2705static void
2706yy_stack_print (bottom, top)
2707 yytype_int16 *bottom;
2708 yytype_int16 *top;
Christopher Lamb5c104242007-04-22 20:09:11 +00002709#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002710{
2711 YYFPRINTF (stderr, "Stack now");
2712 for (; bottom <= top; ++bottom)
2713 YYFPRINTF (stderr, " %d", *bottom);
2714 YYFPRINTF (stderr, "\n");
2715}
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002716
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002717# define YY_STACK_PRINT(Bottom, Top) \
2718do { \
2719 if (yydebug) \
2720 yy_stack_print ((Bottom), (Top)); \
2721} while (YYID (0))
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002722
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002723
2724/*------------------------------------------------.
2725| Report that the YYRULE is going to be reduced. |
2726`------------------------------------------------*/
2727
2728#if (defined __STDC__ || defined __C99__FUNC__ \
2729 || defined __cplusplus || defined _MSC_VER)
2730static void
2731yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2732#else
2733static void
2734yy_reduce_print (yyvsp, yyrule)
2735 YYSTYPE *yyvsp;
2736 int yyrule;
Christopher Lamb2330e4d2007-04-21 08:16:25 +00002737#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002738{
2739 int yynrhs = yyr2[yyrule];
2740 int yyi;
2741 unsigned long int yylno = yyrline[yyrule];
2742 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2743 yyrule - 1, yylno);
2744 /* The symbols being reduced. */
2745 for (yyi = 0; yyi < yynrhs; yyi++)
2746 {
2747 fprintf (stderr, " $%d = ", yyi + 1);
2748 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2749 &(yyvsp[(yyi + 1) - (yynrhs)])
2750 );
2751 fprintf (stderr, "\n");
2752 }
2753}
Reid Spencerc67bdc22007-04-21 18:36:27 +00002754
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002755# define YY_REDUCE_PRINT(Rule) \
2756do { \
2757 if (yydebug) \
2758 yy_reduce_print (yyvsp, Rule); \
2759} while (YYID (0))
Reid Spencerc67bdc22007-04-21 18:36:27 +00002760
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002761/* Nonzero means print parse trace. It is left uninitialized so that
2762 multiple parsers can coexist. */
2763int yydebug;
2764#else /* !YYDEBUG */
2765# define YYDPRINTF(Args)
2766# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2767# define YY_STACK_PRINT(Bottom, Top)
2768# define YY_REDUCE_PRINT(Rule)
2769#endif /* !YYDEBUG */
2770
2771
2772/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002773#ifndef YYINITDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002774# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002775#endif
2776
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002777/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2778 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002779
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002780 Do not make this value too large; the results are undefined if
2781 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2782 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002783
2784#ifndef YYMAXDEPTH
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002785# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002786#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002787
Reid Spencer68a24bd2005-08-27 18:50:39 +00002788
2789
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002790#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002791
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002792# ifndef yystrlen
2793# if defined __GLIBC__ && defined _STRING_H
2794# define yystrlen strlen
2795# else
2796/* Return the length of YYSTR. */
2797#if (defined __STDC__ || defined __C99__FUNC__ \
2798 || defined __cplusplus || defined _MSC_VER)
2799static YYSIZE_T
2800yystrlen (const char *yystr)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002801#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002802static YYSIZE_T
2803yystrlen (yystr)
2804 const char *yystr;
2805#endif
2806{
2807 YYSIZE_T yylen;
2808 for (yylen = 0; yystr[yylen]; yylen++)
2809 continue;
2810 return yylen;
2811}
2812# endif
2813# endif
2814
2815# ifndef yystpcpy
2816# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2817# define yystpcpy stpcpy
2818# else
2819/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2820 YYDEST. */
2821#if (defined __STDC__ || defined __C99__FUNC__ \
2822 || defined __cplusplus || defined _MSC_VER)
2823static char *
2824yystpcpy (char *yydest, const char *yysrc)
2825#else
2826static char *
2827yystpcpy (yydest, yysrc)
2828 char *yydest;
2829 const char *yysrc;
2830#endif
2831{
2832 char *yyd = yydest;
2833 const char *yys = yysrc;
2834
2835 while ((*yyd++ = *yys++) != '\0')
2836 continue;
2837
2838 return yyd - 1;
2839}
2840# endif
2841# endif
2842
2843# ifndef yytnamerr
2844/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2845 quotes and backslashes, so that it's suitable for yyerror. The
2846 heuristic is that double-quoting is unnecessary unless the string
2847 contains an apostrophe, a comma, or backslash (other than
2848 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2849 null, do not copy; instead, return the length of what the result
2850 would have been. */
2851static YYSIZE_T
2852yytnamerr (char *yyres, const char *yystr)
2853{
2854 if (*yystr == '"')
2855 {
2856 YYSIZE_T yyn = 0;
2857 char const *yyp = yystr;
2858
2859 for (;;)
2860 switch (*++yyp)
2861 {
2862 case '\'':
2863 case ',':
2864 goto do_not_strip_quotes;
2865
2866 case '\\':
2867 if (*++yyp != '\\')
2868 goto do_not_strip_quotes;
2869 /* Fall through. */
2870 default:
2871 if (yyres)
2872 yyres[yyn] = *yyp;
2873 yyn++;
2874 break;
2875
2876 case '"':
2877 if (yyres)
2878 yyres[yyn] = '\0';
2879 return yyn;
2880 }
2881 do_not_strip_quotes: ;
2882 }
2883
2884 if (! yyres)
2885 return yystrlen (yystr);
2886
2887 return yystpcpy (yyres, yystr) - yyres;
2888}
2889# endif
2890
2891/* Copy into YYRESULT an error message about the unexpected token
2892 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2893 including the terminating null byte. If YYRESULT is null, do not
2894 copy anything; just return the number of bytes that would be
2895 copied. As a special case, return 0 if an ordinary "syntax error"
2896 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2897 size calculation. */
2898static YYSIZE_T
2899yysyntax_error (char *yyresult, int yystate, int yychar)
2900{
2901 int yyn = yypact[yystate];
2902
2903 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2904 return 0;
2905 else
2906 {
2907 int yytype = YYTRANSLATE (yychar);
2908 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2909 YYSIZE_T yysize = yysize0;
2910 YYSIZE_T yysize1;
2911 int yysize_overflow = 0;
2912 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2913 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2914 int yyx;
2915
2916# if 0
2917 /* This is so xgettext sees the translatable formats that are
2918 constructed on the fly. */
2919 YY_("syntax error, unexpected %s");
2920 YY_("syntax error, unexpected %s, expecting %s");
2921 YY_("syntax error, unexpected %s, expecting %s or %s");
2922 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2923 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2924# endif
2925 char *yyfmt;
2926 char const *yyf;
2927 static char const yyunexpected[] = "syntax error, unexpected %s";
2928 static char const yyexpecting[] = ", expecting %s";
2929 static char const yyor[] = " or %s";
2930 char yyformat[sizeof yyunexpected
2931 + sizeof yyexpecting - 1
2932 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2933 * (sizeof yyor - 1))];
2934 char const *yyprefix = yyexpecting;
2935
2936 /* Start YYX at -YYN if negative to avoid negative indexes in
2937 YYCHECK. */
2938 int yyxbegin = yyn < 0 ? -yyn : 0;
2939
2940 /* Stay within bounds of both yycheck and yytname. */
2941 int yychecklim = YYLAST - yyn + 1;
2942 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2943 int yycount = 1;
2944
2945 yyarg[0] = yytname[yytype];
2946 yyfmt = yystpcpy (yyformat, yyunexpected);
2947
2948 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2949 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2950 {
2951 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2952 {
2953 yycount = 1;
2954 yysize = yysize0;
2955 yyformat[sizeof yyunexpected - 1] = '\0';
2956 break;
2957 }
2958 yyarg[yycount++] = yytname[yyx];
2959 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2960 yysize_overflow |= (yysize1 < yysize);
2961 yysize = yysize1;
2962 yyfmt = yystpcpy (yyfmt, yyprefix);
2963 yyprefix = yyor;
2964 }
2965
2966 yyf = YY_(yyformat);
2967 yysize1 = yysize + yystrlen (yyf);
2968 yysize_overflow |= (yysize1 < yysize);
2969 yysize = yysize1;
2970
2971 if (yysize_overflow)
2972 return YYSIZE_MAXIMUM;
2973
2974 if (yyresult)
2975 {
2976 /* Avoid sprintf, as that infringes on the user's name space.
2977 Don't have undefined behavior even if the translation
2978 produced a string with the wrong number of "%s"s. */
2979 char *yyp = yyresult;
2980 int yyi = 0;
2981 while ((*yyp = *yyf) != '\0')
2982 {
2983 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2984 {
2985 yyp += yytnamerr (yyp, yyarg[yyi++]);
2986 yyf += 2;
2987 }
2988 else
2989 {
2990 yyp++;
2991 yyf++;
2992 }
2993 }
2994 }
2995 return yysize;
2996 }
2997}
2998#endif /* YYERROR_VERBOSE */
2999
3000
3001/*-----------------------------------------------.
3002| Release the memory associated to this symbol. |
3003`-----------------------------------------------*/
3004
3005/*ARGSUSED*/
3006#if (defined __STDC__ || defined __C99__FUNC__ \
3007 || defined __cplusplus || defined _MSC_VER)
3008static void
3009yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3010#else
3011static void
3012yydestruct (yymsg, yytype, yyvaluep)
3013 const char *yymsg;
3014 int yytype;
3015 YYSTYPE *yyvaluep;
3016#endif
3017{
3018 YYUSE (yyvaluep);
3019
3020 if (!yymsg)
3021 yymsg = "Deleting";
3022 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3023
3024 switch (yytype)
3025 {
3026
3027 default:
3028 break;
3029 }
3030}
3031
3032
3033/* Prevent warnings from -Wmissing-prototypes. */
3034
3035#ifdef YYPARSE_PARAM
3036#if defined __STDC__ || defined __cplusplus
3037int yyparse (void *YYPARSE_PARAM);
3038#else
3039int yyparse ();
3040#endif
3041#else /* ! YYPARSE_PARAM */
3042#if defined __STDC__ || defined __cplusplus
Reid Spencere812fb22006-01-19 01:21:04 +00003043int yyparse (void);
Chris Lattner6cdc6822007-04-26 05:31:05 +00003044#else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003045int yyparse ();
Christopher Lamb5c104242007-04-22 20:09:11 +00003046#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003047#endif /* ! YYPARSE_PARAM */
Chris Lattner7d9801d2007-02-13 00:58:01 +00003048
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003049
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003050
3051/* The look-ahead symbol. */
3052int yychar;
3053
3054/* The semantic value of the look-ahead symbol. */
3055YYSTYPE yylval;
3056
3057/* Number of syntax errors so far. */
3058int yynerrs;
3059
3060
3061
3062/*----------.
3063| yyparse. |
3064`----------*/
3065
3066#ifdef YYPARSE_PARAM
3067#if (defined __STDC__ || defined __C99__FUNC__ \
3068 || defined __cplusplus || defined _MSC_VER)
3069int
3070yyparse (void *YYPARSE_PARAM)
3071#else
3072int
3073yyparse (YYPARSE_PARAM)
3074 void *YYPARSE_PARAM;
3075#endif
3076#else /* ! YYPARSE_PARAM */
3077#if (defined __STDC__ || defined __C99__FUNC__ \
3078 || defined __cplusplus || defined _MSC_VER)
3079int
3080yyparse (void)
3081#else
3082int
3083yyparse ()
3084
Chris Lattner6cdc6822007-04-26 05:31:05 +00003085#endif
3086#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003087{
3088
3089 int yystate;
3090 int yyn;
3091 int yyresult;
3092 /* Number of tokens to shift before error messages enabled. */
3093 int yyerrstatus;
3094 /* Look-ahead token as an internal (translated) token number. */
3095 int yytoken = 0;
3096#if YYERROR_VERBOSE
3097 /* Buffer for error messages, and its allocated size. */
3098 char yymsgbuf[128];
3099 char *yymsg = yymsgbuf;
3100 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Chris Lattner6cdc6822007-04-26 05:31:05 +00003101#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003102
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003103 /* Three stacks and their tools:
3104 `yyss': related to states,
3105 `yyvs': related to semantic values,
3106 `yyls': related to locations.
3107
3108 Refer to the stacks thru separate pointers, to allow yyoverflow
3109 to reallocate them elsewhere. */
3110
3111 /* The state stack. */
3112 yytype_int16 yyssa[YYINITDEPTH];
3113 yytype_int16 *yyss = yyssa;
3114 yytype_int16 *yyssp;
3115
3116 /* The semantic value stack. */
3117 YYSTYPE yyvsa[YYINITDEPTH];
3118 YYSTYPE *yyvs = yyvsa;
3119 YYSTYPE *yyvsp;
3120
3121
3122
3123#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3124
3125 YYSIZE_T yystacksize = YYINITDEPTH;
3126
3127 /* The variables used to return semantic value and location from the
3128 action routines. */
3129 YYSTYPE yyval;
3130
3131
3132 /* The number of symbols on the RHS of the reduced rule.
3133 Keep to zero when no symbol should be popped. */
3134 int yylen = 0;
3135
3136 YYDPRINTF ((stderr, "Starting parse\n"));
3137
Reid Spencer68a24bd2005-08-27 18:50:39 +00003138 yystate = 0;
3139 yyerrstatus = 0;
3140 yynerrs = 0;
3141 yychar = YYEMPTY; /* Cause a token to be read. */
3142
3143 /* Initialize stack pointers.
3144 Waste one element of value and location stack
3145 so that they stay on the same level as the state stack.
3146 The wasted elements are never initialized. */
3147
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003148 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003149 yyvsp = yyvs;
3150
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003151 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003152
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003153/*------------------------------------------------------------.
3154| yynewstate -- Push a new state, which is found in yystate. |
3155`------------------------------------------------------------*/
3156 yynewstate:
3157 /* In all cases, when you get here, the value and location stacks
3158 have just been pushed. So pushing a state here evens the stacks. */
3159 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003160
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003161 yysetstate:
3162 *yyssp = yystate;
3163
3164 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003165 {
3166 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003167 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003168
3169#ifdef yyoverflow
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003170 {
3171 /* Give user a chance to reallocate the stack. Use copies of
3172 these so that the &'s don't force the real ones into
3173 memory. */
3174 YYSTYPE *yyvs1 = yyvs;
3175 yytype_int16 *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003176
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003177
3178 /* Each stack pointer address is followed by the size of the
3179 data in use in that stack, in bytes. This used to be a
3180 conditional around just the two extra args, but that might
3181 be undefined if yyoverflow is a macro. */
3182 yyoverflow (YY_("memory exhausted"),
3183 &yyss1, yysize * sizeof (*yyssp),
3184 &yyvs1, yysize * sizeof (*yyvsp),
3185
3186 &yystacksize);
3187
3188 yyss = yyss1;
3189 yyvs = yyvs1;
3190 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003191#else /* no yyoverflow */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003192# ifndef YYSTACK_RELOCATE
3193 goto yyexhaustedlab;
3194# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00003195 /* Extend the stack our own way. */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003196 if (YYMAXDEPTH <= yystacksize)
3197 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003198 yystacksize *= 2;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003199 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003200 yystacksize = YYMAXDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003201
3202 {
3203 yytype_int16 *yyss1 = yyss;
3204 union yyalloc *yyptr =
3205 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3206 if (! yyptr)
3207 goto yyexhaustedlab;
3208 YYSTACK_RELOCATE (yyss);
3209 YYSTACK_RELOCATE (yyvs);
3210
3211# undef YYSTACK_RELOCATE
3212 if (yyss1 != yyssa)
3213 YYSTACK_FREE (yyss1);
3214 }
3215# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003216#endif /* no yyoverflow */
3217
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003218 yyssp = yyss + yysize - 1;
3219 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003220
3221
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003222 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3223 (unsigned long int) yystacksize));
3224
3225 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003226 YYABORT;
3227 }
3228
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003229 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003230
3231 goto yybackup;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003232
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003233/*-----------.
3234| yybackup. |
3235`-----------*/
3236yybackup:
Andrew Lenharth6353e052006-12-08 18:07:09 +00003237
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003238 /* Do appropriate processing given the current state. Read a
3239 look-ahead token if we need one and don't already have one. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003240
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003241 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003242 yyn = yypact[yystate];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003243 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003244 goto yydefault;
3245
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003246 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003247
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003248 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003249 if (yychar == YYEMPTY)
3250 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003251 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003252 yychar = YYLEX;
3253 }
3254
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003255 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003256 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003257 yychar = yytoken = YYEOF;
3258 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003259 }
3260 else
3261 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003262 yytoken = YYTRANSLATE (yychar);
3263 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003264 }
3265
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003266 /* If the proper action on seeing token YYTOKEN is to reduce or to
3267 detect an error, take that action. */
3268 yyn += yytoken;
3269 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003270 goto yydefault;
3271 yyn = yytable[yyn];
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003272 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003273 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003274 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003275 goto yyerrlab;
3276 yyn = -yyn;
3277 goto yyreduce;
3278 }
3279
3280 if (yyn == YYFINAL)
3281 YYACCEPT;
3282
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003283 /* Count tokens shifted since error; after three, turn off error
3284 status. */
3285 if (yyerrstatus)
3286 yyerrstatus--;
Christopher Lamb5c104242007-04-22 20:09:11 +00003287
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003288 /* Shift the look-ahead token. */
3289 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer7780acb2007-04-16 06:56:07 +00003290
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003291 /* Discard the shifted token unless it is eof. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003292 if (yychar != YYEOF)
3293 yychar = YYEMPTY;
3294
Chris Lattner6cdc6822007-04-26 05:31:05 +00003295 yystate = yyn;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003296 *++yyvsp = yylval;
3297
Reid Spencer68a24bd2005-08-27 18:50:39 +00003298 goto yynewstate;
3299
Chris Lattner6cdc6822007-04-26 05:31:05 +00003300
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003301/*-----------------------------------------------------------.
3302| yydefault -- do the default action for the current state. |
3303`-----------------------------------------------------------*/
3304yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003305 yyn = yydefact[yystate];
3306 if (yyn == 0)
3307 goto yyerrlab;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003308 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003309
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003310
3311/*-----------------------------.
3312| yyreduce -- Do a reduction. |
3313`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003314yyreduce:
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003315 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003316 yylen = yyr2[yyn];
3317
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003318 /* If YYLEN is nonzero, implement the default value of the action:
3319 `$$ = $1'.
3320
3321 Otherwise, the following line sets YYVAL to garbage.
3322 This behavior is undocumented and Bison
3323 users should not rely upon it. Assigning to YYVAL
3324 unconditionally makes the parser a bit smaller, and it avoids a
3325 GCC warning that YYVAL may be used uninitialized. */
3326 yyval = yyvsp[1-yylen];
3327
3328
3329 YY_REDUCE_PRINT (yyn);
3330 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003331 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003332 case 29:
3333#line 1116 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3334 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3335 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003336
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003337 case 30:
3338#line 1116 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3339 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3340 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003341
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003342 case 31:
3343#line 1117 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3344 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3345 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003346
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003347 case 32:
3348#line 1117 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3349 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3350 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003351
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003352 case 33:
3353#line 1118 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3354 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3355 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003356
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003357 case 34:
3358#line 1118 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3359 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3360 break;
3361
3362 case 35:
3363#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3364 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3365 break;
3366
3367 case 36:
3368#line 1119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3369 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3370 break;
3371
3372 case 37:
3373#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3374 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3375 break;
3376
3377 case 38:
3378#line 1120 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3379 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3380 break;
3381
3382 case 39:
3383#line 1124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3384 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3385 break;
3386
3387 case 40:
3388#line 1124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3389 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3390 break;
3391
3392 case 41:
3393#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3394 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3395 break;
3396
3397 case 42:
3398#line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3399 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3400 break;
3401
3402 case 43:
3403#line 1126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3404 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3405 break;
3406
3407 case 44:
3408#line 1126 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3409 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3410 break;
3411
3412 case 45:
3413#line 1127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3414 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3415 break;
3416
3417 case 46:
3418#line 1127 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3419 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3420 break;
3421
3422 case 47:
3423#line 1128 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3424 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3425 break;
3426
3427 case 48:
3428#line 1128 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3429 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3430 break;
3431
3432 case 49:
3433#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3434 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3435 break;
3436
3437 case 50:
3438#line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3439 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3440 break;
3441
3442 case 51:
3443#line 1130 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3444 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3445 break;
3446
3447 case 52:
3448#line 1130 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3449 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3450 break;
3451
3452 case 53:
3453#line 1131 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3454 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3455 break;
3456
3457 case 54:
3458#line 1132 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3459 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3460 break;
3461
3462 case 61:
3463#line 1141 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3464 { (yyval.StrVal) = 0; ;}
3465 break;
3466
3467 case 62:
3468#line 1145 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3469 {
3470 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003471 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003472 ;}
3473 break;
3474
3475 case 63:
3476#line 1149 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3477 {
3478 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003479 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003480 ;}
3481 break;
3482
3483 case 67:
3484#line 1157 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3485 {
3486 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003487 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003488 ;}
3489 break;
3490
3491 case 68:
3492#line 1162 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3493 {
3494 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003495 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003496 ;}
3497 break;
3498
3499 case 69:
3500#line 1168 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3501 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3502 break;
3503
3504 case 70:
3505#line 1169 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3506 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3507 break;
3508
3509 case 71:
3510#line 1170 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3511 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3512 break;
3513
3514 case 72:
3515#line 1171 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3516 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3517 break;
3518
3519 case 73:
3520#line 1172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3521 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3522 break;
3523
3524 case 74:
3525#line 1176 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3526 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3527 break;
3528
3529 case 75:
3530#line 1177 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3531 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3532 break;
3533
3534 case 76:
3535#line 1178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3536 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3537 break;
3538
3539 case 77:
3540#line 1182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3541 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3542 break;
3543
3544 case 78:
3545#line 1183 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3546 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3547 break;
3548
3549 case 79:
3550#line 1184 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3551 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3552 break;
3553
3554 case 80:
3555#line 1188 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3556 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3557 break;
3558
3559 case 81:
3560#line 1189 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3561 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3562 break;
3563
3564 case 82:
3565#line 1190 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3566 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3567 break;
3568
3569 case 83:
3570#line 1194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3571 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3572 break;
3573
3574 case 84:
3575#line 1195 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3576 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3577 break;
3578
3579 case 85:
3580#line 1196 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3581 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3582 break;
3583
3584 case 86:
3585#line 1197 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3586 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3587 break;
3588
3589 case 87:
3590#line 1198 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3591 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3592 break;
3593
3594 case 88:
3595#line 1202 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3596 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3597 break;
3598
3599 case 89:
3600#line 1203 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3601 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3602 break;
3603
3604 case 90:
3605#line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3606 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3607 break;
3608
3609 case 91:
3610#line 1207 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3611 { (yyval.UIntVal) = CallingConv::C; ;}
3612 break;
3613
3614 case 92:
3615#line 1208 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3616 { (yyval.UIntVal) = CallingConv::C; ;}
3617 break;
3618
3619 case 93:
3620#line 1209 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3621 { (yyval.UIntVal) = CallingConv::Fast; ;}
3622 break;
3623
3624 case 94:
3625#line 1210 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3626 { (yyval.UIntVal) = CallingConv::Cold; ;}
3627 break;
3628
3629 case 95:
3630#line 1211 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3631 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3632 break;
3633
3634 case 96:
3635#line 1212 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3636 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3637 break;
3638
3639 case 97:
3640#line 1213 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3641 {
3642 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003643 GEN_ERROR("Calling conv too large");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003644 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003645 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003646 ;}
3647 break;
3648
3649 case 98:
3650#line 1220 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3651 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3652 break;
3653
3654 case 99:
3655#line 1221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3656 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3657 break;
3658
3659 case 100:
3660#line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3661 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3662 break;
3663
3664 case 101:
3665#line 1223 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3666 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3667 break;
3668
3669 case 102:
3670#line 1226 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3671 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3672 break;
3673
3674 case 103:
3675#line 1227 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3676 {
3677 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3678 ;}
3679 break;
3680
3681 case 104:
3682#line 1232 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3683 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3684 break;
3685
3686 case 105:
3687#line 1233 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3688 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3689 break;
3690
3691 case 107:
3692#line 1237 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3693 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3694 break;
3695
3696 case 108:
3697#line 1238 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3698 {
3699 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3700 ;}
3701 break;
3702
3703 case 109:
3704#line 1245 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3705 { (yyval.UIntVal) = 0; ;}
3706 break;
3707
3708 case 110:
3709#line 1246 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3710 {
3711 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3712 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003713 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003714 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003715;}
3716 break;
3717
3718 case 111:
3719#line 1252 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3720 { (yyval.UIntVal) = 0; ;}
3721 break;
3722
3723 case 112:
3724#line 1253 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3725 {
3726 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3727 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer66728ef2007-03-20 01:13:36 +00003728 GEN_ERROR("Alignment must be a power of two");
3729 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003730;}
3731 break;
3732
3733 case 113:
3734#line 1261 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3735 {
3736 for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
3737 if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003738 GEN_ERROR("Invalid character in section name");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003739 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003740 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003741;}
3742 break;
3743
3744 case 114:
3745#line 1269 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3746 { (yyval.StrVal) = 0; ;}
3747 break;
3748
3749 case 115:
3750#line 1270 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3751 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3752 break;
3753
3754 case 116:
3755#line 1275 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3756 {;}
3757 break;
3758
3759 case 117:
3760#line 1276 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3761 {;}
3762 break;
3763
3764 case 118:
3765#line 1277 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3766 {
3767 CurGV->setSection((yyvsp[(1) - (1)].StrVal));
3768 free((yyvsp[(1) - (1)].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003769 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003770 ;}
3771 break;
3772
3773 case 119:
3774#line 1282 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3775 {
3776 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003777 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003778 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003779 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003780 ;}
3781 break;
3782
3783 case 124:
3784#line 1298 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3785 {
3786 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003787 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003788 ;}
3789 break;
3790
3791 case 125:
3792#line 1302 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3793 {
3794 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003795 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003796 ;}
3797 break;
3798
3799 case 126:
3800#line 1306 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3801 { // Pointer type?
3802 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003803 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003804 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3805 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003806 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003807 ;}
3808 break;
3809
3810 case 127:
3811#line 1313 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3812 { // Named types are also simple types...
3813 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003814 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003815 (yyval.TypeVal) = new PATypeHolder(tmp);
3816 ;}
3817 break;
3818
3819 case 128:
3820#line 1318 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3821 { // Type UpReference
3822 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003823 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003824 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3825 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003826 UR_OUT("New Upreference!\n");
3827 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003828 ;}
3829 break;
3830
3831 case 129:
3832#line 1326 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3833 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003834 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003835 ParamAttrsVector Attrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003836 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3837 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003838 Attrs.push_back(X);
3839 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003840 unsigned index = 1;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003841 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003842 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003843 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003844 Params.push_back(Ty);
3845 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003846 if (I->Attrs != ParamAttr::None) {
3847 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3848 Attrs.push_back(X);
3849 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003850 }
3851 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3852 if (isVarArg) Params.pop_back();
3853
Reid Spencer7b5d4662007-04-09 06:16:21 +00003854 ParamAttrsList *ActualAttrs = 0;
3855 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003856 ActualAttrs = ParamAttrsList::get(Attrs);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003857 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
3858 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3859 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3860 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003861 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003862 ;}
3863 break;
3864
3865 case 130:
3866#line 1356 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3867 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003868 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003869 ParamAttrsVector Attrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003870 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3871 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003872 Attrs.push_back(X);
3873 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003874 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003875 unsigned index = 1;
3876 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003877 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003878 Params.push_back(Ty);
3879 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003880 if (I->Attrs != ParamAttr::None) {
3881 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3882 Attrs.push_back(X);
3883 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003884 }
3885 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3886 if (isVarArg) Params.pop_back();
3887
Reid Spencer7b5d4662007-04-09 06:16:21 +00003888 ParamAttrsList *ActualAttrs = 0;
3889 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003890 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003891
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003892 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
3893 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3894 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003895 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003896 ;}
3897 break;
3898
3899 case 131:
3900#line 1387 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3901 { // Sized array type?
3902 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3903 delete (yyvsp[(4) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003904 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003905 ;}
3906 break;
3907
3908 case 132:
3909#line 1392 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3910 { // Vector type?
3911 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
3912 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003913 GEN_ERROR("Unsigned result not equal to signed result");
3914 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003915 GEN_ERROR("Element type of a VectorType must be primitive");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003916 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003917 GEN_ERROR("Vector length should be a power of 2");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003918 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
3919 delete (yyvsp[(4) - (5)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003920 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003921 ;}
3922 break;
3923
3924 case 133:
3925#line 1404 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3926 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003927 std::vector<const Type*> Elements;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003928 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
3929 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003930 Elements.push_back(*I);
3931
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003932 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3933 delete (yyvsp[(2) - (3)].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003934 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003935 ;}
3936 break;
3937
3938 case 134:
3939#line 1414 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3940 { // Empty structure type?
3941 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003942 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003943 ;}
3944 break;
3945
3946 case 135:
3947#line 1418 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3948 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003949 std::vector<const Type*> Elements;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003950 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
3951 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003952 Elements.push_back(*I);
3953
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003954 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3955 delete (yyvsp[(3) - (5)].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003956 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003957 ;}
3958 break;
3959
3960 case 136:
3961#line 1428 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3962 { // Empty structure type?
3963 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003964 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003965 ;}
3966 break;
3967
3968 case 137:
3969#line 1435 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3970 {
3971 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
3972 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
3973 ;}
3974 break;
3975
3976 case 138:
3977#line 1442 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3978 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003979 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003980 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
3981 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003982 GEN_ERROR("LLVM functions cannot return aggregate types");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003983 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
3984 ;}
3985 break;
3986
3987 case 139:
3988#line 1449 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3989 {
3990 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3991 ;}
3992 break;
3993
3994 case 140:
3995#line 1454 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3996 {
3997 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3998 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003999 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004000 ;}
4001 break;
4002
4003 case 141:
4004#line 1459 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4005 {
4006 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00004007 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004008 ;}
4009 break;
4010
4011 case 143:
4012#line 1467 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4013 {
4014 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00004015 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004016 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004017 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004018 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004019 ;}
4020 break;
4021
4022 case 144:
4023#line 1474 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4024 {
4025 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00004026 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004027 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004028 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004029 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004030 ;}
4031 break;
4032
4033 case 145:
4034#line 1481 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4035 {
4036 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004037 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004038 ;}
4039 break;
4040
4041 case 146:
4042#line 1489 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4043 {
4044 (yyval.TypeList) = new std::list<PATypeHolder>();
4045 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4046 delete (yyvsp[(1) - (1)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004047 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004048 ;}
4049 break;
4050
4051 case 147:
4052#line 1495 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4053 {
4054 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4055 delete (yyvsp[(3) - (3)].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00004056 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004057 ;}
4058 break;
4059
4060 case 148:
4061#line 1507 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4062 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00004063 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004064 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4065 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004066 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004067 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004068 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004069 const Type *ETy = ATy->getElementType();
4070 int NumElements = ATy->getNumElements();
4071
4072 // Verify that we have the correct size...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004073 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004074 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004075 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004076 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004077
4078 // Verify all elements are correct type!
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004079 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4080 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004081 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4082 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004083 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004084 }
4085
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004086 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4087 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004088 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004089 ;}
4090 break;
4091
4092 case 149:
4093#line 1535 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4094 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004095 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004096 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4097 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004098 if (ATy == 0)
4099 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004100 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004101
Andrew Lenharth6353e052006-12-08 18:07:09 +00004102 int NumElements = ATy->getNumElements();
4103 if (NumElements != -1 && NumElements != 0)
4104 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00004105 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004106 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4107 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004108 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004109 ;}
4110 break;
4111
4112 case 150:
4113#line 1551 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4114 {
Reid Spencer14310612006-12-31 05:40:51 +00004115 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004116 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4117 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004118 if (ATy == 0)
4119 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004120 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00004121
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004122 int NumElements = ATy->getNumElements();
4123 const Type *ETy = ATy->getElementType();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004124 char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
4125 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004126 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004127 itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004128 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004129 std::vector<Constant*> Vals;
4130 if (ETy == Type::Int8Ty) {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004131 for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004132 C != (unsigned char*)EndStr; ++C)
4133 Vals.push_back(ConstantInt::get(ETy, *C));
4134 } else {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004135 free((yyvsp[(3) - (3)].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00004136 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004137 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004138 free((yyvsp[(3) - (3)].StrVal));
4139 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4140 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004141 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004142 ;}
4143 break;
4144
4145 case 151:
4146#line 1580 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4147 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004148 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004149 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4150 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004151 if (PTy == 0)
4152 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004153 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004154 const Type *ETy = PTy->getElementType();
4155 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004156
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004157 // Verify that we have the correct size...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004158 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004159 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004160 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00004161 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004162
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004163 // Verify all elements are correct type!
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004164 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4165 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004166 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4167 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004168 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004169 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004170
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004171 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4172 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004173 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004174 ;}
4175 break;
4176
4177 case 152:
4178#line 1608 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4179 {
4180 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004181 if (STy == 0)
4182 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004183 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004184
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004185 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004186 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004187
4188 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004189 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4190 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004191 GEN_ERROR("Expected type '" +
4192 STy->getElementType(i)->getDescription() +
4193 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004194 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004195
4196 // Check to ensure that Type is not packed
4197 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004198 GEN_ERROR("Unpacked Initializer to vector type '" +
4199 STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004200
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004201 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4202 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004203 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004204 ;}
4205 break;
4206
4207 case 153:
4208#line 1634 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4209 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004210 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004211 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4212 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004213 if (STy == 0)
4214 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004215 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004216
4217 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004218 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004219
4220 // Check to ensure that Type is not packed
4221 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004222 GEN_ERROR("Unpacked Initializer to vector type '" +
4223 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004224
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004225 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4226 delete (yyvsp[(1) - (3)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004227 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004228 ;}
4229 break;
4230
4231 case 154:
4232#line 1654 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4233 {
4234 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004235 if (STy == 0)
4236 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004237 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004238
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004239 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004240 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004241
4242 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004243 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4244 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004245 GEN_ERROR("Expected type '" +
4246 STy->getElementType(i)->getDescription() +
4247 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004248 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004249
4250 // Check to ensure that Type is packed
4251 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004252 GEN_ERROR("Vector initializer to non-vector type '" +
4253 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004254
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004255 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4256 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004257 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004258 ;}
4259 break;
4260
4261 case 155:
4262#line 1680 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4263 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004264 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004265 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4266 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004267 if (STy == 0)
4268 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004269 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004270
4271 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004272 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004273
4274 // Check to ensure that Type is packed
4275 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004276 GEN_ERROR("Vector initializer to non-vector type '" +
4277 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004278
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004279 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4280 delete (yyvsp[(1) - (5)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004281 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004282 ;}
4283 break;
4284
4285 case 156:
4286#line 1700 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4287 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004288 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004289 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4290 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004291 if (PTy == 0)
4292 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004293 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004294
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004295 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4296 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004297 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004298 ;}
4299 break;
4300
4301 case 157:
4302#line 1712 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4303 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004304 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004305 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4306 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4307 delete (yyvsp[(1) - (2)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004308 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004309 ;}
4310 break;
4311
4312 case 158:
4313#line 1719 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4314 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004315 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004316 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4317 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004318 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004319 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004320
4321 // ConstExprs can exist in the body of a function, thus creating
4322 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004323 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004324 // symbol table instead of the module symbol table for the global symbol,
4325 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004326 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004327 //
4328 Function *SavedCurFn = CurFun.CurrentFunction;
4329 CurFun.CurrentFunction = 0;
4330
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004331 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004332 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004333
4334 CurFun.CurrentFunction = SavedCurFn;
4335
4336 // If this is an initializer for a constant pointer, which is referencing a
4337 // (currently) undefined variable, create a stub now that shall be replaced
4338 // in the future with the right type of variable.
4339 //
4340 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004341 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004342 const PointerType *PT = cast<PointerType>(Ty);
4343
4344 // First check to see if the forward references value is already created!
4345 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004346 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004347
4348 if (I != CurModule.GlobalRefs.end()) {
4349 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004350 (yyvsp[(2) - (2)].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004351 } else {
4352 std::string Name;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004353 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4354 Name = (yyvsp[(2) - (2)].ValIDVal).Name;
4355 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004356 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004357
4358 // Create the forward referenced global.
4359 GlobalValue *GV;
4360 if (const FunctionType *FTy =
4361 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004362 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004363 CurModule.CurrentModule);
4364 } else {
4365 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004366 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004367 Name, CurModule.CurrentModule);
4368 }
4369
4370 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004371 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004372 V = GV;
4373 }
4374 }
4375
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004376 (yyval.ConstVal) = cast<GlobalValue>(V);
4377 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004378 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004379 ;}
4380 break;
4381
4382 case 159:
4383#line 1785 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4384 {
Reid Spencer14310612006-12-31 05:40:51 +00004385 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004386 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4387 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004388 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004389 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4390 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4391 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004392 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004393 ;}
4394 break;
4395
4396 case 160:
4397#line 1795 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4398 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004399 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004400 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4401 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004402 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004403 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004404 (yyval.ConstVal) = Constant::getNullValue(Ty);
4405 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004406 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004407 ;}
4408 break;
4409
4410 case 161:
4411#line 1805 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4412 { // integral constants
4413 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004414 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004415 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004416 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004417 ;}
4418 break;
4419
4420 case 162:
4421#line 1811 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4422 { // arbitrary precision integer constants
4423 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4424 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004425 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004426 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004427 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4428 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4429 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00004430 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004431 ;}
4432 break;
4433
4434 case 163:
4435#line 1821 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4436 { // integral constants
4437 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004438 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004439 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004440 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004441 ;}
4442 break;
4443
4444 case 164:
4445#line 1827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4446 { // arbitrary precision integer constants
4447 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4448 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Reid Spencer38c91a92007-02-28 02:24:54 +00004449 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004450 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004451 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4452 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4453 delete (yyvsp[(2) - (2)].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004454 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004455 ;}
4456 break;
4457
4458 case 165:
4459#line 1837 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4460 { // Boolean constants
4461 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4462 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004463 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004464 ;}
4465 break;
4466
4467 case 166:
4468#line 1842 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4469 { // Boolean constants
4470 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4471 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer38c91a92007-02-28 02:24:54 +00004472 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004473 ;}
4474 break;
4475
4476 case 167:
4477#line 1847 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4478 { // Float & Double constants
4479 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004480 GEN_ERROR("Floating point constant invalid for type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004481 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004482 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004483 ;}
4484 break;
4485
4486 case 168:
4487#line 1855 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4488 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004489 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004490 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4491 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4492 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4493 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004494 GEN_ERROR("invalid cast opcode for cast from '" +
4495 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004496 DestTy->getDescription() + "'");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004497 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4498 delete (yyvsp[(5) - (6)].TypeVal);
4499 ;}
4500 break;
4501
4502 case 169:
4503#line 1867 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4504 {
4505 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004506 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004507
4508 const Type *IdxTy =
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004509 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004510 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004511 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004512 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004513
Chris Lattnerf7469af2007-01-31 04:44:08 +00004514 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004515 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4516 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004517 IdxVec.push_back(C);
4518 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004519 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004520
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004521 delete (yyvsp[(4) - (5)].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004522
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004523 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004524 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004525 ;}
4526 break;
4527
4528 case 170:
4529#line 1889 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4530 {
4531 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004532 GEN_ERROR("Select condition must be of boolean type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004533 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004534 GEN_ERROR("Select operand types must match");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004535 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004536 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004537 ;}
4538 break;
4539
4540 case 171:
4541#line 1897 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4542 {
4543 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004544 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004545 CHECK_FOR_ERROR;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004546 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4547 ;}
4548 break;
4549
4550 case 172:
4551#line 1903 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4552 {
4553 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004554 GEN_ERROR("Logical operator types must match");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004555 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4556 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4557 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004558 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004559 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004560 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004561 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004562 ;}
4563 break;
4564
4565 case 173:
4566#line 1914 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4567 {
4568 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004569 GEN_ERROR("icmp operand types must match");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004570 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4571 ;}
4572 break;
4573
4574 case 174:
4575#line 1919 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4576 {
4577 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004578 GEN_ERROR("fcmp operand types must match");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004579 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4580 ;}
4581 break;
4582
4583 case 175:
4584#line 1924 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4585 {
4586 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004587 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004588 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004589 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004590 ;}
4591 break;
4592
4593 case 176:
4594#line 1930 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4595 {
4596 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004597 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004598 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004599 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004600 ;}
4601 break;
4602
4603 case 177:
4604#line 1936 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4605 {
4606 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004607 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004608 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004609 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004610 ;}
4611 break;
4612
4613 case 178:
4614#line 1945 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4615 {
4616 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004617 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004618 ;}
4619 break;
4620
4621 case 179:
4622#line 1949 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4623 {
4624 (yyval.ConstVector) = new std::vector<Constant*>();
4625 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004626 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004627 ;}
4628 break;
4629
4630 case 180:
4631#line 1957 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4632 { (yyval.BoolVal) = false; ;}
4633 break;
4634
4635 case 181:
4636#line 1957 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4637 { (yyval.BoolVal) = true; ;}
4638 break;
4639
4640 case 182:
4641#line 1960 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4642 { (yyval.BoolVal) = true; ;}
4643 break;
4644
4645 case 183:
4646#line 1960 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4647 { (yyval.BoolVal) = false; ;}
4648 break;
4649
4650 case 184:
4651#line 1963 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4652 {
4653 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4654 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
4655 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4656 if (!Aliasee)
4657 GEN_ERROR("Aliases can be created only to global values");
4658
4659 (yyval.ConstVal) = Aliasee;
4660 CHECK_FOR_ERROR
4661 delete (yyvsp[(1) - (2)].TypeVal);
4662 ;}
4663 break;
4664
4665 case 185:
4666#line 1974 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4667 {
4668 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4669 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4670 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
4671 GEN_ERROR("invalid cast opcode for cast from '" +
4672 Val->getType()->getDescription() + "' to '" +
4673 DestTy->getDescription() + "'");
4674
4675 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4676 CHECK_FOR_ERROR
4677 delete (yyvsp[(5) - (6)].TypeVal);
4678 ;}
4679 break;
4680
4681 case 186:
4682#line 1995 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4683 {
4684 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer67d8ed92007-03-22 02:14:08 +00004685 CurModule.ModuleDone();
4686 CHECK_FOR_ERROR;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004687 ;}
4688 break;
4689
4690 case 187:
4691#line 2000 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4692 {
4693 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004694 CurModule.ModuleDone();
4695 CHECK_FOR_ERROR;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004696 ;}
4697 break;
4698
4699 case 190:
4700#line 2013 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4701 { CurFun.isDeclare = false; ;}
4702 break;
4703
4704 case 191:
4705#line 2013 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4706 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004707 CurFun.FunctionDone();
4708 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004709 ;}
4710 break;
4711
4712 case 192:
4713#line 2017 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4714 { CurFun.isDeclare = true; ;}
4715 break;
4716
4717 case 193:
4718#line 2017 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4719 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004720 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004721 ;}
4722 break;
4723
4724 case 194:
4725#line 2020 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4726 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004727 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004728 ;}
4729 break;
4730
4731 case 195:
4732#line 2023 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4733 {
Reid Spencer14310612006-12-31 05:40:51 +00004734 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004735 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004736 // Eagerly resolve types. This is not an optimization, this is a
4737 // requirement that is due to the fact that we could have this:
4738 //
4739 // %list = type { %list * }
4740 // %list = type { %list * } ; repeated type decl
4741 //
4742 // If types are not resolved eagerly, then the two types will not be
4743 // determined to be the same type!
4744 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004745 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004746
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004747 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004748 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004749 // If this is a named type that is not a redefinition, add it to the slot
4750 // table.
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004751 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004752 }
Reid Spencera132e042006-12-03 05:46:11 +00004753
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004754 delete (yyvsp[(3) - (3)].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004755 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004756 ;}
4757 break;
Reid Spencer38c91a92007-02-28 02:24:54 +00004758
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004759 case 196:
4760#line 2047 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4761 {
4762 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4763
4764 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004765 CHECK_FOR_ERROR
4766 // If this is a named type that is not a redefinition, add it to the slot
4767 // table.
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004768 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004769 }
4770 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004771 ;}
4772 break;
4773
4774 case 197:
4775#line 2058 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4776 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004777 /* "Externally Visible" Linkage */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004778 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004779 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004780 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4781 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004782 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004783 ;}
4784 break;
4785
4786 case 198:
4787#line 2065 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4788 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004789 CurGV = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004790 ;}
4791 break;
4792
4793 case 199:
4794#line 2069 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4795 {
4796 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004797 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004798 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004799 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004800 ;}
4801 break;
4802
4803 case 200:
4804#line 2074 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4805 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004806 CurGV = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004807 ;}
4808 break;
4809
4810 case 201:
4811#line 2078 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4812 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004813 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004814 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4815 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));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004816 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004817 delete (yyvsp[(6) - (6)].TypeVal);
4818 ;}
4819 break;
4820
4821 case 202:
4822#line 2084 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4823 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004824 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004825 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004826 ;}
4827 break;
4828
4829 case 203:
4830#line 2088 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4831 {
4832 std::string Name((yyvsp[(1) - (5)].StrVal));
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004833 if (Name.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004834 GEN_ERROR("Alias name cannot be empty");
4835
4836 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
4837 if (Aliasee == 0)
4838 GEN_ERROR(std::string("Invalid aliasee for alias: ") + (yyvsp[(1) - (5)].StrVal));
4839
4840 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
4841 CurModule.CurrentModule);
4842 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
4843 InsertValue(GA, CurModule.Values);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004844 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004845 ;}
4846 break;
4847
4848 case 204:
4849#line 2103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4850 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004851 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004852 ;}
4853 break;
4854
4855 case 205:
4856#line 2106 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4857 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004858 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004859 ;}
4860 break;
4861
4862 case 206:
4863#line 2112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4864 {
Chris Lattner66316012006-01-24 04:14:29 +00004865 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004866 char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
4867 std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
4868 free((yyvsp[(1) - (1)].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004869
4870 if (AsmSoFar.empty())
4871 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4872 else
4873 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004874 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004875;}
4876 break;
4877
4878 case 207:
4879#line 2125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4880 {
4881 CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
4882 free((yyvsp[(3) - (3)].StrVal));
4883 ;}
4884 break;
4885
4886 case 208:
4887#line 2129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4888 {
4889 CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
4890 free((yyvsp[(3) - (3)].StrVal));
4891 ;}
4892 break;
4893
4894 case 210:
4895#line 2136 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4896 {
4897 CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
4898 free((yyvsp[(3) - (3)].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004899 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004900 ;}
4901 break;
4902
4903 case 211:
4904#line 2141 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4905 {
4906 CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
4907 free((yyvsp[(1) - (1)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004908 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004909 ;}
4910 break;
4911
4912 case 212:
4913#line 2146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4914 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004915 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004916 ;}
4917 break;
4918
4919 case 213:
4920#line 2155 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4921 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004922 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004923 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
4924 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004925 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004926 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
4927 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
4928 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004929 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004930 ;}
4931 break;
4932
4933 case 214:
4934#line 2165 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4935 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004936 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004937 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4938 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004939 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004940 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
4941 (yyval.ArgList) = new ArgListType;
4942 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004943 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004944 ;}
4945 break;
4946
4947 case 215:
4948#line 2176 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4949 {
4950 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004951 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004952 ;}
4953 break;
4954
4955 case 216:
4956#line 2180 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4957 {
4958 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004959 struct ArgListEntry E;
4960 E.Ty = new PATypeHolder(Type::VoidTy);
4961 E.Name = 0;
4962 E.Attrs = ParamAttr::None;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004963 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004964 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004965 ;}
4966 break;
4967
4968 case 217:
4969#line 2189 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4970 {
4971 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004972 struct ArgListEntry E;
4973 E.Ty = new PATypeHolder(Type::VoidTy);
4974 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004975 E.Attrs = ParamAttr::None;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004976 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004977 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004978 ;}
4979 break;
4980
4981 case 218:
4982#line 2198 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4983 {
4984 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004985 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004986 ;}
4987 break;
4988
4989 case 219:
4990#line 2204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4991 {
4992 UnEscapeLexed((yyvsp[(3) - (9)].StrVal));
4993 std::string FunctionName((yyvsp[(3) - (9)].StrVal));
4994 free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004995
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004996 // Check the function result for abstractness if this is a define. We should
4997 // have no abstract types at this point
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004998 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
4999 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005000
Reid Spencer68a24bd2005-08-27 18:50:39 +00005001 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00005002 ParamAttrsVector Attrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005003 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
5004 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005005 Attrs.push_back(PAWI);
5006 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005007 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00005008 unsigned index = 1;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005009 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005010 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00005011 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5012 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00005013 ParamTypeList.push_back(Ty);
5014 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00005015 if (I->Attrs != ParamAttr::None) {
5016 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5017 Attrs.push_back(PAWI);
5018 }
Reid Spencer14310612006-12-31 05:40:51 +00005019 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005020 }
5021
5022 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5023 if (isVarArg) ParamTypeList.pop_back();
5024
Christopher Lamb5c104242007-04-22 20:09:11 +00005025 ParamAttrsList *PAL = 0;
5026 if (!Attrs.empty())
5027 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005028
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005029 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005030 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005031 delete (yyvsp[(2) - (9)].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005032
5033 ValID ID;
5034 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00005035 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005036 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00005037 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005038 }
5039
5040 Function *Fn = 0;
5041 // See if this function was forward referenced. If so, recycle the object.
5042 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5043 // Move the function to the end of the list, from whereever it was
5044 // previously inserted.
5045 Fn = cast<Function>(FWRef);
5046 CurModule.CurrentModule->getFunctionList().remove(Fn);
5047 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5048 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00005049 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005050 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005051 // The existing function doesn't have the same type. This is an overload
5052 // error.
5053 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
5054 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00005055 // Neither the existing or the current function is a declaration and they
5056 // have the same name and same type. Clearly this is a redefinition.
5057 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005058 } if (Fn->isDeclaration()) {
5059 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005060 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5061 AI != AE; ++AI)
5062 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00005063 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005064 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00005065 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00005066 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005067
Reid Spencer68a24bd2005-08-27 18:50:39 +00005068 InsertValue(Fn, CurModule.Values);
5069 }
5070
5071 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005072
5073 if (CurFun.isDeclare) {
5074 // If we have declaration, always overwrite linkage. This will allow us to
5075 // correctly handle cases, when pointer to function is passed as argument to
5076 // another function.
5077 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00005078 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00005079 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005080 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5081 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5082 if ((yyvsp[(8) - (9)].StrVal)) {
5083 Fn->setSection((yyvsp[(8) - (9)].StrVal));
5084 free((yyvsp[(8) - (9)].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00005085 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086
5087 // Add all of the arguments we parsed to the function...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005088 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00005089 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005090 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00005091 "Not a varargs marker!");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005092 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5093 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00005094 }
5095 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00005096 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00005097 unsigned Idx = 1;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005098 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5099 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00005100 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00005101 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005102 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00005104 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005105 }
Reid Spencera132e042006-12-03 05:46:11 +00005106
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005107 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00005108 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005109 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005110;}
5111 break;
5112
5113 case 222:
5114#line 2327 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5115 {
5116 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005117
5118 // Make sure that we keep track of the linkage type even if there was a
5119 // previous "declare".
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005120 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5121 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5122;}
5123 break;
5124
5125 case 225:
5126#line 2338 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5127 {
5128 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005129 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005130;}
5131 break;
5132
5133 case 226:
5134#line 2343 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5135 {
5136 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5137 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5138 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005139 CurFun.FunctionDone();
5140 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005141 ;}
5142 break;
5143
5144 case 227:
5145#line 2355 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5146 {
5147 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00005148 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005149 ;}
5150 break;
5151
5152 case 228:
5153#line 2359 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5154 {
5155 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005156 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005157 ;}
5158 break;
5159
5160 case 229:
5161#line 2364 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5162 { // A reference to a direct constant
5163 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005164 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005165 ;}
5166 break;
5167
5168 case 230:
5169#line 2368 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5170 {
5171 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005172 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005173 ;}
5174 break;
5175
5176 case 231:
5177#line 2372 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5178 { // Perhaps it's an FP constant?
5179 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005180 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005181 ;}
5182 break;
5183
5184 case 232:
5185#line 2376 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5186 {
5187 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005188 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005189 ;}
5190 break;
5191
5192 case 233:
5193#line 2380 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5194 {
5195 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005196 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005197 ;}
5198 break;
5199
5200 case 234:
5201#line 2384 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5202 {
5203 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005204 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005205 ;}
5206 break;
5207
5208 case 235:
5209#line 2388 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5210 {
5211 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005212 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005213 ;}
5214 break;
5215
5216 case 236:
5217#line 2392 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5218 { // A vector zero constant.
5219 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00005220 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005221 ;}
5222 break;
5223
5224 case 237:
5225#line 2396 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5226 { // Nonempty unsized packed vector
5227 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5228 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005229
Reid Spencer9d6565a2007-02-15 02:26:10 +00005230 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005231 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005232 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005233 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005234 ETy,
5235 NumElements)
5236 )
5237 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005238
5239 // Verify all elements are correct type!
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005240 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5241 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005242 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005243 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005244 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005245 }
5246
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005247 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5248 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005249 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005250 ;}
5251 break;
5252
5253 case 238:
5254#line 2421 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5255 {
5256 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005257 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005258 ;}
5259 break;
5260
5261 case 239:
5262#line 2425 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5263 {
5264 char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
5265 std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
5266 End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
5267 std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
5268 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
5269 free((yyvsp[(3) - (5)].StrVal));
5270 free((yyvsp[(5) - (5)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005271 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005272 ;}
5273 break;
5274
5275 case 240:
5276#line 2439 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5277 { // Is it an integer reference...?
5278 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005279 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005280 ;}
5281 break;
5282
5283 case 241:
5284#line 2443 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5285 {
5286 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005287 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005288 ;}
5289 break;
5290
5291 case 242:
5292#line 2447 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5293 { // Is it a named reference...?
5294 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005295 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005296 ;}
5297 break;
5298
5299 case 243:
5300#line 2451 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5301 { // Is it a named reference...?
5302 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[(1) - (1)].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005303 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005304 ;}
5305 break;
5306
5307 case 246:
5308#line 2463 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5309 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005310 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005311 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5312 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5313 delete (yyvsp[(1) - (2)].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005314 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005315 ;}
5316 break;
5317
5318 case 247:
5319#line 2472 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5320 {
5321 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005322 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005323 ;}
5324 break;
5325
5326 case 248:
5327#line 2476 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5328 { // Do not allow functions with 0 basic blocks
5329 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005330 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005331 ;}
5332 break;
5333
5334 case 249:
5335#line 2485 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5336 {
5337 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005338 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005339 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5340 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5341 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005342 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005343 ;}
5344 break;
5345
5346 case 250:
5347#line 2494 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5348 {
5349 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005350 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5351 if (CI2->getParent() == 0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005352 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5353 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5354 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005355 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005356 ;}
5357 break;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005358
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005359 case 251:
5360#line 2503 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5361 { // Empty space between instruction lists
5362 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
5363 CHECK_FOR_ERROR
5364 ;}
5365 break;
5366
5367 case 252:
5368#line 2507 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5369 { // Labelled (named) basic block
5370 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[(1) - (1)].StrVal)));
5371 CHECK_FOR_ERROR
5372 ;}
5373 break;
5374
5375 case 253:
5376#line 2512 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5377 { // Return with a result...
5378 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5379 CHECK_FOR_ERROR
5380 ;}
5381 break;
5382
5383 case 254:
5384#line 2516 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5385 { // Return with no result...
5386 (yyval.TermInstVal) = new ReturnInst();
5387 CHECK_FOR_ERROR
5388 ;}
5389 break;
5390
5391 case 255:
5392#line 2520 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5393 { // Unconditional Branch...
5394 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5395 CHECK_FOR_ERROR
5396 (yyval.TermInstVal) = new BranchInst(tmpBB);
5397 ;}
5398 break;
5399
5400 case 256:
5401#line 2525 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5402 {
5403 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5404 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5405 CHECK_FOR_ERROR
5406 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5407 CHECK_FOR_ERROR
5408 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5409 CHECK_FOR_ERROR
5410 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5411 ;}
5412 break;
5413
5414 case 257:
5415#line 2535 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5416 {
5417 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5418 CHECK_FOR_ERROR
5419 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5420 CHECK_FOR_ERROR
5421 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5422 (yyval.TermInstVal) = S;
5423
5424 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5425 E = (yyvsp[(8) - (9)].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005426 for (; I != E; ++I) {
5427 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5428 S->addCase(CI, I->second);
5429 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005430 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005431 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005432 delete (yyvsp[(8) - (9)].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005433 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005434 ;}
5435 break;
5436
5437 case 258:
5438#line 2554 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5439 {
5440 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005441 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005442 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005443 CHECK_FOR_ERROR
5444 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005445 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005446 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005447 ;}
5448 break;
5449
5450 case 259:
5451#line 2564 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5452 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005453
Reid Spencer14310612006-12-31 05:40:51 +00005454 // Handle the short syntax
5455 const PointerType *PFTy = 0;
5456 const FunctionType *Ty = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005457 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005458 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5459 // Pull out the types of all of the arguments...
5460 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005461 ParamAttrsVector Attrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005462 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
Christopher Lamb5c104242007-04-22 20:09:11 +00005463 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8;
5464 Attrs.push_back(PAWI);
5465 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005466 ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005467 unsigned index = 1;
5468 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005469 const Type *Ty = I->Val->getType();
5470 if (Ty == Type::VoidTy)
5471 GEN_ERROR("Short call syntax cannot be used with varargs");
5472 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005473 if (I->Attrs != ParamAttr::None) {
5474 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5475 Attrs.push_back(PAWI);
5476 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005477 }
5478
Christopher Lamb5c104242007-04-22 20:09:11 +00005479 ParamAttrsList *PAL = 0;
5480 if (!Attrs.empty())
5481 PAL = ParamAttrsList::get(Attrs);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005482 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005483 PFTy = PointerType::get(Ty);
5484 }
5485
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005486 delete (yyvsp[(3) - (14)].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005487
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005488 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005489 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005490 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005491 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005492 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005493 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005494
Reid Spencer14310612006-12-31 05:40:51 +00005495 // Check the arguments
5496 ValueList Args;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005497 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005498 // Make sure no arguments is a good thing!
5499 if (Ty->getNumParams() != 0)
5500 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005501 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005502 } else { // Has arguments?
5503 // Loop through FunctionType's arguments and ensure they are specified
5504 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005505 FunctionType::param_iterator I = Ty->param_begin();
5506 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005507 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005508
Reid Spencer14310612006-12-31 05:40:51 +00005509 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5510 if (ArgI->Val->getType() != *I)
5511 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005512 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005513 Args.push_back(ArgI->Val);
5514 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005515
Reid Spencer14310612006-12-31 05:40:51 +00005516 if (Ty->isVarArg()) {
5517 if (I == E)
5518 for (; ArgI != ArgE; ++ArgI)
5519 Args.push_back(ArgI->Val); // push the remaining varargs
5520 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005521 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005522 }
Reid Spencer14310612006-12-31 05:40:51 +00005523
5524 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005525 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005526 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5527 (yyval.TermInstVal) = II;
5528 delete (yyvsp[(6) - (14)].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005529 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005530 ;}
5531 break;
5532
5533 case 260:
5534#line 2643 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5535 {
5536 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005537 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005538 ;}
5539 break;
5540
5541 case 261:
5542#line 2647 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5543 {
5544 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005545 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005546 ;}
5547 break;
5548
5549 case 262:
5550#line 2654 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5551 {
5552 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5553 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005554 CHECK_FOR_ERROR
5555 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005556 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005557
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005558 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005559 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005560 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5561 ;}
5562 break;
5563
5564 case 263:
5565#line 2665 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5566 {
5567 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5568 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005569 CHECK_FOR_ERROR
5570
5571 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005572 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005573
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005574 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005575 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005576 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5577 ;}
5578 break;
5579
5580 case 264:
5581#line 2678 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5582 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005583 // Is this definition named?? if so, assign the name...
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005584 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005585 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005586 InsertValue((yyvsp[(2) - (2)].InstVal));
5587 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005588 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005589 ;}
5590 break;
5591
5592 case 265:
5593#line 2688 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5594 { // Used for PHI nodes
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005595 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005596 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5597 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5598 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005599 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005600 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005601 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005602 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5603 delete (yyvsp[(1) - (6)].TypeVal);
5604 ;}
5605 break;
5606
5607 case 266:
5608#line 2699 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5609 {
5610 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5611 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005612 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005613 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005614 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005615 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5616 ;}
5617 break;
5618
5619 case 267:
5620#line 2709 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5621 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005622 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005623 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005624 // Used for call and invoke instructions
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005625 (yyval.ValueRefList) = new ValueRefList();
5626 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5627 (yyval.ValueRefList)->push_back(E);
5628 delete (yyvsp[(1) - (3)].TypeVal);
5629 ;}
5630 break;
5631
5632 case 268:
5633#line 2718 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5634 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005635 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005636 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5637 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5638 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5639 (yyval.ValueRefList)->push_back(E);
5640 delete (yyvsp[(3) - (5)].TypeVal);
Reid Spencer14310612006-12-31 05:40:51 +00005641 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005642 ;}
5643 break;
5644
5645 case 269:
5646#line 2727 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5647 { (yyval.ValueRefList) = new ValueRefList(); ;}
5648 break;
5649
5650 case 270:
5651#line 2730 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5652 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5653 break;
5654
5655 case 271:
5656#line 2731 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5657 {
5658 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5659 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005660 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005661 ;}
5662 break;
5663
5664 case 272:
5665#line 2738 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5666 {
5667 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005668 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005669 ;}
5670 break;
5671
5672 case 273:
5673#line 2742 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5674 {
5675 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005676 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005677 ;}
5678 break;
5679
5680 case 274:
5681#line 2747 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5682 {
Reid Spencer14310612006-12-31 05:40:51 +00005683 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005684 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5685 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5686 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005687 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005688 "Arithmetic operator requires integer, FP, or packed operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005689 if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5690 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5691 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5692 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005693 GEN_ERROR("Remainder not supported on vector types");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005694 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005695 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005696 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005697 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005698 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5699 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005700 GEN_ERROR("binary operator returned null");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005701 delete (yyvsp[(2) - (5)].TypeVal);
5702 ;}
5703 break;
5704
5705 case 275:
5706#line 2768 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5707 {
Reid Spencer14310612006-12-31 05:40:51 +00005708 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005709 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5710 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5711 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5712 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005713 GEN_ERROR("Logical operator requires integral operands");
5714 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005715 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005716 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005717 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005718 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005719 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5720 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005721 GEN_ERROR("binary operator returned null");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005722 delete (yyvsp[(2) - (5)].TypeVal);
5723 ;}
5724 break;
5725
5726 case 276:
5727#line 2785 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5728 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005729 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005730 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5731 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005732 GEN_ERROR("Vector types not supported by icmp instruction");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005733 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005734 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005735 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005736 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005737 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5738 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005739 GEN_ERROR("icmp operator returned null");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005740 delete (yyvsp[(3) - (6)].TypeVal);
5741 ;}
5742 break;
5743
5744 case 277:
5745#line 2799 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5746 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005747 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005748 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5749 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005750 GEN_ERROR("Vector types not supported by fcmp instruction");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005751 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005752 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005753 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005754 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005755 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5756 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005757 GEN_ERROR("fcmp operator returned null");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005758 delete (yyvsp[(3) - (6)].TypeVal);
5759 ;}
5760 break;
5761
5762 case 278:
5763#line 2813 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5764 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005765 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005766 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5767 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5768 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5769 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005770 GEN_ERROR("invalid cast opcode for cast from '" +
5771 Val->getType()->getDescription() + "' to '" +
5772 DestTy->getDescription() + "'");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005773 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5774 delete (yyvsp[(4) - (4)].TypeVal);
5775 ;}
5776 break;
5777
5778 case 279:
5779#line 2825 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5780 {
5781 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005782 GEN_ERROR("select condition must be boolean");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005783 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005784 GEN_ERROR("select value types should match");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005785 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005786 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005787 ;}
5788 break;
5789
5790 case 280:
5791#line 2833 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5792 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005793 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005794 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5795 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5796 delete (yyvsp[(4) - (4)].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005797 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005798 ;}
5799 break;
5800
5801 case 281:
5802#line 2840 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5803 {
5804 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005805 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005806 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005807 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005808 ;}
5809 break;
5810
5811 case 282:
5812#line 2846 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5813 {
5814 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005815 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005816 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005817 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005818 ;}
5819 break;
5820
5821 case 283:
5822#line 2852 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5823 {
5824 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005825 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005826 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005827 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005828 ;}
5829 break;
5830
5831 case 284:
5832#line 2858 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5833 {
5834 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005835 if (!Ty->isFirstClassType())
5836 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005837 (yyval.InstVal) = new PHINode(Ty);
5838 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5839 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5840 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005841 GEN_ERROR("All elements of a PHI node must be of the same type");
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005842 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5843 (yyvsp[(2) - (2)].PHIList)->pop_front();
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005844 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005845 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005846 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005847 ;}
5848 break;
5849
5850 case 285:
5851#line 2874 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5852 {
Reid Spencer14310612006-12-31 05:40:51 +00005853
5854 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005855 const PointerType *PFTy = 0;
5856 const FunctionType *Ty = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005857 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005858 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5859 // Pull out the types of all of the arguments...
5860 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005861 ParamAttrsVector Attrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005862 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
5863 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005864 Attrs.push_back(PAWI);
5865 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005866 unsigned index = 1;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005867 ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005868 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005869 const Type *Ty = I->Val->getType();
5870 if (Ty == Type::VoidTy)
5871 GEN_ERROR("Short call syntax cannot be used with varargs");
5872 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005873 if (I->Attrs != ParamAttr::None) {
5874 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5875 Attrs.push_back(PAWI);
5876 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005877 }
5878
Christopher Lamb5c104242007-04-22 20:09:11 +00005879 ParamAttrsList *PAL = 0;
5880 if (!Attrs.empty())
5881 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005882
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005883 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005884 PFTy = PointerType::get(Ty);
5885 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005886
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005887 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005888 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005889
Reid Spencer7780acb2007-04-16 06:56:07 +00005890 // Check for call to invalid intrinsic to avoid crashing later.
5891 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005892 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005893 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5894 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005895 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5896 theF->getName() + "'");
5897 }
5898
Reid Spencer14310612006-12-31 05:40:51 +00005899 // Check the arguments
5900 ValueList Args;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005901 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005902 // Make sure no arguments is a good thing!
5903 if (Ty->getNumParams() != 0)
5904 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005905 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005906 } else { // Has arguments?
5907 // Loop through FunctionType's arguments and ensure they are specified
5908 // correctly!
5909 //
5910 FunctionType::param_iterator I = Ty->param_begin();
5911 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005912 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005913
Reid Spencer14310612006-12-31 05:40:51 +00005914 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5915 if (ArgI->Val->getType() != *I)
5916 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005917 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005918 Args.push_back(ArgI->Val);
5919 }
5920 if (Ty->isVarArg()) {
5921 if (I == E)
5922 for (; ArgI != ArgE; ++ArgI)
5923 Args.push_back(ArgI->Val); // push the remaining varargs
5924 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005925 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005926 }
Reid Spencer14310612006-12-31 05:40:51 +00005927 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005928 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005929 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
5930 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
5931 (yyval.InstVal) = CI;
5932 delete (yyvsp[(6) - (8)].ValueRefList);
5933 delete (yyvsp[(3) - (8)].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005934 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005935 ;}
5936 break;
5937
5938 case 286:
5939#line 2958 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5940 {
5941 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005942 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005943 ;}
5944 break;
5945
5946 case 287:
5947#line 2963 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5948 {
5949 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005950 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005951 ;}
5952 break;
5953
5954 case 288:
5955#line 2967 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5956 {
5957 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005958 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005959 ;}
5960 break;
5961
5962 case 289:
5963#line 2974 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5964 {
Reid Spencer14310612006-12-31 05:40:51 +00005965 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005966 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5967 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5968 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005969 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005970 ;}
5971 break;
5972
5973 case 290:
5974#line 2981 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5975 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005976 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005977 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
5978 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005979 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005980 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
5981 delete (yyvsp[(2) - (6)].TypeVal);
5982 ;}
5983 break;
5984
5985 case 291:
5986#line 2989 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5987 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005988 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005989 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
5990 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
5991 delete (yyvsp[(2) - (3)].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005992 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005993 ;}
5994 break;
5995
5996 case 292:
5997#line 2996 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5998 {
Reid Spencer14310612006-12-31 05:40:51 +00005999 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006000 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6001 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006002 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006003 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6004 delete (yyvsp[(2) - (6)].TypeVal);
6005 ;}
6006 break;
6007
6008 case 293:
6009#line 3004 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6010 {
6011 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006012 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006013 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6014 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006015 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006016 ;}
6017 break;
6018
6019 case 294:
6020#line 3012 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6021 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00006022 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006023 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6024 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006025 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006026 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6027 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006028 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006029 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6030 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006031 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006032 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6033 delete (yyvsp[(3) - (5)].TypeVal);
6034 ;}
6035 break;
6036
6037 case 295:
6038#line 3026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6039 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006040 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006041 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6042 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006043 if (!PT)
6044 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006045 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006046 const Type *ElTy = PT->getElementType();
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006047 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6048 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006049 "' into space of type '" + ElTy->getDescription() + "'");
6050
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006051 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006052 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006053 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6054 delete (yyvsp[(5) - (7)].TypeVal);
6055 ;}
6056 break;
6057
6058 case 296:
6059#line 3043 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6060 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00006061 if (!UpRefs.empty())
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006062 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6063 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00006064 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00006065
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006066 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 +00006067 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006068 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6069 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00006070 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006071 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size());
6072 delete (yyvsp[(2) - (4)].TypeVal);
6073 delete (yyvsp[(4) - (4)].ValueList);
6074 ;}
6075 break;
Reid Spencer7780acb2007-04-16 06:56:07 +00006076
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006077
6078/* Line 1267 of yacc.c. */
6079#line 6080 "llvmAsmParser.tab.c"
6080 default: break;
Christopher Lamb5c104242007-04-22 20:09:11 +00006081 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006082 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6083
6084 YYPOPSTACK (yylen);
6085 yylen = 0;
6086 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006087
6088 *++yyvsp = yyval;
6089
6090
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006091 /* Now `shift' the result of the reduction. Determine what state
6092 that goes to, based on the state we popped back to and the rule
6093 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00006094
6095 yyn = yyr1[yyn];
6096
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006097 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6098 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006099 yystate = yytable[yystate];
6100 else
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006101 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00006102
6103 goto yynewstate;
6104
6105
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006106/*------------------------------------.
6107| yyerrlab -- here on detecting error |
6108`------------------------------------*/
6109yyerrlab:
6110 /* If not already recovering from an error, report this error. */
6111 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006112 {
6113 ++yynerrs;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006114#if ! YYERROR_VERBOSE
6115 yyerror (YY_("syntax error"));
6116#else
6117 {
6118 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6119 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6120 {
6121 YYSIZE_T yyalloc = 2 * yysize;
6122 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6123 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6124 if (yymsg != yymsgbuf)
6125 YYSTACK_FREE (yymsg);
6126 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6127 if (yymsg)
6128 yymsg_alloc = yyalloc;
6129 else
6130 {
6131 yymsg = yymsgbuf;
6132 yymsg_alloc = sizeof yymsgbuf;
6133 }
6134 }
Christopher Lamb5c104242007-04-22 20:09:11 +00006135
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006136 if (0 < yysize && yysize <= yymsg_alloc)
6137 {
6138 (void) yysyntax_error (yymsg, yystate, yychar);
6139 yyerror (yymsg);
6140 }
6141 else
6142 {
6143 yyerror (YY_("syntax error"));
6144 if (yysize != 0)
6145 goto yyexhaustedlab;
6146 }
6147 }
6148#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00006149 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00006150
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006151
Reid Spencer41dff5e2007-01-26 08:05:27 +00006152
6153 if (yyerrstatus == 3)
6154 {
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006155 /* If just tried and failed to reuse look-ahead token after an
6156 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00006157
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006158 if (yychar <= YYEOF)
6159 {
6160 /* Return failure if at end of input. */
6161 if (yychar == YYEOF)
6162 YYABORT;
6163 }
6164 else
6165 {
6166 yydestruct ("Error: discarding",
6167 yytoken, &yylval);
6168 yychar = YYEMPTY;
6169 }
6170 }
6171
6172 /* Else will try to reuse look-ahead token after shifting the error
6173 token. */
6174 goto yyerrlab1;
6175
6176
6177/*---------------------------------------------------.
6178| yyerrorlab -- error raised explicitly by YYERROR. |
6179`---------------------------------------------------*/
6180yyerrorlab:
6181
6182 /* Pacify compilers like GCC when the user code never invokes
6183 YYERROR and the label yyerrorlab therefore never appears in user
6184 code. */
6185 if (/*CONSTCOND*/ 0)
6186 goto yyerrorlab;
6187
6188 /* Do not reclaim the symbols of the rule which action triggered
6189 this YYERROR. */
6190 YYPOPSTACK (yylen);
6191 yylen = 0;
6192 YY_STACK_PRINT (yyss, yyssp);
6193 yystate = *yyssp;
6194 goto yyerrlab1;
6195
6196
6197/*-------------------------------------------------------------.
6198| yyerrlab1 -- common code for both syntax error and YYERROR. |
6199`-------------------------------------------------------------*/
6200yyerrlab1:
6201 yyerrstatus = 3; /* Each real token shifted decrements this. */
6202
6203 for (;;)
6204 {
6205 yyn = yypact[yystate];
6206 if (yyn != YYPACT_NINF)
6207 {
6208 yyn += YYTERROR;
6209 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6210 {
6211 yyn = yytable[yyn];
6212 if (0 < yyn)
6213 break;
6214 }
6215 }
6216
6217 /* Pop the current state because it cannot handle the error token. */
6218 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006219 YYABORT;
6220
Reid Spencere4d87aa2006-12-23 06:05:41 +00006221
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006222 yydestruct ("Error: popping",
6223 yystos[yystate], yyvsp);
6224 YYPOPSTACK (1);
6225 yystate = *yyssp;
6226 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006227 }
6228
6229 if (yyn == YYFINAL)
6230 YYACCEPT;
6231
Reid Spencer68a24bd2005-08-27 18:50:39 +00006232 *++yyvsp = yylval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006233
6234
6235 /* Shift the error token. */
6236 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00006237
Reid Spencer68a24bd2005-08-27 18:50:39 +00006238 yystate = yyn;
6239 goto yynewstate;
6240
Chris Lattner6cdc6822007-04-26 05:31:05 +00006241
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006242/*-------------------------------------.
6243| yyacceptlab -- YYACCEPT comes here. |
6244`-------------------------------------*/
6245yyacceptlab:
6246 yyresult = 0;
6247 goto yyreturn;
6248
6249/*-----------------------------------.
6250| yyabortlab -- YYABORT comes here. |
6251`-----------------------------------*/
6252yyabortlab:
6253 yyresult = 1;
6254 goto yyreturn;
6255
6256#ifndef yyoverflow
6257/*-------------------------------------------------.
6258| yyexhaustedlab -- memory exhaustion comes here. |
6259`-------------------------------------------------*/
6260yyexhaustedlab:
6261 yyerror (YY_("memory exhausted"));
6262 yyresult = 2;
6263 /* Fall through. */
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00006264#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006265
6266yyreturn:
6267 if (yychar != YYEOF && yychar != YYEMPTY)
6268 yydestruct ("Cleanup: discarding lookahead",
6269 yytoken, &yylval);
6270 /* Do not reclaim the symbols of the rule which action triggered
6271 this YYABORT or YYACCEPT. */
6272 YYPOPSTACK (yylen);
6273 YY_STACK_PRINT (yyss, yyssp);
6274 while (yyssp != yyss)
6275 {
6276 yydestruct ("Cleanup: popping",
6277 yystos[*yyssp], yyvsp);
6278 YYPOPSTACK (1);
Chris Lattner6cdc6822007-04-26 05:31:05 +00006279 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006280#ifndef yyoverflow
6281 if (yyss != yyssa)
6282 YYSTACK_FREE (yyss);
6283#endif
6284#if YYERROR_VERBOSE
6285 if (yymsg != yymsgbuf)
6286 YYSTACK_FREE (yymsg);
6287#endif
6288 /* Make sure YYID is used. */
6289 return YYID (yyresult);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006290}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006291
6292
6293#line 3060 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006294
6295
Reid Spencer14310612006-12-31 05:40:51 +00006296// common code from the two 'RunVMAsmParser' functions
6297static Module* RunParser(Module * M) {
6298
6299 llvmAsmlineno = 1; // Reset the current line number...
6300 CurModule.CurrentModule = M;
6301#if YYDEBUG
6302 yydebug = Debug;
6303#endif
6304
6305 // Check to make sure the parser succeeded
6306 if (yyparse()) {
6307 if (ParserResult)
6308 delete ParserResult;
6309 return 0;
6310 }
6311
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006312 // Emit an error if there are any unresolved types left.
6313 if (!CurModule.LateResolveTypes.empty()) {
6314 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6315 if (DID.Type == ValID::LocalName) {
6316 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6317 } else {
6318 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6319 }
6320 if (ParserResult)
6321 delete ParserResult;
6322 return 0;
6323 }
6324
6325 // Emit an error if there are any unresolved values left.
6326 if (!CurModule.LateResolveValues.empty()) {
6327 Value *V = CurModule.LateResolveValues.back();
6328 std::map<Value*, std::pair<ValID, int> >::iterator I =
6329 CurModule.PlaceHolderInfo.find(V);
6330
6331 if (I != CurModule.PlaceHolderInfo.end()) {
6332 ValID &DID = I->second.first;
6333 if (DID.Type == ValID::LocalName) {
6334 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6335 } else {
6336 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6337 }
6338 if (ParserResult)
6339 delete ParserResult;
6340 return 0;
6341 }
6342 }
6343
Reid Spencer14310612006-12-31 05:40:51 +00006344 // Check to make sure that parsing produced a result
6345 if (!ParserResult)
6346 return 0;
6347
6348 // Reset ParserResult variable while saving its value for the result.
6349 Module *Result = ParserResult;
6350 ParserResult = 0;
6351
6352 return Result;
6353}
6354
Reid Spencer61c83e02006-08-18 08:43:06 +00006355void llvm::GenerateError(const std::string &message, int LineNo) {
6356 if (LineNo == -1) LineNo = llvmAsmlineno;
6357 // TODO: column number in exception
6358 if (TheParseError)
6359 TheParseError->setError(CurFilename, message, LineNo);
6360 TriggerError = 1;
6361}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006362
6363int yyerror(const char *ErrorMsg) {
6364 std::string where
6365 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6366 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006367 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6368 if (yychar != YYEMPTY && yychar != 0)
6369 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6370 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006371 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006372 return 0;
6373}
Anton Korobeynikov38e09802007-04-28 13:48:45 +00006374