blob: cce94e01f688ebe56fbdc5f7b47ff44aebdc929a [file] [log] [blame]
Reid Spencerb8f85052007-07-31 03:50:36 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencerb8f85052007-07-31 03:50:36 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005
Reid Spencerb8f85052007-07-31 03:50:36 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencerb8f85052007-07-31 03:50:36 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencerb8f85052007-07-31 03:50:36 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencerb8f85052007-07-31 03:50:36 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencerb8f85052007-07-31 03:50:36 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 ESAPINTVAL = 260,
70 EUAPINTVAL = 261,
71 LOCALVAL_ID = 262,
72 GLOBALVAL_ID = 263,
73 FPVAL = 264,
74 VOID = 265,
75 INTTYPE = 266,
76 FLOAT = 267,
77 DOUBLE = 268,
78 LABEL = 269,
79 TYPE = 270,
80 LOCALVAR = 271,
81 GLOBALVAR = 272,
82 LABELSTR = 273,
83 STRINGCONSTANT = 274,
84 ATSTRINGCONSTANT = 275,
85 PCTSTRINGCONSTANT = 276,
86 ZEROINITIALIZER = 277,
87 TRUETOK = 278,
88 FALSETOK = 279,
89 BEGINTOK = 280,
90 ENDTOK = 281,
91 DECLARE = 282,
92 DEFINE = 283,
93 GLOBAL = 284,
94 CONSTANT = 285,
95 SECTION = 286,
96 ALIAS = 287,
97 VOLATILE = 288,
98 THREAD_LOCAL = 289,
99 TO = 290,
100 DOTDOTDOT = 291,
101 NULL_TOK = 292,
102 UNDEF = 293,
103 INTERNAL = 294,
104 LINKONCE = 295,
105 WEAK = 296,
106 APPENDING = 297,
107 DLLIMPORT = 298,
108 DLLEXPORT = 299,
109 EXTERN_WEAK = 300,
110 OPAQUE = 301,
111 EXTERNAL = 302,
112 TARGET = 303,
113 TRIPLE = 304,
114 ALIGN = 305,
115 DEPLIBS = 306,
116 CALL = 307,
117 TAIL = 308,
118 ASM_TOK = 309,
119 MODULE = 310,
120 SIDEEFFECT = 311,
121 CC_TOK = 312,
122 CCC_TOK = 313,
123 FASTCC_TOK = 314,
124 COLDCC_TOK = 315,
125 X86_STDCALLCC_TOK = 316,
126 X86_FASTCALLCC_TOK = 317,
127 DATALAYOUT = 318,
128 RET = 319,
129 BR = 320,
130 SWITCH = 321,
131 INVOKE = 322,
132 UNWIND = 323,
133 UNREACHABLE = 324,
134 ADD = 325,
135 SUB = 326,
136 MUL = 327,
137 UDIV = 328,
138 SDIV = 329,
139 FDIV = 330,
140 UREM = 331,
141 SREM = 332,
142 FREM = 333,
143 AND = 334,
144 OR = 335,
145 XOR = 336,
146 SHL = 337,
147 LSHR = 338,
148 ASHR = 339,
149 ICMP = 340,
150 FCMP = 341,
151 EQ = 342,
152 NE = 343,
153 SLT = 344,
154 SGT = 345,
155 SLE = 346,
156 SGE = 347,
157 ULT = 348,
158 UGT = 349,
159 ULE = 350,
160 UGE = 351,
161 OEQ = 352,
162 ONE = 353,
163 OLT = 354,
164 OGT = 355,
165 OLE = 356,
166 OGE = 357,
167 ORD = 358,
168 UNO = 359,
169 UEQ = 360,
170 UNE = 361,
171 MALLOC = 362,
172 ALLOCA = 363,
173 FREE = 364,
174 LOAD = 365,
175 STORE = 366,
176 GETELEMENTPTR = 367,
177 TRUNC = 368,
178 ZEXT = 369,
179 SEXT = 370,
180 FPTRUNC = 371,
181 FPEXT = 372,
182 BITCAST = 373,
183 UITOFP = 374,
184 SITOFP = 375,
185 FPTOUI = 376,
186 FPTOSI = 377,
187 INTTOPTR = 378,
188 PTRTOINT = 379,
189 PHI_TOK = 380,
190 SELECT = 381,
191 VAARG = 382,
192 EXTRACTELEMENT = 383,
193 INSERTELEMENT = 384,
194 SHUFFLEVECTOR = 385,
195 SIGNEXT = 386,
196 ZEROEXT = 387,
197 NORETURN = 388,
198 INREG = 389,
199 SRET = 390,
200 NOUNWIND = 391,
201 NOALIAS = 392,
202 BYVAL = 393,
203 NEST = 394,
204 DEFAULT = 395,
205 HIDDEN = 396,
206 PROTECTED = 397
207 };
208#endif
209/* Tokens. */
210#define ESINT64VAL 258
211#define EUINT64VAL 259
212#define ESAPINTVAL 260
213#define EUAPINTVAL 261
214#define LOCALVAL_ID 262
215#define GLOBALVAL_ID 263
216#define FPVAL 264
217#define VOID 265
218#define INTTYPE 266
219#define FLOAT 267
220#define DOUBLE 268
221#define LABEL 269
222#define TYPE 270
223#define LOCALVAR 271
224#define GLOBALVAR 272
225#define LABELSTR 273
226#define STRINGCONSTANT 274
227#define ATSTRINGCONSTANT 275
228#define PCTSTRINGCONSTANT 276
229#define ZEROINITIALIZER 277
230#define TRUETOK 278
231#define FALSETOK 279
232#define BEGINTOK 280
233#define ENDTOK 281
234#define DECLARE 282
235#define DEFINE 283
236#define GLOBAL 284
237#define CONSTANT 285
238#define SECTION 286
239#define ALIAS 287
240#define VOLATILE 288
241#define THREAD_LOCAL 289
242#define TO 290
243#define DOTDOTDOT 291
244#define NULL_TOK 292
245#define UNDEF 293
246#define INTERNAL 294
247#define LINKONCE 295
248#define WEAK 296
249#define APPENDING 297
250#define DLLIMPORT 298
251#define DLLEXPORT 299
252#define EXTERN_WEAK 300
253#define OPAQUE 301
254#define EXTERNAL 302
255#define TARGET 303
256#define TRIPLE 304
257#define ALIGN 305
258#define DEPLIBS 306
259#define CALL 307
260#define TAIL 308
261#define ASM_TOK 309
262#define MODULE 310
263#define SIDEEFFECT 311
264#define CC_TOK 312
265#define CCC_TOK 313
266#define FASTCC_TOK 314
267#define COLDCC_TOK 315
268#define X86_STDCALLCC_TOK 316
269#define X86_FASTCALLCC_TOK 317
270#define DATALAYOUT 318
271#define RET 319
272#define BR 320
273#define SWITCH 321
274#define INVOKE 322
275#define UNWIND 323
276#define UNREACHABLE 324
277#define ADD 325
278#define SUB 326
279#define MUL 327
280#define UDIV 328
281#define SDIV 329
282#define FDIV 330
283#define UREM 331
284#define SREM 332
285#define FREM 333
286#define AND 334
287#define OR 335
288#define XOR 336
289#define SHL 337
290#define LSHR 338
291#define ASHR 339
292#define ICMP 340
293#define FCMP 341
294#define EQ 342
295#define NE 343
296#define SLT 344
297#define SGT 345
298#define SLE 346
299#define SGE 347
300#define ULT 348
301#define UGT 349
302#define ULE 350
303#define UGE 351
304#define OEQ 352
305#define ONE 353
306#define OLT 354
307#define OGT 355
308#define OLE 356
309#define OGE 357
310#define ORD 358
311#define UNO 359
312#define UEQ 360
313#define UNE 361
314#define MALLOC 362
315#define ALLOCA 363
316#define FREE 364
317#define LOAD 365
318#define STORE 366
319#define GETELEMENTPTR 367
320#define TRUNC 368
321#define ZEXT 369
322#define SEXT 370
323#define FPTRUNC 371
324#define FPEXT 372
325#define BITCAST 373
326#define UITOFP 374
327#define SITOFP 375
328#define FPTOUI 376
329#define FPTOSI 377
330#define INTTOPTR 378
331#define PTRTOINT 379
332#define PHI_TOK 380
333#define SELECT 381
334#define VAARG 382
335#define EXTRACTELEMENT 383
336#define INSERTELEMENT 384
337#define SHUFFLEVECTOR 385
338#define SIGNEXT 386
339#define ZEROEXT 387
340#define NORETURN 388
341#define INREG 389
342#define SRET 390
343#define NOUNWIND 391
344#define NOALIAS 392
345#define BYVAL 393
346#define NEST 394
347#define DEFAULT 395
348#define HIDDEN 396
349#define PROTECTED 397
350
351
352
353
354/* Copy the first part of user declarations. */
355#line 14 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356
357#include "ParserInternals.h"
358#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000359#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360#include "llvm/Instructions.h"
361#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000362#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000363#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000364#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000365#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000367#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000368#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000371#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000372#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000373#ifndef NDEBUG
374#define YYDEBUG 1
375#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376
Reid Spencere4f47592006-08-18 17:32:55 +0000377// The following is a gross hack. In order to rid the libAsmParser library of
378// exceptions, we have to have a way of getting the yyparse function to go into
379// an error situation. So, whenever we want an error to occur, the GenerateError
380// function (see bottom of file) sets TriggerError. Then, at the end of each
381// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
382// (a goto) to put YACC in error state. Furthermore, several calls to
383// GenerateError are made from inside productions and they must simulate the
384// previous exception behavior by exiting the production immediately. We have
385// replaced these with the GEN_ERROR macro which calls GeneratError and then
386// immediately invokes YYERROR. This would be so much cleaner if it was a
387// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000388static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000389#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000390#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
391
Reid Spencer68a24bd2005-08-27 18:50:39 +0000392int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
393int yylex(); // declaration" of xxx warnings.
394int yyparse();
395
396namespace llvm {
397 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000398#if YYDEBUG
399static cl::opt<bool>
400Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
401 cl::Hidden, cl::init(false));
402#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403}
404using namespace llvm;
405
406static Module *ParserResult;
407
408// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
409// relating to upreferences in the input stream.
410//
411//#define DEBUG_UPREFS 1
412#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000413#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000414#else
415#define UR_OUT(X)
416#endif
417
418#define YYERROR_VERBOSE 1
419
Chris Lattnerb475c422005-11-12 18:22:38 +0000420static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421
422
423// This contains info used when building the body of a function. It is
424// destroyed when the function is completed.
425//
426typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000427
Reid Spencer68a24bd2005-08-27 18:50:39 +0000428static void
Reid Spencer93c40032007-03-19 18:40:50 +0000429ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000430
431static struct PerModuleInfo {
432 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000433 ValueList Values; // Module level numbered definitions
434 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000435 std::vector<PATypeHolder> Types;
436 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437
438 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000439 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000440 /// that we can resolve them later and print error messages as appropriate.
441 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
442
443 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
444 // references to global values. Global values may be referenced before they
445 // are defined, and if so, the temporary object that they represent is held
446 // here. This is used for forward references of GlobalValues.
447 //
448 typedef std::map<std::pair<const PointerType *,
449 ValID>, GlobalValue*> GlobalRefsType;
450 GlobalRefsType GlobalRefs;
451
452 void ModuleDone() {
453 // If we could not resolve some functions at function compilation time
454 // (calls to functions before they are defined), resolve them now... Types
455 // are resolved when the constant pool has been completely parsed.
456 //
457 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000458 if (TriggerError)
459 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460
461 // Check to make sure that all global value forward references have been
462 // resolved!
463 //
464 if (!GlobalRefs.empty()) {
465 std::string UndefinedReferences = "Unresolved global references exist:\n";
466
467 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
468 I != E; ++I) {
469 UndefinedReferences += " " + I->first.first->getDescription() + " " +
470 I->first.second.getName() + "\n";
471 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000472 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000473 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000474 }
475
476 Values.clear(); // Clear out function local definitions
477 Types.clear();
478 CurrentModule = 0;
479 }
480
Reid Spencer68a24bd2005-08-27 18:50:39 +0000481 // GetForwardRefForGlobal - Check to see if there is a forward reference
482 // for this global. If so, remove it from the GlobalRefs map and return it.
483 // If not, just return null.
484 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
485 // Check to see if there is a forward reference to this global variable...
486 // if there is, eliminate it and patch the reference to use the new def'n.
487 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
488 GlobalValue *Ret = 0;
489 if (I != GlobalRefs.end()) {
490 Ret = I->second;
491 GlobalRefs.erase(I);
492 }
493 return Ret;
494 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000495
496 bool TypeIsUnresolved(PATypeHolder* PATy) {
497 // If it isn't abstract, its resolved
498 const Type* Ty = PATy->get();
499 if (!Ty->isAbstract())
500 return false;
501 // Traverse the type looking for abstract types. If it isn't abstract then
502 // we don't need to traverse that leg of the type.
503 std::vector<const Type*> WorkList, SeenList;
504 WorkList.push_back(Ty);
505 while (!WorkList.empty()) {
506 const Type* Ty = WorkList.back();
507 SeenList.push_back(Ty);
508 WorkList.pop_back();
509 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
510 // Check to see if this is an unresolved type
511 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
512 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
513 for ( ; I != E; ++I) {
514 if (I->second.get() == OpTy)
515 return true;
516 }
517 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
518 const Type* TheTy = SeqTy->getElementType();
519 if (TheTy->isAbstract() && TheTy != Ty) {
520 std::vector<const Type*>::iterator I = SeenList.begin(),
521 E = SeenList.end();
522 for ( ; I != E; ++I)
523 if (*I == TheTy)
524 break;
525 if (I == E)
526 WorkList.push_back(TheTy);
527 }
528 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
529 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
530 const Type* TheTy = StrTy->getElementType(i);
531 if (TheTy->isAbstract() && TheTy != Ty) {
532 std::vector<const Type*>::iterator I = SeenList.begin(),
533 E = SeenList.end();
534 for ( ; I != E; ++I)
535 if (*I == TheTy)
536 break;
537 if (I == E)
538 WorkList.push_back(TheTy);
539 }
540 }
541 }
542 }
543 return false;
544 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000545} CurModule;
546
547static struct PerFunctionInfo {
548 Function *CurrentFunction; // Pointer to current function being created
549
Reid Spencer93c40032007-03-19 18:40:50 +0000550 ValueList Values; // Keep track of #'d definitions
551 unsigned NextValNum;
552 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000553 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000554 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000555 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000556
557 /// BBForwardRefs - When we see forward references to basic blocks, keep
558 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000559 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560
561 inline PerFunctionInfo() {
562 CurrentFunction = 0;
563 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000564 Linkage = GlobalValue::ExternalLinkage;
565 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566 }
567
568 inline void FunctionStart(Function *M) {
569 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000570 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000571 }
572
573 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000575 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000576 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000577 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000578 return;
579 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580
581 // Resolve all forward references now.
582 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
583
584 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000585 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586 CurrentFunction = 0;
587 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000588 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000589 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000590 }
591} CurFun; // Info for the current function...
592
593static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
594
595
596//===----------------------------------------------------------------------===//
597// Code to handle definitions of all the types
598//===----------------------------------------------------------------------===//
599
Reid Spencer93c40032007-03-19 18:40:50 +0000600static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
601 // Things that have names or are void typed don't get slot numbers
602 if (V->hasName() || (V->getType() == Type::VoidTy))
603 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604
Reid Spencer93c40032007-03-19 18:40:50 +0000605 // In the case of function values, we have to allow for the forward reference
606 // of basic blocks, which are included in the numbering. Consequently, we keep
607 // track of the next insertion location with NextValNum. When a BB gets
608 // inserted, it could change the size of the CurFun.Values vector.
609 if (&ValueTab == &CurFun.Values) {
610 if (ValueTab.size() <= CurFun.NextValNum)
611 ValueTab.resize(CurFun.NextValNum+1);
612 ValueTab[CurFun.NextValNum++] = V;
613 return;
614 }
615 // For all other lists, its okay to just tack it on the back of the vector.
616 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000617}
618
619static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
620 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000621 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000623 if (D.Num < CurModule.Types.size())
624 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000626 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000627 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628 D.destroy(); // Free old strdup'd memory...
629 return N;
630 }
631 break;
632 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000633 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000634 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635 }
636
637 // If we reached here, we referenced either a symbol that we don't know about
638 // or an id number that hasn't been read yet. We may be referencing something
639 // forward, so just create an entry to be resolved later and get to it...
640 //
641 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
642
643
644 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000645 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000646 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000647 return 0;
648 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000649 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000650 return 0;
651 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 }
653
Reid Spencer861d9d62006-11-28 07:29:44 +0000654 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000655 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000656 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657
Reid Spencer861d9d62006-11-28 07:29:44 +0000658 Type *Typ = OpaqueType::get();
659 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
660 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000661 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000662
Reid Spencer93c40032007-03-19 18:40:50 +0000663// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664// the provided ValID. If the value exists and has already been defined, return
665// it. Otherwise return null.
666//
Reid Spencer93c40032007-03-19 18:40:50 +0000667static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000668 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000669 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000671 return 0;
672 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673
674 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000675 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000676 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000677 if (D.Num >= CurFun.Values.size())
678 return 0;
679 Value *Result = CurFun.Values[D.Num];
680 if (Ty != Result->getType()) {
681 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
682 Result->getType()->getDescription() + "' does not match "
683 "expected type, '" + Ty->getDescription() + "'");
684 return 0;
685 }
686 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000687 }
688 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000689 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000690 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000691 Value *Result = CurModule.Values[D.Num];
692 if (Ty != Result->getType()) {
693 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
694 Result->getType()->getDescription() + "' does not match "
695 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000696 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000697 }
698 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000699 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000700
701 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000702 if (!inFunctionScope())
703 return 0;
704 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000705 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000706 if (N == 0)
707 return 0;
708 if (N->getType() != Ty)
709 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000710
711 D.destroy(); // Free old strdup'd memory...
712 return N;
713 }
714 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000715 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000716 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000717 if (N == 0)
718 return 0;
719 if (N->getType() != Ty)
720 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000721
722 D.destroy(); // Free old strdup'd memory...
723 return N;
724 }
725
726 // Check to make sure that "Ty" is an integral type, and that our
727 // value will fit into the specified type...
728 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000729 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000730 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000731 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000732 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000733 return 0;
734 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000735 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000736
737 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000738 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
739 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000740 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000741 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000743 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000744 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745 }
746 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000747 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000748 }
749
750 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000751 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000752 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000753 return 0;
754 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000755 return ConstantFP::get(Ty, D.ConstPoolFP);
756
757 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000758 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000759 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000760 return 0;
761 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000762 return ConstantPointerNull::get(cast<PointerType>(Ty));
763
764 case ValID::ConstUndefVal: // Is it an undef value?
765 return UndefValue::get(Ty);
766
Chris Lattner7aa61892005-12-21 17:53:23 +0000767 case ValID::ConstZeroVal: // Is it a zero value?
768 return Constant::getNullValue(Ty);
769
Reid Spencer68a24bd2005-08-27 18:50:39 +0000770 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000771 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000772 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000773 return 0;
774 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000775 return D.ConstantValue;
776
Chris Lattner0e9c3762006-01-25 22:27:16 +0000777 case ValID::InlineAsmVal: { // Inline asm expression
778 const PointerType *PTy = dyn_cast<PointerType>(Ty);
779 const FunctionType *FTy =
780 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000781 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000782 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000783 return 0;
784 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000785 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
786 D.IAD->HasSideEffects);
787 D.destroy(); // Free InlineAsmDescriptor.
788 return IA;
789 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000791 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792 return 0;
793 } // End of switch
794
Reid Spencera9720f52007-02-05 17:04:00 +0000795 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796 return 0;
797}
798
Reid Spencer93c40032007-03-19 18:40:50 +0000799// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000800// value is not already defined, it "improvises" by creating a placeholder var
801// that looks and acts just like the requested variable. When the value is
802// defined later, all uses of the placeholder variable are replaced with the
803// real thing.
804//
805static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000807 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000808 return 0;
809 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000810
811 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000812 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000813 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000815
Reid Spencer5b7e7532006-09-28 19:28:24 +0000816 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000817 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000818 return 0;
819 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000820
821 // If we reached here, we referenced either a symbol that we don't know about
822 // or an id number that hasn't been read yet. We may be referencing something
823 // forward, so just create an entry to be resolved later and get to it...
824 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000825 switch (ID.Type) {
826 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000827 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000828 const PointerType *PTy = dyn_cast<PointerType>(Ty);
829 if (!PTy) {
830 GenerateError("Invalid type for reference to global" );
831 return 0;
832 }
833 const Type* ElTy = PTy->getElementType();
834 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
835 V = new Function(FTy, GlobalValue::ExternalLinkage);
836 else
837 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
838 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000839 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000840 default:
841 V = new Argument(Ty);
842 }
843
Reid Spencer68a24bd2005-08-27 18:50:39 +0000844 // Remember where this forward reference came from. FIXME, shouldn't we try
845 // to recycle these things??
846 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
847 llvmAsmlineno)));
848
849 if (inFunctionScope())
850 InsertValue(V, CurFun.LateResolveValues);
851 else
852 InsertValue(V, CurModule.LateResolveValues);
853 return V;
854}
855
Reid Spencer93c40032007-03-19 18:40:50 +0000856/// defineBBVal - This is a definition of a new basic block with the specified
857/// identifier which must be the same as CurFun.NextValNum, if its numeric.
858static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000859 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000862
Reid Spencer93c40032007-03-19 18:40:50 +0000863 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000864
Reid Spencer93c40032007-03-19 18:40:50 +0000865 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
866 if (BBI != CurFun.BBForwardRefs.end()) {
867 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868 // The forward declaration could have been inserted anywhere in the
869 // function: insert it into the correct place now.
870 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
871 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000872
Reid Spencer66728ef2007-03-20 01:13:36 +0000873 // We're about to erase the entry, save the key so we can clean it up.
874 ValID Tmp = BBI->first;
875
Reid Spencer93c40032007-03-19 18:40:50 +0000876 // Erase the forward ref from the map as its no longer "forward"
877 CurFun.BBForwardRefs.erase(ID);
878
Reid Spencer66728ef2007-03-20 01:13:36 +0000879 // The key has been removed from the map but so we don't want to leave
880 // strdup'd memory around so destroy it too.
881 Tmp.destroy();
882
Reid Spencer93c40032007-03-19 18:40:50 +0000883 // If its a numbered definition, bump the number and set the BB value.
884 if (ID.Type == ValID::LocalID) {
885 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
886 InsertValue(BB);
887 }
888
889 ID.destroy();
890 return BB;
891 }
892
893 // We haven't seen this BB before and its first mention is a definition.
894 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000895 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000896 BB = new BasicBlock(Name, CurFun.CurrentFunction);
897 if (ID.Type == ValID::LocalID) {
898 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
899 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000900 }
Reid Spencer93c40032007-03-19 18:40:50 +0000901
902 ID.destroy(); // Free strdup'd memory
903 return BB;
904}
905
906/// getBBVal - get an existing BB value or create a forward reference for it.
907///
908static BasicBlock *getBBVal(const ValID &ID) {
909 assert(inFunctionScope() && "Can't get basic block at global scope!");
910
911 BasicBlock *BB = 0;
912
913 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
914 if (BBI != CurFun.BBForwardRefs.end()) {
915 BB = BBI->second;
916 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000917 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000918 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
919 if (N)
920 if (N->getType()->getTypeID() == Type::LabelTyID)
921 BB = cast<BasicBlock>(N);
922 else
923 GenerateError("Reference to label '" + Name + "' is actually of type '"+
924 N->getType()->getDescription() + "'");
925 } else if (ID.Type == ValID::LocalID) {
926 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
927 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
928 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
929 else
930 GenerateError("Reference to label '%" + utostr(ID.Num) +
931 "' is actually of type '"+
932 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
933 }
934 } else {
935 GenerateError("Illegal label reference " + ID.getName());
936 return 0;
937 }
938
939 // If its already been defined, return it now.
940 if (BB) {
941 ID.destroy(); // Free strdup'd memory.
942 return BB;
943 }
944
945 // Otherwise, this block has not been seen before, create it.
946 std::string Name;
947 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000948 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000949 BB = new BasicBlock(Name, CurFun.CurrentFunction);
950
951 // Insert it in the forward refs map.
952 CurFun.BBForwardRefs[ID] = BB;
953
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954 return BB;
955}
956
957
958//===----------------------------------------------------------------------===//
959// Code to handle forward references in instructions
960//===----------------------------------------------------------------------===//
961//
962// This code handles the late binding needed with statements that reference
963// values not defined yet... for example, a forward branch, or the PHI node for
964// a loop body.
965//
966// This keeps a table (CurFun.LateResolveValues) of all such forward references
967// and back patchs after we are done.
968//
969
970// ResolveDefinitions - If we could not resolve some defs at parsing
971// time (forward branches, phi functions for loops, etc...) resolve the
972// defs now...
973//
974static void
Reid Spencer93c40032007-03-19 18:40:50 +0000975ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000976 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000977 while (!LateResolvers.empty()) {
978 Value *V = LateResolvers.back();
979 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000980
Reid Spencer93c40032007-03-19 18:40:50 +0000981 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
982 CurModule.PlaceHolderInfo.find(V);
983 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000984
Reid Spencer93c40032007-03-19 18:40:50 +0000985 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986
Reid Spencer93c40032007-03-19 18:40:50 +0000987 Value *TheRealValue = getExistingVal(V->getType(), DID);
988 if (TriggerError)
989 return;
990 if (TheRealValue) {
991 V->replaceAllUsesWith(TheRealValue);
992 delete V;
993 CurModule.PlaceHolderInfo.erase(PHI);
994 } else if (FutureLateResolvers) {
995 // Functions have their unresolved items forwarded to the module late
996 // resolver table
997 InsertValue(V, *FutureLateResolvers);
998 } else {
999 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1000 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1001 "' of type '" + V->getType()->getDescription() + "'",
1002 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001003 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001004 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001005 GenerateError("Reference to an invalid definition: #" +
1006 itostr(DID.Num) + " of type '" +
1007 V->getType()->getDescription() + "'",
1008 PHI->second.second);
1009 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010 }
1011 }
1012 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001013 LateResolvers.clear();
1014}
1015
1016// ResolveTypeTo - A brand new type was just declared. This means that (if
1017// name is not null) things referencing Name can be resolved. Otherwise, things
1018// refering to the number can be resolved. Do this now.
1019//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001020static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001021 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001022 if (Name)
1023 D = ValID::createLocalName(*Name);
1024 else
1025 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026
Reid Spencer861d9d62006-11-28 07:29:44 +00001027 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001028 CurModule.LateResolveTypes.find(D);
1029 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001030 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001031 CurModule.LateResolveTypes.erase(I);
1032 }
1033}
1034
1035// setValueName - Set the specified value to the name given. The name may be
1036// null potentially, in which case this is a noop. The string passed in is
1037// assumed to be a malloc'd string buffer, and is free'd by this function.
1038//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001039static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001040 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001041 std::string Name(*NameStr); // Copy string
1042 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001043
Reid Spencer41dff5e2007-01-26 08:05:27 +00001044 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001045 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001046 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001048
Reid Spencera9720f52007-02-05 17:04:00 +00001049 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001050 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1051 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001052 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001053 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001054 return;
1055 }
1056
1057 // Set the name.
1058 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001059}
1060
1061/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1062/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001063static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001064ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001065 GlobalValue::LinkageTypes Linkage,
1066 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001067 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001068 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001069 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001070 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001071 return 0;
1072 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001073
1074 const PointerType *PTy = PointerType::get(Ty);
1075
1076 std::string Name;
1077 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001078 Name = *NameStr; // Copy string
1079 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001080 }
1081
1082 // See if this global value was forward referenced. If so, recycle the
1083 // object.
1084 ValID ID;
1085 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001086 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001088 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001089 }
1090
1091 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1092 // Move the global to the end of the list, from whereever it was
1093 // previously inserted.
1094 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1095 CurModule.CurrentModule->getGlobalList().remove(GV);
1096 CurModule.CurrentModule->getGlobalList().push_back(GV);
1097 GV->setInitializer(Initializer);
1098 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001099 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001100 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001101 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001102 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001103 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001104 }
1105
Reid Spenceref9b9a72007-02-05 20:47:22 +00001106 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001107 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001108 // if the global we're parsing has an initializer (is a definition) and
1109 // has external linkage.
1110 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1111 // If there is already a global with external linkage with this name
1112 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1113 // If we allow this GVar to get created, it will be renamed in the
1114 // symbol table because it conflicts with an existing GVar. We can't
1115 // allow redefinition of GVars whose linking indicates that their name
1116 // must stay the same. Issue the error.
1117 GenerateError("Redefinition of global variable named '" + Name +
1118 "' of type '" + Ty->getDescription() + "'");
1119 return 0;
1120 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001121 }
1122
1123 // Otherwise there is no existing GV to use, create one now.
1124 GlobalVariable *GV =
1125 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001126 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001127 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001128 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001129 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001130}
1131
1132// setTypeName - Set the specified type to the name given. The name may be
1133// null potentially, in which case this is a noop. The string passed in is
1134// assumed to be a malloc'd string buffer, and is freed by this function.
1135//
1136// This function returns true if the type has already been defined, but is
1137// allowed to be redefined in the specified context. If the name is a new name
1138// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001139static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001140 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141 if (NameStr == 0) return false;
1142
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001143 std::string Name(*NameStr); // Copy string
1144 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145
1146 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001147 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001148 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001149 return false;
1150 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001151
1152 // Set the type name, checking for conflicts as we do so.
1153 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1154
1155 if (AlreadyExists) { // Inserting a name that is already defined???
1156 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001157 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001158
1159 // There is only one case where this is allowed: when we are refining an
1160 // opaque type. In this case, Existing will be an opaque type.
1161 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1162 // We ARE replacing an opaque type!
1163 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1164 return true;
1165 }
1166
1167 // Otherwise, this is an attempt to redefine a type. That's okay if
1168 // the redefinition is identical to the original. This will be so if
1169 // Existing and T point to the same Type object. In this one case we
1170 // allow the equivalent redefinition.
1171 if (Existing == T) return true; // Yes, it's equal.
1172
1173 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001174 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001175 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001176 }
1177
1178 return false;
1179}
1180
1181//===----------------------------------------------------------------------===//
1182// Code for handling upreferences in type names...
1183//
1184
1185// TypeContains - Returns true if Ty directly contains E in it.
1186//
1187static bool TypeContains(const Type *Ty, const Type *E) {
1188 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1189 E) != Ty->subtype_end();
1190}
1191
1192namespace {
1193 struct UpRefRecord {
1194 // NestingLevel - The number of nesting levels that need to be popped before
1195 // this type is resolved.
1196 unsigned NestingLevel;
1197
1198 // LastContainedTy - This is the type at the current binding level for the
1199 // type. Every time we reduce the nesting level, this gets updated.
1200 const Type *LastContainedTy;
1201
1202 // UpRefTy - This is the actual opaque type that the upreference is
1203 // represented with.
1204 OpaqueType *UpRefTy;
1205
1206 UpRefRecord(unsigned NL, OpaqueType *URTy)
1207 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1208 };
1209}
1210
1211// UpRefs - A list of the outstanding upreferences that need to be resolved.
1212static std::vector<UpRefRecord> UpRefs;
1213
1214/// HandleUpRefs - Every time we finish a new layer of types, this function is
1215/// called. It loops through the UpRefs vector, which is a list of the
1216/// currently active types. For each type, if the up reference is contained in
1217/// the newly completed type, we decrement the level count. When the level
1218/// count reaches zero, the upreferenced type is the type that is passed in:
1219/// thus we can complete the cycle.
1220///
1221static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001222 // If Ty isn't abstract, or if there are no up-references in it, then there is
1223 // nothing to resolve here.
1224 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1225
Reid Spencer68a24bd2005-08-27 18:50:39 +00001226 PATypeHolder Ty(ty);
1227 UR_OUT("Type '" << Ty->getDescription() <<
1228 "' newly formed. Resolving upreferences.\n" <<
1229 UpRefs.size() << " upreferences active!\n");
1230
1231 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1232 // to zero), we resolve them all together before we resolve them to Ty. At
1233 // the end of the loop, if there is anything to resolve to Ty, it will be in
1234 // this variable.
1235 OpaqueType *TypeToResolve = 0;
1236
1237 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1238 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1239 << UpRefs[i].second->getDescription() << ") = "
1240 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1241 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1242 // Decrement level of upreference
1243 unsigned Level = --UpRefs[i].NestingLevel;
1244 UpRefs[i].LastContainedTy = Ty;
1245 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1246 if (Level == 0) { // Upreference should be resolved!
1247 if (!TypeToResolve) {
1248 TypeToResolve = UpRefs[i].UpRefTy;
1249 } else {
1250 UR_OUT(" * Resolving upreference for "
1251 << UpRefs[i].second->getDescription() << "\n";
1252 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1253 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1254 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1255 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1256 }
1257 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1258 --i; // Do not skip the next element...
1259 }
1260 }
1261 }
1262
1263 if (TypeToResolve) {
1264 UR_OUT(" * Resolving upreference for "
1265 << UpRefs[i].second->getDescription() << "\n";
1266 std::string OldName = TypeToResolve->getDescription());
1267 TypeToResolve->refineAbstractTypeTo(Ty);
1268 }
1269
1270 return Ty;
1271}
1272
Reid Spencer68a24bd2005-08-27 18:50:39 +00001273//===----------------------------------------------------------------------===//
1274// RunVMAsmParser - Define an interface to this parser
1275//===----------------------------------------------------------------------===//
1276//
Reid Spencer14310612006-12-31 05:40:51 +00001277static Module* RunParser(Module * M);
1278
Reid Spencer68a24bd2005-08-27 18:50:39 +00001279Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1280 set_scan_file(F);
1281
1282 CurFilename = Filename;
1283 return RunParser(new Module(CurFilename));
1284}
1285
1286Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1287 set_scan_string(AsmString);
1288
1289 CurFilename = "from_memory";
1290 if (M == NULL) {
1291 return RunParser(new Module (CurFilename));
1292 } else {
1293 return RunParser(M);
1294 }
1295}
1296
1297
Reid Spencerb8f85052007-07-31 03:50:36 +00001298
1299/* Enabling traces. */
1300#ifndef YYDEBUG
1301# define YYDEBUG 0
1302#endif
1303
1304/* Enabling verbose error messages. */
1305#ifdef YYERROR_VERBOSE
1306# undef YYERROR_VERBOSE
1307# define YYERROR_VERBOSE 1
1308#else
1309# define YYERROR_VERBOSE 0
1310#endif
1311
1312/* Enabling the token table. */
1313#ifndef YYTOKEN_TABLE
1314# define YYTOKEN_TABLE 0
1315#endif
1316
1317#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1318#line 957 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
1319typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001320 llvm::Module *ModuleVal;
1321 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001322 llvm::BasicBlock *BasicBlockVal;
1323 llvm::TerminatorInst *TermInstVal;
1324 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001325 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001326
Reid Spencera132e042006-12-03 05:46:11 +00001327 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001328 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001329 llvm::PATypeHolder *TypeVal;
1330 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001331 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001332 llvm::ArgListType *ArgList;
1333 llvm::TypeWithAttrs TypeWithAttrs;
1334 llvm::TypeWithAttrsList *TypeWithAttrsList;
1335 llvm::ValueRefList *ValueRefList;
1336
Reid Spencer68a24bd2005-08-27 18:50:39 +00001337 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001338 std::list<std::pair<llvm::Value*,
1339 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001340 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001341 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001342
1343 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001344 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001345 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001346 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001347 int64_t SInt64Val;
1348 uint64_t UInt64Val;
1349 int SIntVal;
1350 unsigned UIntVal;
1351 double FPVal;
1352 bool BoolVal;
1353
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001354 std::string *StrVal; // This memory must be deleted
1355 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001356
Reid Spencera132e042006-12-03 05:46:11 +00001357 llvm::Instruction::BinaryOps BinaryOpVal;
1358 llvm::Instruction::TermOps TermOpVal;
1359 llvm::Instruction::MemoryOps MemOpVal;
1360 llvm::Instruction::CastOps CastOpVal;
1361 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001362 llvm::ICmpInst::Predicate IPredicate;
1363 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001364} YYSTYPE;
Reid Spencerb8f85052007-07-31 03:50:36 +00001365/* Line 196 of yacc.c. */
1366#line 1367 "llvmAsmParser.tab.c"
1367# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1368# define YYSTYPE_IS_DECLARED 1
1369# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370#endif
1371
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001372
Reid Spencer68a24bd2005-08-27 18:50:39 +00001373
Reid Spencerb8f85052007-07-31 03:50:36 +00001374/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001375
1376
Reid Spencerb8f85052007-07-31 03:50:36 +00001377/* Line 219 of yacc.c. */
1378#line 1379 "llvmAsmParser.tab.c"
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001379
Reid Spencerb8f85052007-07-31 03:50:36 +00001380#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1381# define YYSIZE_T __SIZE_TYPE__
1382#endif
1383#if ! defined (YYSIZE_T) && defined (size_t)
1384# define YYSIZE_T size_t
1385#endif
1386#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1387# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1388# define YYSIZE_T size_t
1389#endif
1390#if ! defined (YYSIZE_T)
1391# define YYSIZE_T unsigned int
1392#endif
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001393
Reid Spencerb8f85052007-07-31 03:50:36 +00001394#ifndef YY_
1395# if YYENABLE_NLS
1396# if ENABLE_NLS
1397# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1398# define YY_(msgid) dgettext ("bison-runtime", msgid)
1399# endif
1400# endif
1401# ifndef YY_
1402# define YY_(msgid) msgid
1403# endif
1404#endif
1405
1406#if ! defined (yyoverflow) || YYERROR_VERBOSE
1407
1408/* The parser invokes alloca or malloc; define the necessary symbols. */
1409
1410# ifdef YYSTACK_USE_ALLOCA
1411# if YYSTACK_USE_ALLOCA
1412# ifdef __GNUC__
1413# define YYSTACK_ALLOC __builtin_alloca
1414# else
1415# define YYSTACK_ALLOC alloca
1416# if defined (__STDC__) || defined (__cplusplus)
1417# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1418# define YYINCLUDED_STDLIB_H
1419# endif
1420# endif
1421# endif
1422# endif
1423
1424# ifdef YYSTACK_ALLOC
1425 /* Pacify GCC's `empty if-body' warning. */
1426# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1427# ifndef YYSTACK_ALLOC_MAXIMUM
1428 /* The OS might guarantee only one guard page at the bottom of the stack,
1429 and a page size can be as small as 4096 bytes. So we cannot safely
1430 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1431 to allow for a few compiler-allocated temporary stack slots. */
1432# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1433# endif
1434# else
1435# define YYSTACK_ALLOC YYMALLOC
1436# define YYSTACK_FREE YYFREE
1437# ifndef YYSTACK_ALLOC_MAXIMUM
1438# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1439# endif
1440# ifdef __cplusplus
1441extern "C" {
1442# endif
1443# ifndef YYMALLOC
1444# define YYMALLOC malloc
1445# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1446 && (defined (__STDC__) || defined (__cplusplus)))
1447void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1448# endif
1449# endif
1450# ifndef YYFREE
1451# define YYFREE free
1452# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1453 && (defined (__STDC__) || defined (__cplusplus)))
1454void free (void *); /* INFRINGES ON USER NAME SPACE */
1455# endif
1456# endif
1457# ifdef __cplusplus
1458}
1459# endif
1460# endif
1461#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1462
1463
1464#if (! defined (yyoverflow) \
1465 && (! defined (__cplusplus) \
1466 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1467
1468/* A type that is properly aligned for any stack member. */
1469union yyalloc
1470{
1471 short int yyss;
1472 YYSTYPE yyvs;
1473 };
1474
1475/* The size of the maximum gap between one aligned stack and the next. */
1476# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1477
1478/* The size of an array large to enough to hold all stacks, each with
1479 N elements. */
1480# define YYSTACK_BYTES(N) \
1481 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1482 + YYSTACK_GAP_MAXIMUM)
1483
1484/* Copy COUNT objects from FROM to TO. The source and destination do
1485 not overlap. */
1486# ifndef YYCOPY
1487# if defined (__GNUC__) && 1 < __GNUC__
1488# define YYCOPY(To, From, Count) \
1489 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1490# else
1491# define YYCOPY(To, From, Count) \
1492 do \
1493 { \
1494 YYSIZE_T yyi; \
1495 for (yyi = 0; yyi < (Count); yyi++) \
1496 (To)[yyi] = (From)[yyi]; \
1497 } \
1498 while (0)
1499# endif
1500# endif
1501
1502/* Relocate STACK from its old location to the new one. The
1503 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1504 elements in the stack, and YYPTR gives the new location of the
1505 stack. Advance YYPTR to a properly aligned location for the next
1506 stack. */
1507# define YYSTACK_RELOCATE(Stack) \
1508 do \
1509 { \
1510 YYSIZE_T yynewbytes; \
1511 YYCOPY (&yyptr->Stack, Stack, yysize); \
1512 Stack = &yyptr->Stack; \
1513 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1514 yyptr += yynewbytes / sizeof (*yyptr); \
1515 } \
1516 while (0)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001517
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001518#endif
1519
Reid Spencerb8f85052007-07-31 03:50:36 +00001520#if defined (__STDC__) || defined (__cplusplus)
1521 typedef signed char yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001522#else
Reid Spencerb8f85052007-07-31 03:50:36 +00001523 typedef short int yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001524#endif
1525
Reid Spencerb8f85052007-07-31 03:50:36 +00001526/* YYFINAL -- State number of the termination state. */
1527#define YYFINAL 43
1528/* YYLAST -- Last index in YYTABLE. */
1529#define YYLAST 1553
1530
1531/* YYNTOKENS -- Number of terminals. */
1532#define YYNTOKENS 157
1533/* YYNNTS -- Number of nonterminals. */
1534#define YYNNTS 82
1535/* YYNRULES -- Number of rules. */
1536#define YYNRULES 304
1537/* YYNRULES -- Number of states. */
1538#define YYNSTATES 588
1539
1540/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1541#define YYUNDEFTOK 2
1542#define YYMAXUTOK 397
1543
1544#define YYTRANSLATE(YYX) \
1545 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1546
1547/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1548static const unsigned char yytranslate[] =
1549{
1550 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1554 147, 148, 145, 2, 144, 2, 2, 2, 2, 2,
1555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1556 152, 143, 153, 2, 2, 2, 2, 2, 2, 2,
1557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1559 2, 149, 146, 151, 2, 2, 2, 2, 2, 156,
1560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1562 150, 2, 2, 154, 2, 155, 2, 2, 2, 2,
1563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1574 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1575 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1576 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1577 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1578 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1579 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1580 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1581 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1582 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1583 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1584 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1585 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1586 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1587 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1588 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1589 135, 136, 137, 138, 139, 140, 141, 142
1590};
1591
1592#if YYDEBUG
1593/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1594 YYRHS. */
1595static const unsigned short int yyprhs[] =
1596{
1597 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1598 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1599 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1600 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1601 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1602 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1603 119, 121, 123, 124, 127, 128, 130, 132, 134, 135,
1604 138, 140, 142, 144, 146, 148, 150, 152, 154, 155,
1605 157, 159, 161, 162, 164, 166, 167, 169, 171, 173,
1606 175, 176, 178, 180, 181, 183, 185, 187, 189, 191,
1607 194, 196, 198, 200, 202, 204, 206, 208, 210, 212,
1608 213, 216, 218, 220, 222, 224, 225, 228, 229, 232,
1609 233, 237, 240, 241, 243, 244, 248, 250, 253, 255,
1610 257, 259, 261, 263, 265, 268, 270, 273, 279, 285,
1611 291, 297, 301, 304, 310, 315, 318, 320, 322, 324,
1612 328, 330, 334, 336, 337, 339, 343, 348, 352, 356,
1613 361, 366, 370, 377, 383, 386, 389, 392, 395, 398,
1614 401, 404, 407, 410, 413, 416, 419, 426, 432, 441,
1615 448, 455, 463, 471, 478, 487, 496, 500, 502, 504,
1616 506, 508, 509, 512, 519, 521, 522, 524, 527, 528,
1617 532, 533, 537, 541, 545, 549, 550, 558, 559, 568,
1618 569, 578, 584, 587, 591, 593, 597, 601, 605, 609,
1619 611, 612, 618, 622, 624, 628, 630, 631, 641, 643,
1620 645, 650, 652, 654, 657, 661, 662, 664, 666, 668,
1621 670, 672, 674, 676, 678, 680, 684, 686, 692, 694,
1622 696, 698, 700, 702, 704, 707, 710, 713, 717, 720,
1623 721, 723, 726, 729, 733, 743, 753, 762, 777, 779,
1624 781, 788, 794, 797, 804, 812, 816, 822, 823, 824,
1625 828, 831, 833, 839, 845, 852, 859, 864, 871, 876,
1626 881, 888, 895, 898, 907, 909, 911, 912, 916, 923,
1627 927, 934, 937, 943, 951
1628};
1629
1630/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1631static const short int yyrhs[] =
1632{
1633 201, 0, -1, 70, -1, 71, -1, 72, -1, 73,
1634 -1, 74, -1, 75, -1, 76, -1, 77, -1, 78,
1635 -1, 82, -1, 83, -1, 84, -1, 79, -1, 80,
1636 -1, 81, -1, 113, -1, 114, -1, 115, -1, 116,
1637 -1, 117, -1, 118, -1, 119, -1, 120, -1, 121,
1638 -1, 122, -1, 123, -1, 124, -1, 87, -1, 88,
1639 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
1640 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
1641 -1, 99, -1, 100, -1, 101, -1, 102, -1, 103,
1642 -1, 104, -1, 105, -1, 106, -1, 93, -1, 94,
1643 -1, 95, -1, 96, -1, 23, -1, 24, -1, 11,
1644 -1, 12, -1, 13, -1, 16, -1, 19, -1, 21,
1645 -1, 165, -1, -1, 165, 143, -1, -1, 17, -1,
1646 20, -1, 170, -1, -1, 168, 143, -1, 39, -1,
1647 41, -1, 40, -1, 42, -1, 44, -1, 43, -1,
1648 45, -1, 47, -1, -1, 140, -1, 141, -1, 142,
1649 -1, -1, 43, -1, 45, -1, -1, 39, -1, 40,
1650 -1, 41, -1, 44, -1, -1, 41, -1, 39, -1,
1651 -1, 58, -1, 59, -1, 60, -1, 61, -1, 62,
1652 -1, 57, 4, -1, 132, -1, 114, -1, 131, -1,
1653 115, -1, 134, -1, 135, -1, 137, -1, 138, -1,
1654 139, -1, -1, 179, 178, -1, 133, -1, 136, -1,
1655 132, -1, 131, -1, -1, 181, 180, -1, -1, 50,
1656 4, -1, -1, 144, 50, 4, -1, 31, 19, -1,
1657 -1, 184, -1, -1, 144, 187, 186, -1, 184, -1,
1658 50, 4, -1, 11, -1, 12, -1, 13, -1, 14,
1659 -1, 46, -1, 188, -1, 189, 145, -1, 223, -1,
1660 146, 4, -1, 189, 147, 193, 148, 181, -1, 10,
1661 147, 193, 148, 181, -1, 149, 4, 150, 189, 151,
1662 -1, 152, 4, 150, 189, 153, -1, 154, 194, 155,
1663 -1, 154, 155, -1, 152, 154, 194, 155, 153, -1,
1664 152, 154, 155, 153, -1, 189, 179, -1, 189, -1,
1665 10, -1, 190, -1, 192, 144, 190, -1, 192, -1,
1666 192, 144, 36, -1, 36, -1, -1, 189, -1, 194,
1667 144, 189, -1, 189, 149, 197, 151, -1, 189, 149,
1668 151, -1, 189, 156, 19, -1, 189, 152, 197, 153,
1669 -1, 189, 154, 197, 155, -1, 189, 154, 155, -1,
1670 189, 152, 154, 197, 155, 153, -1, 189, 152, 154,
1671 155, 153, -1, 189, 37, -1, 189, 38, -1, 189,
1672 223, -1, 189, 196, -1, 189, 22, -1, 163, 3,
1673 -1, 163, 5, -1, 163, 4, -1, 163, 6, -1,
1674 11, 23, -1, 11, 24, -1, 164, 9, -1, 160,
1675 147, 195, 35, 189, 148, -1, 112, 147, 195, 234,
1676 148, -1, 126, 147, 195, 144, 195, 144, 195, 148,
1677 -1, 158, 147, 195, 144, 195, 148, -1, 159, 147,
1678 195, 144, 195, 148, -1, 85, 161, 147, 195, 144,
1679 195, 148, -1, 86, 162, 147, 195, 144, 195, 148,
1680 -1, 128, 147, 195, 144, 195, 148, -1, 129, 147,
1681 195, 144, 195, 144, 195, 148, -1, 130, 147, 195,
1682 144, 195, 144, 195, 148, -1, 197, 144, 195, -1,
1683 195, -1, 29, -1, 30, -1, 34, -1, -1, 191,
1684 223, -1, 118, 147, 200, 35, 189, 148, -1, 202,
1685 -1, -1, 203, -1, 202, 203, -1, -1, 28, 204,
1686 219, -1, -1, 27, 205, 220, -1, 55, 54, 209,
1687 -1, 167, 15, 189, -1, 167, 15, 10, -1, -1,
1688 169, 173, 199, 198, 195, 206, 186, -1, -1, 169,
1689 171, 173, 199, 198, 195, 207, 186, -1, -1, 169,
1690 172, 173, 199, 198, 189, 208, 186, -1, 169, 173,
1691 32, 176, 200, -1, 48, 210, -1, 51, 143, 211,
1692 -1, 19, -1, 49, 143, 19, -1, 63, 143, 19,
1693 -1, 149, 212, 151, -1, 212, 144, 19, -1, 19,
1694 -1, -1, 213, 144, 189, 179, 166, -1, 189, 179,
1695 166, -1, 213, -1, 213, 144, 36, -1, 36, -1,
1696 -1, 177, 191, 168, 147, 214, 148, 181, 185, 182,
1697 -1, 25, -1, 154, -1, 175, 173, 215, 216, -1,
1698 26, -1, 155, -1, 226, 218, -1, 174, 173, 215,
1699 -1, -1, 56, -1, 3, -1, 4, -1, 9, -1,
1700 23, -1, 24, -1, 37, -1, 38, -1, 22, -1,
1701 152, 197, 153, -1, 196, -1, 54, 221, 19, 144,
1702 19, -1, 7, -1, 8, -1, 165, -1, 168, -1,
1703 223, -1, 222, -1, 189, 224, -1, 226, 227, -1,
1704 217, 227, -1, 228, 167, 229, -1, 228, 231, -1,
1705 -1, 18, -1, 64, 225, -1, 64, 10, -1, 65,
1706 14, 224, -1, 65, 11, 224, 144, 14, 224, 144,
1707 14, 224, -1, 66, 163, 224, 144, 14, 224, 149,
1708 230, 151, -1, 66, 163, 224, 144, 14, 224, 149,
1709 151, -1, 67, 177, 191, 224, 147, 233, 148, 181,
1710 35, 14, 224, 68, 14, 224, -1, 68, -1, 69,
1711 -1, 230, 163, 222, 144, 14, 224, -1, 163, 222,
1712 144, 14, 224, -1, 167, 236, -1, 189, 149, 224,
1713 144, 224, 151, -1, 232, 144, 149, 224, 144, 224,
1714 151, -1, 189, 224, 179, -1, 233, 144, 189, 224,
1715 179, -1, -1, -1, 234, 144, 225, -1, 53, 52,
1716 -1, 52, -1, 158, 189, 224, 144, 224, -1, 159,
1717 189, 224, 144, 224, -1, 85, 161, 189, 224, 144,
1718 224, -1, 86, 162, 189, 224, 144, 224, -1, 160,
1719 225, 35, 189, -1, 126, 225, 144, 225, 144, 225,
1720 -1, 127, 225, 144, 189, -1, 128, 225, 144, 225,
1721 -1, 129, 225, 144, 225, 144, 225, -1, 130, 225,
1722 144, 225, 144, 225, -1, 125, 232, -1, 235, 177,
1723 191, 224, 147, 233, 148, 181, -1, 238, -1, 33,
1724 -1, -1, 107, 189, 183, -1, 107, 189, 144, 11,
1725 224, 183, -1, 108, 189, 183, -1, 108, 189, 144,
1726 11, 224, 183, -1, 109, 225, -1, 237, 110, 189,
1727 224, 183, -1, 237, 111, 225, 144, 189, 224, 183,
1728 -1, 112, 189, 224, 234, -1
1729};
1730
1731/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1732static const unsigned short int yyrline[] =
1733{
1734 0, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116,
1735 1116, 1117, 1117, 1117, 1117, 1117, 1117, 1118, 1118, 1118,
1736 1118, 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, 1122,
1737 1122, 1123, 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1130,
1738 1130, 1131, 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135,
1739 1135, 1136, 1136, 1137, 1138, 1143, 1144, 1144, 1146, 1146,
1740 1146, 1147, 1147, 1151, 1155, 1160, 1160, 1162, 1163, 1168,
1741 1174, 1175, 1176, 1177, 1178, 1182, 1183, 1184, 1188, 1189,
1742 1190, 1191, 1195, 1196, 1197, 1201, 1202, 1203, 1204, 1205,
1743 1209, 1210, 1211, 1214, 1215, 1216, 1217, 1218, 1219, 1220,
1744 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1238,
1745 1239, 1244, 1245, 1246, 1247, 1250, 1251, 1258, 1259, 1265,
1746 1266, 1274, 1282, 1283, 1288, 1289, 1290, 1295, 1308, 1308,
1747 1308, 1308, 1311, 1315, 1319, 1326, 1331, 1339, 1369, 1400,
1748 1405, 1417, 1427, 1431, 1441, 1448, 1455, 1462, 1467, 1472,
1749 1479, 1480, 1487, 1494, 1502, 1508, 1520, 1548, 1564, 1591,
1750 1619, 1645, 1665, 1691, 1711, 1723, 1730, 1796, 1806, 1816,
1751 1822, 1832, 1838, 1848, 1853, 1858, 1866, 1878, 1900, 1908,
1752 1914, 1925, 1930, 1935, 1941, 1947, 1956, 1960, 1968, 1968,
1753 1971, 1971, 1974, 1985, 2006, 2011, 2019, 2020, 2024, 2024,
1754 2028, 2028, 2031, 2034, 2058, 2069, 2069, 2080, 2079, 2089,
1755 2088, 2099, 2118, 2121, 2127, 2137, 2141, 2146, 2148, 2153,
1756 2158, 2167, 2177, 2188, 2192, 2201, 2210, 2215, 2336, 2336,
1757 2338, 2347, 2347, 2349, 2354, 2366, 2370, 2375, 2379, 2383,
1758 2387, 2391, 2395, 2399, 2403, 2407, 2432, 2436, 2446, 2450,
1759 2454, 2459, 2466, 2466, 2472, 2481, 2485, 2494, 2503, 2512,
1760 2516, 2523, 2527, 2531, 2536, 2546, 2565, 2574, 2654, 2658,
1761 2665, 2676, 2689, 2699, 2710, 2720, 2729, 2738, 2741, 2742,
1762 2749, 2753, 2758, 2779, 2796, 2810, 2824, 2836, 2844, 2851,
1763 2857, 2863, 2869, 2884, 2969, 2974, 2978, 2985, 2992, 3000,
1764 3007, 3015, 3023, 3037, 3054
1765};
1766#endif
1767
1768#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1769/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1770 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1771static const char *const yytname[] =
1772{
1773 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1774 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1775 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1776 "STRINGCONSTANT", "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT",
1777 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1778 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "ALIAS",
1779 "VOLATILE", "THREAD_LOCAL", "TO", "DOTDOTDOT", "NULL_TOK", "UNDEF",
1780 "INTERNAL", "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT",
1781 "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET", "TRIPLE", "ALIGN",
1782 "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK",
1783 "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK",
1784 "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1785 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1786 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR",
1787 "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT",
1788 "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO",
1789 "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1790 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1791 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1792 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1793 "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
1794 "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "DEFAULT", "HIDDEN", "PROTECTED",
1795 "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'",
1796 "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps",
1797 "CastOps", "IPredicates", "FPredicates", "IntType", "FPType",
1798 "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1799 "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1800 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1801 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1802 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1803 "SectionString", "OptSection", "GlobalVarAttributes",
1804 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1805 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1806 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1807 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1808 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1809 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1810 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1811 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1812 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1813 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1814 "OptVolatile", "MemoryInst", 0
1815};
1816#endif
1817
1818# ifdef YYPRINT
1819/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1820 token YYLEX-NUM. */
1821static const unsigned short int yytoknum[] =
1822{
1823 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1824 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1825 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1826 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1827 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1828 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1829 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1830 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1831 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1832 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1833 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1834 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1835 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1836 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1837 395, 396, 397, 61, 44, 42, 92, 40, 41, 91,
1838 120, 93, 60, 62, 123, 125, 99
1839};
1840# endif
1841
1842/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1843static const unsigned char yyr1[] =
1844{
1845 0, 157, 158, 158, 158, 158, 158, 158, 158, 158,
1846 158, 159, 159, 159, 159, 159, 159, 160, 160, 160,
1847 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1848 161, 161, 161, 161, 161, 161, 161, 161, 161, 162,
1849 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
1850 162, 162, 162, 162, 162, 163, 164, 164, 165, 165,
1851 165, 166, 166, 167, 167, 168, 168, 169, 169, 170,
1852 171, 171, 171, 171, 171, 172, 172, 172, 173, 173,
1853 173, 173, 174, 174, 174, 175, 175, 175, 175, 175,
1854 176, 176, 176, 177, 177, 177, 177, 177, 177, 177,
1855 178, 178, 178, 178, 178, 178, 178, 178, 178, 179,
1856 179, 180, 180, 180, 180, 181, 181, 182, 182, 183,
1857 183, 184, 185, 185, 186, 186, 187, 187, 188, 188,
1858 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
1859 189, 189, 189, 189, 189, 190, 191, 191, 192, 192,
1860 193, 193, 193, 193, 194, 194, 195, 195, 195, 195,
1861 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
1862 195, 195, 195, 195, 195, 195, 196, 196, 196, 196,
1863 196, 196, 196, 196, 196, 196, 197, 197, 198, 198,
1864 199, 199, 200, 200, 201, 201, 202, 202, 204, 203,
1865 205, 203, 203, 203, 203, 206, 203, 207, 203, 208,
1866 203, 203, 203, 203, 209, 210, 210, 211, 212, 212,
1867 212, 213, 213, 214, 214, 214, 214, 215, 216, 216,
1868 217, 218, 218, 219, 220, 221, 221, 222, 222, 222,
1869 222, 222, 222, 222, 222, 222, 222, 222, 223, 223,
1870 223, 223, 224, 224, 225, 226, 226, 227, 228, 228,
1871 228, 229, 229, 229, 229, 229, 229, 229, 229, 229,
1872 230, 230, 231, 232, 232, 233, 233, 233, 234, 234,
1873 235, 235, 236, 236, 236, 236, 236, 236, 236, 236,
1874 236, 236, 236, 236, 236, 237, 237, 238, 238, 238,
1875 238, 238, 238, 238, 238
1876};
1877
1878/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1879static const unsigned char yyr2[] =
1880{
1881 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1882 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1883 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1884 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1885 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1886 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1887 1, 1, 0, 2, 0, 1, 1, 1, 0, 2,
1888 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1889 1, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1890 0, 1, 1, 0, 1, 1, 1, 1, 1, 2,
1891 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1892 2, 1, 1, 1, 1, 0, 2, 0, 2, 0,
1893 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1894 1, 1, 1, 1, 2, 1, 2, 5, 5, 5,
1895 5, 3, 2, 5, 4, 2, 1, 1, 1, 3,
1896 1, 3, 1, 0, 1, 3, 4, 3, 3, 4,
1897 4, 3, 6, 5, 2, 2, 2, 2, 2, 2,
1898 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1899 6, 7, 7, 6, 8, 8, 3, 1, 1, 1,
1900 1, 0, 2, 6, 1, 0, 1, 2, 0, 3,
1901 0, 3, 3, 3, 3, 0, 7, 0, 8, 0,
1902 8, 5, 2, 3, 1, 3, 3, 3, 3, 1,
1903 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1904 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1905 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1906 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1907 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1908 6, 5, 2, 6, 7, 3, 5, 0, 0, 3,
1909 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
1910 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
1911 6, 2, 5, 7, 4
1912};
1913
1914/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1915 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1916 means the default is an error. */
1917static const unsigned short int yydefact[] =
1918{
1919 68, 58, 65, 59, 66, 60, 200, 198, 0, 0,
1920 0, 0, 0, 0, 78, 67, 0, 68, 196, 82,
1921 85, 0, 0, 212, 0, 0, 63, 0, 69, 70,
1922 72, 71, 73, 75, 74, 76, 77, 79, 80, 81,
1923 78, 78, 191, 1, 197, 83, 84, 78, 201, 86,
1924 87, 88, 89, 78, 259, 199, 259, 0, 0, 220,
1925 213, 214, 202, 248, 249, 204, 128, 129, 130, 131,
1926 132, 0, 0, 0, 0, 250, 251, 133, 203, 135,
1927 191, 191, 90, 190, 0, 93, 93, 260, 256, 64,
1928 231, 232, 233, 255, 215, 216, 219, 0, 153, 136,
1929 0, 0, 0, 0, 142, 154, 0, 134, 153, 0,
1930 0, 92, 91, 0, 188, 189, 0, 0, 94, 95,
1931 96, 97, 98, 0, 234, 0, 296, 258, 0, 217,
1932 152, 109, 148, 150, 0, 0, 0, 0, 0, 0,
1933 141, 0, 0, 0, 147, 0, 146, 0, 211, 128,
1934 129, 130, 0, 0, 0, 205, 99, 0, 228, 229,
1935 230, 295, 281, 0, 0, 0, 0, 93, 268, 269,
1936 2, 3, 4, 5, 6, 7, 8, 9, 10, 14,
1937 15, 16, 11, 12, 13, 0, 0, 0, 0, 0,
1938 0, 17, 18, 19, 20, 21, 22, 23, 24, 25,
1939 26, 27, 28, 0, 0, 0, 0, 0, 0, 0,
1940 0, 0, 257, 93, 272, 0, 294, 218, 145, 0,
1941 115, 0, 0, 144, 0, 155, 115, 207, 209, 0,
1942 192, 173, 174, 169, 171, 170, 172, 175, 168, 164,
1943 165, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1944 0, 0, 0, 0, 0, 167, 166, 124, 0, 280,
1945 262, 0, 261, 0, 0, 55, 0, 0, 29, 30,
1946 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
1947 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
1948 44, 45, 46, 47, 48, 0, 119, 119, 301, 0,
1949 0, 292, 0, 0, 0, 0, 0, 0, 0, 0,
1950 0, 0, 0, 101, 103, 102, 100, 104, 105, 106,
1951 107, 108, 110, 151, 149, 138, 139, 140, 143, 137,
1952 124, 124, 0, 0, 0, 0, 0, 0, 0, 0,
1953 157, 187, 0, 0, 0, 161, 0, 158, 0, 0,
1954 0, 0, 206, 226, 237, 238, 239, 244, 240, 241,
1955 242, 243, 235, 0, 246, 253, 252, 254, 0, 263,
1956 0, 0, 0, 0, 0, 297, 0, 299, 278, 0,
1957 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1958 0, 0, 114, 113, 111, 112, 116, 208, 210, 0,
1959 0, 0, 278, 0, 0, 0, 0, 0, 156, 142,
1960 154, 0, 159, 160, 0, 0, 0, 0, 0, 126,
1961 124, 225, 109, 223, 0, 236, 0, 0, 0, 0,
1962 0, 0, 0, 0, 0, 0, 304, 0, 0, 0,
1963 288, 289, 0, 0, 0, 0, 286, 0, 119, 0,
1964 0, 0, 0, 0, 0, 0, 0, 0, 186, 163,
1965 0, 0, 0, 0, 121, 127, 125, 62, 0, 115,
1966 0, 245, 0, 0, 277, 0, 0, 119, 120, 119,
1967 0, 0, 0, 0, 0, 0, 282, 283, 277, 0,
1968 302, 0, 193, 0, 0, 177, 0, 0, 0, 0,
1969 162, 0, 0, 0, 61, 222, 224, 109, 122, 0,
1970 0, 0, 0, 0, 284, 285, 298, 300, 279, 0,
1971 0, 287, 290, 291, 0, 119, 0, 0, 0, 183,
1972 0, 0, 179, 180, 176, 62, 123, 117, 247, 0,
1973 0, 109, 0, 115, 273, 0, 115, 303, 181, 182,
1974 0, 0, 0, 221, 0, 227, 0, 266, 0, 0,
1975 275, 0, 0, 274, 293, 178, 184, 185, 118, 264,
1976 0, 265, 0, 109, 0, 0, 0, 276, 0, 0,
1977 0, 0, 271, 0, 0, 270, 0, 267
1978};
1979
1980/* YYDEFGOTO[NTERM-NUM]. */
1981static const short int yydefgoto[] =
1982{
1983 -1, 252, 253, 254, 278, 295, 152, 153, 75, 505,
1984 12, 76, 14, 15, 40, 41, 42, 47, 53, 113,
1985 123, 322, 218, 396, 325, 555, 375, 419, 537, 352,
1986 420, 77, 154, 132, 147, 133, 134, 106, 341, 364,
1987 342, 116, 84, 148, 16, 17, 18, 20, 19, 257,
1988 330, 331, 62, 23, 60, 97, 423, 424, 124, 160,
1989 54, 92, 55, 48, 426, 365, 79, 367, 262, 56,
1990 88, 89, 212, 559, 127, 301, 513, 436, 213, 214,
1991 215, 216
1992};
1993
1994/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1995 STATE-NUM. */
1996#define YYPACT_NINF -522
1997static const short int yypact[] =
1998{
1999 40, -522, -522, -522, -522, -522, -522, -522, -24, -105,
2000 -4, -80, 60, -32, 461, -522, 134, 1386, -522, 153,
2001 150, 1, 15, -522, 16, 130, -522, 1208, -522, -522,
2002 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
2003 126, 126, 239, -522, -522, -522, -522, 126, -522, -522,
2004 -522, -522, -522, 126, 158, -522, -7, 168, 183, 194,
2005 -522, -522, -522, -522, -522, 45, -522, -522, -522, -522,
2006 -522, 212, 226, 6, 198, -522, -522, -522, 127, -522,
2007 204, 204, 248, -522, 218, 113, 113, -522, -522, 135,
2008 -522, -522, -522, -522, -522, -522, -522, -44, 1006, -522,
2009 101, 107, 371, 45, -522, 127, -103, -522, 1006, 218,
2010 218, -522, -522, 1043, -522, -522, 1223, 259, -522, -522,
2011 -522, -522, -522, 1274, -522, -13, 1423, -522, 269, -522,
2012 -522, 127, -522, 162, 146, 1305, 1305, 144, -101, 1305,
2013 -522, 159, 1223, 1305, 45, 161, 127, 85, -522, 41,
2014 301, 302, 250, 304, 782, -522, -522, 79, -522, -522,
2015 -522, -522, -522, 263, 1320, 193, 305, 113, -522, -522,
2016 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
2017 -522, -522, -522, -522, -522, 133, 456, 1305, 1305, 1305,
2018 1305, -522, -522, -522, -522, -522, -522, -522, -522, -522,
2019 -522, -522, -522, 1305, 1305, 1305, 1305, 1305, 1305, 1305,
2020 1305, 1305, -522, 113, -522, 165, -522, -522, 519, 1060,
2021 -522, -18, -33, -522, 166, 127, -522, -522, 127, 1043,
2022 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
2023 -522, 133, 456, 171, 174, 175, 177, 178, 1111, 1371,
2024 579, 307, 181, 182, 184, -522, -522, 186, 187, -522,
2025 45, 623, -522, 757, 757, -522, 757, 1274, -522, -522,
2026 -522, -522, -522, -522, -522, -522, -522, -522, 1305, -522,
2027 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
2028 -522, -522, -522, -522, -522, 1305, 98, 114, -522, 623,
2029 -64, 195, 196, 201, 202, 210, 216, 623, 623, 303,
2030 1274, 1305, 1305, -522, -522, -522, -522, -522, -522, -522,
2031 -522, -522, -522, -522, -522, 104, -522, -522, -522, 104,
2032 186, 186, 313, 190, 214, 1223, 1223, 1223, 1223, 1223,
2033 -522, -522, -36, 962, -111, -522, -78, -522, 1223, 1223,
2034 1223, 3, -522, 1126, -522, -522, -522, -522, -522, -522,
2035 -522, -522, 308, 1223, -522, -522, -522, -522, 219, -522,
2036 221, 757, 623, 623, 20, -522, 21, -522, -522, 757,
2037 225, 1305, 1305, 1305, 1305, 1305, 224, 227, 1305, 757,
2038 623, 231, -522, -522, -522, -522, -522, -522, -522, 1305,
2039 1223, 1223, -522, 233, 242, 245, 249, 1223, -522, 217,
2040 782, -65, -522, -522, 256, 257, 359, 386, 402, -522,
2041 186, -522, 127, 265, 264, -522, 394, -75, 400, 401,
2042 271, 275, 276, 757, 418, 757, 282, 285, 757, 289,
2043 127, -522, 290, 296, 757, 757, 127, 294, 300, 1305,
2044 -29, 306, 309, -50, 1223, 1223, 1223, 1223, -522, -522,
2045 292, 1223, 1223, 1305, -522, -522, -522, 293, 1157, -522,
2046 311, -522, 757, 757, 1305, 757, 757, 300, -522, 300,
2047 1305, 757, 312, 1305, 1305, 1305, -522, -522, 1305, 397,
2048 -522, 623, -522, 1223, 1223, -522, 316, 315, 317, 320,
2049 -522, 318, 321, 117, -522, -522, -522, 127, -1, 430,
2050 324, 322, 623, -8, -522, -522, -522, -522, -522, 314,
2051 757, -522, -522, -522, -5, 300, 329, 330, 1223, -522,
2052 1223, 1223, -522, -522, -522, 293, -522, 431, -522, 437,
2053 2, -522, 1305, -522, -522, 332, -522, -522, -522, -522,
2054 336, 337, 338, -522, 448, -522, 757, -522, 917, 4,
2055 519, 623, 14, -522, 104, -522, -522, -522, -522, -522,
2056 343, -522, 917, -522, 474, 475, 346, 519, 757, 757,
2057 477, 426, -522, 757, 481, -522, 757, -522
2058};
2059
2060/* YYPGOTO[NTERM-NUM]. */
2061static const short int yypgoto[] =
2062{
2063 -522, 370, 372, 373, 266, 255, -164, -522, 0, -25,
2064 420, 9, -522, -522, -522, -522, 33, -522, -522, -522,
2065 -151, -522, -404, -522, -223, -522, -291, 5, -522, -295,
2066 -522, -522, -26, 295, -115, -522, 403, 410, -58, -150,
2067 -221, 173, 222, 286, -522, -522, 501, -522, -522, -522,
2068 -522, -522, -522, -522, -522, -522, -522, -522, 433, -522,
2069 -522, -522, -522, -522, -522, -521, -140, 103, -184, -522,
2070 465, -522, -522, -522, -522, -522, 34, 122, -522, -522,
2071 -522, -522
2072};
2073
2074/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2075 positive, shift that token. If negative, reduce the rule which
2076 number is the opposite. If zero, do what YYDEFACT says.
2077 If YYTABLE_NINF, syntax error. */
2078#define YYTABLE_NINF -196
2079static const short int yytable[] =
2080{
2081 11, 78, 266, 329, 255, 298, 377, 230, 157, 13,
2082 101, 87, 158, 265, 256, 265, 267, 11, 467, 90,
2083 302, 303, 304, 305, 306, 21, 13, 309, 344, 346,
2084 417, 433, 435, 407, 417, 397, 398, 570, 24, 22,
2085 -195, 139, 412, 139, -55, -55, -55, -55, 105, 574,
2086 25, 576, 140, 418, 224, -64, 1, 2, 155, 3,
2087 4, 5, 310, 26, 231, 232, 407, 6, 7, 407,
2088 434, 434, 131, 80, 81, 27, 105, 413, 471, 407,
2089 85, 107, 131, 108, 227, 379, 86, 146, 8, 11,
2090 460, 9, 63, 64, 480, 10, 2, 146, 495, 4,
2091 128, 1, 2, 535, 3, 4, 5, 129, 407, 221,
2092 222, 28, 107, 225, 108, 408, 107, 228, 108, 492,
2093 327, 366, 411, 366, 366, 466, 366, 107, 391, 108,
2094 392, 393, 394, 326, 43, 395, 542, 560, 261, 542,
2095 543, 159, 427, 546, 57, 392, 393, 394, 91, 61,
2096 395, 1, 371, 557, 3, 571, 5, 490, 58, 366,
2097 102, 296, 297, 261, 299, 59, 258, 366, 366, 577,
2098 117, 118, 119, 120, 121, 122, 87, 300, 261, 261,
2099 261, 261, 261, 307, 308, 261, 516, 94, 517, 49,
2100 50, 51, 98, 131, 52, 389, 45, 439, 46, 441,
2101 442, 443, 95, 146, 263, 63, 64, 264, 103, 66,
2102 67, 68, 69, 96, 1, 2, 99, 3, 4, 5,
2103 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
2104 100, 366, 366, 366, 547, 392, 393, 394, 83, 366,
2105 395, 146, 374, 107, 70, 108, 508, 114, 115, 366,
2106 366, 135, 372, 233, 234, 235, 236, 136, 376, 107,
2107 255, 108, 107, 156, 108, 534, 37, 38, 39, 373,
2108 256, 82, 107, 83, 108, 311, 312, 402, 403, 404,
2109 405, 406, 142, 143, 146, 390, 261, 111, 217, 112,
2110 414, 415, 416, 366, 220, 366, 518, 223, 366, 521,
2111 522, 523, 109, 110, 366, 366, 219, 226, 229, 1,
2112 -56, -57, 3, 237, 5, 259, 265, 410, 335, 328,
2113 562, 336, 337, 564, 338, 339, 347, 422, 348, 349,
2114 351, 350, 366, 366, 353, 366, 366, 400, 388, 380,
2115 381, 366, 451, 452, 71, 382, 383, 72, 399, 458,
2116 73, 366, 74, 104, 384, 261, 440, 261, 261, 261,
2117 385, 401, 446, 428, 425, 429, 368, 369, 444, 370,
2118 459, 445, 366, 450, 438, 449, 558, 454, 63, 64,
2119 366, 103, 66, 67, 68, 69, 455, 1, 2, 456,
2120 3, 4, 5, 457, 463, 572, 496, 497, 498, 499,
2121 461, 462, 378, 501, 502, 464, 465, 313, 314, 468,
2122 386, 387, 469, 470, 472, 473, 366, 70, 474, 475,
2123 476, 366, 478, 491, 315, 316, 480, 317, 318, 481,
2124 319, 320, 321, 483, 484, 526, 527, 503, 366, 366,
2125 485, 488, 507, 366, 489, 500, 366, 434, 512, 538,
2126 493, 556, 568, 494, 261, 509, 520, 261, 261, 261,
2127 528, 530, 512, 529, 531, 544, 532, 504, 539, 533,
2128 550, 540, 551, 552, 430, 431, 432, 548, 549, 279,
2129 280, 554, 437, 563, 565, 566, 567, 575, 578, 579,
2130 580, 583, 447, 448, 584, 586, 209, 334, 210, 211,
2131 29, 30, 31, 32, 33, 34, 35, 333, 36, 126,
2132 553, 141, 138, 536, 324, 332, 561, 71, 44, 125,
2133 72, 93, 524, 73, 453, 74, 137, 0, 0, 0,
2134 0, 0, 0, 0, 0, 504, 477, 0, 479, 0,
2135 0, 482, 0, 0, 0, 0, 0, 486, 487, 281,
2136 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
2137 292, 293, 294, 0, 0, 0, 0, 0, 0, 0,
2138 0, 0, 0, 0, 0, 510, 511, 0, 514, 515,
2139 0, 0, 0, 0, 519, 0, 63, 64, 0, 103,
2140 149, 150, 151, 69, 525, 1, 2, 0, 3, 4,
2141 5, 37, 38, 39, 0, 0, 0, 0, 0, 0,
2142 0, 0, 0, 0, 0, 541, 0, 0, 0, 0,
2143 0, 0, 0, 545, 0, 70, 354, 355, 0, 0,
2144 63, 64, 356, 313, 314, 0, 0, 0, 0, 1,
2145 2, 0, 3, 4, 5, 357, 358, 359, 0, 0,
2146 315, 316, 0, 317, 318, 0, 319, 320, 321, 569,
2147 360, 361, 0, 0, 573, 0, 0, 0, 0, 0,
2148 0, 0, 0, 0, 0, 0, 0, 362, 0, 0,
2149 0, 581, 582, 0, 0, 0, 585, 0, 0, 587,
2150 0, 0, 0, 170, 171, 172, 173, 174, 175, 176,
2151 177, 178, 179, 180, 181, 182, 183, 184, 241, 242,
2152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2153 0, 0, 0, 0, 0, 71, 0, 0, 72, 0,
2154 0, 73, 0, 74, 345, 243, 191, 192, 193, 194,
2155 195, 196, 197, 198, 199, 200, 201, 202, 0, 244,
2156 0, 245, 246, 247, 0, 0, 0, 0, 0, 0,
2157 354, 355, 0, 0, 63, 64, 356, 0, 107, 0,
2158 108, 0, 0, 1, 2, 363, 3, 4, 5, 357,
2159 358, 359, 0, 0, 0, 0, 0, 0, 0, 63,
2160 64, 0, 0, 0, 360, 361, 0, 0, 1, 2,
2161 0, 3, 4, 5, 238, 0, 0, 0, 0, 0,
2162 0, 362, 0, 0, 0, 0, 0, 0, 0, 239,
2163 240, 0, 0, 0, 0, 0, 0, 170, 171, 172,
2164 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2165 183, 184, 241, 242, 0, 0, 0, 0, 0, 0,
2166 0, 0, 170, 171, 172, 173, 174, 175, 176, 177,
2167 178, 179, 180, 181, 182, 183, 184, 241, 242, 243,
2168 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2169 201, 202, 0, 244, 0, 245, 246, 247, 0, 0,
2170 0, 0, 0, 0, 243, 191, 192, 193, 194, 195,
2171 196, 197, 198, 199, 200, 201, 202, 0, 244, 363,
2172 245, 246, 247, 0, 0, 0, 0, 0, 0, 0,
2173 354, 355, 0, 0, 0, 0, 356, 107, 0, 108,
2174 0, 248, 0, 0, 249, 0, 250, 0, 251, 357,
2175 358, 359, 0, 0, 0, 0, 0, 0, 0, 0,
2176 0, 0, 0, 0, 360, 361, 0, 0, 0, 0,
2177 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
2178 64, 362, 103, 149, 150, 151, 69, 0, 1, 2,
2179 0, 3, 4, 5, 0, 0, 0, 170, 171, 172,
2180 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2181 183, 184, 241, 242, 0, 0, 0, 0, 70, 0,
2182 0, 0, 0, 63, 64, 0, 103, 66, 67, 68,
2183 69, 0, 1, 2, 0, 3, 4, 5, 0, 243,
2184 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2185 201, 202, 130, 244, 0, 245, 246, 247, 0, 0,
2186 63, 64, 70, 144, 66, 67, 68, 69, 0, 1,
2187 2, 0, 3, 4, 5, 0, 0, 63, 64, 363,
2188 103, 66, 67, 68, 69, 0, 1, 2, 0, 3,
2189 4, 5, 0, 0, 0, 0, 0, 0, 0, 70,
2190 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
2191 0, 0, 0, 0, 0, 0, 70, 0, 71, 0,
2192 0, 72, 0, 0, 73, 0, 74, 409, 63, 64,
2193 0, 103, 149, 150, 151, 69, 0, 1, 2, 0,
2194 3, 4, 5, 63, 64, 0, 103, 66, 67, 68,
2195 69, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2196 0, 0, 71, 0, 0, 72, 0, 70, 73, 0,
2197 74, 145, 421, 0, 63, 64, 0, 103, 66, 67,
2198 68, 69, 70, 1, 2, 0, 3, 4, 5, 0,
2199 0, 0, 0, 0, 0, 0, 0, 0, 0, 71,
2200 0, 0, 72, 506, 0, 73, 0, 74, 0, 0,
2201 0, 0, 0, 70, 0, 0, 71, 0, 0, 72,
2202 0, 0, 73, 0, 74, 63, 64, 0, 65, 66,
2203 67, 68, 69, 0, 1, 2, 0, 3, 4, 5,
2204 63, 64, 0, 103, 149, 150, 151, 69, 0, 1,
2205 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2206 0, 0, 0, 0, 70, 0, 0, 71, 0, 0,
2207 72, 0, 340, 73, 0, 74, 0, 0, 0, 70,
2208 0, 0, 71, 0, 0, 72, 0, 0, 73, 0,
2209 74, 63, 64, 0, 144, 66, 67, 68, 69, 0,
2210 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2211 0, 0, 0, 71, 0, 0, 72, 0, 0, 73,
2212 0, 74, 63, 64, 0, 103, 66, 67, 68, 69,
2213 70, 1, 2, 0, 3, 4, 5, 63, 64, 0,
2214 260, 66, 67, 68, 69, 0, 1, 2, 0, 3,
2215 4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
2216 0, 70, 0, 0, 71, 0, 0, 72, 0, 0,
2217 73, 0, 74, 0, 0, 0, 70, 0, 0, 71,
2218 0, 0, 72, 0, 0, 73, 0, 74, 63, 64,
2219 0, 103, 149, 150, 151, 69, -194, 1, 2, 0,
2220 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2221 0, -64, 1, 2, 0, 3, 4, 5, 0, 0,
2222 0, 0, 0, 6, 7, 0, 0, 70, 0, 0,
2223 71, 0, 0, 72, 0, 0, 73, 0, 74, 0,
2224 0, 0, 0, 0, 8, 0, 0, 9, 0, 0,
2225 0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
2226 0, 71, 0, 0, 72, 0, 161, 73, 0, 74,
2227 0, 0, 0, 0, 0, 0, 71, 0, 0, 72,
2228 0, 0, 73, 0, 74, 162, 163, 0, 0, 0,
2229 0, 0, 0, 0, 0, 0, 0, 164, 165, 166,
2230 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2231 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
2232 0, 0, 0, 0, 0, 0, 0, 71, 0, 0,
2233 72, 0, 0, 73, 0, 343, 0, 0, 0, 0,
2234 187, 188, 189, 0, 0, 190, 191, 192, 193, 194,
2235 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
2236 205, 206, 207, 208
2237};
2238
2239static const short int yycheck[] =
2240{
2241 0, 27, 166, 226, 154, 189, 297, 147, 123, 0,
2242 4, 18, 25, 11, 154, 11, 167, 17, 422, 26,
2243 204, 205, 206, 207, 208, 49, 17, 211, 249, 250,
2244 31, 11, 11, 144, 31, 330, 331, 558, 143, 63,
2245 0, 144, 153, 144, 3, 4, 5, 6, 74, 35,
2246 54, 572, 155, 50, 155, 15, 16, 17, 116, 19,
2247 20, 21, 213, 143, 23, 24, 144, 27, 28, 144,
2248 50, 50, 98, 40, 41, 15, 102, 155, 153, 144,
2249 47, 145, 108, 147, 142, 149, 53, 113, 48, 89,
2250 155, 51, 7, 8, 144, 55, 17, 123, 148, 20,
2251 144, 16, 17, 507, 19, 20, 21, 151, 144, 135,
2252 136, 143, 145, 139, 147, 151, 145, 143, 147, 148,
2253 153, 261, 343, 263, 264, 420, 266, 145, 312, 147,
2254 131, 132, 133, 151, 0, 136, 144, 541, 164, 144,
2255 148, 154, 363, 148, 143, 131, 132, 133, 155, 19,
2256 136, 16, 267, 151, 19, 151, 21, 448, 143, 299,
2257 154, 187, 188, 189, 190, 149, 157, 307, 308, 573,
2258 57, 58, 59, 60, 61, 62, 18, 203, 204, 205,
2259 206, 207, 208, 209, 210, 211, 477, 19, 479, 39,
2260 40, 41, 147, 219, 44, 310, 43, 381, 45, 383,
2261 384, 385, 19, 229, 11, 7, 8, 14, 10, 11,
2262 12, 13, 14, 19, 16, 17, 4, 19, 20, 21,
2263 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2264 4, 371, 372, 373, 525, 131, 132, 133, 34, 379,
2265 136, 267, 144, 145, 46, 147, 469, 29, 30, 389,
2266 390, 150, 278, 3, 4, 5, 6, 150, 144, 145,
2267 410, 147, 145, 4, 147, 148, 140, 141, 142, 295,
2268 410, 32, 145, 34, 147, 110, 111, 335, 336, 337,
2269 338, 339, 109, 110, 310, 311, 312, 39, 19, 41,
2270 348, 349, 350, 433, 148, 435, 480, 153, 438, 483,
2271 484, 485, 80, 81, 444, 445, 144, 148, 147, 16,
2272 9, 9, 19, 9, 21, 52, 11, 343, 147, 153,
2273 543, 147, 147, 546, 147, 147, 19, 353, 147, 147,
2274 144, 147, 472, 473, 147, 475, 476, 147, 35, 144,
2275 144, 481, 400, 401, 146, 144, 144, 149, 35, 407,
2276 152, 491, 154, 155, 144, 381, 382, 383, 384, 385,
2277 144, 147, 388, 144, 56, 144, 263, 264, 144, 266,
2278 153, 144, 512, 399, 149, 144, 540, 144, 7, 8,
2279 520, 10, 11, 12, 13, 14, 144, 16, 17, 144,
2280 19, 20, 21, 144, 35, 559, 454, 455, 456, 457,
2281 144, 144, 299, 461, 462, 19, 4, 114, 115, 144,
2282 307, 308, 148, 19, 14, 14, 556, 46, 147, 144,
2283 144, 561, 4, 449, 131, 132, 144, 134, 135, 144,
2284 137, 138, 139, 144, 144, 493, 494, 463, 578, 579,
2285 144, 147, 468, 583, 144, 153, 586, 50, 474, 19,
2286 144, 14, 4, 144, 480, 144, 144, 483, 484, 485,
2287 144, 144, 488, 148, 144, 151, 148, 467, 144, 148,
2288 528, 149, 530, 531, 371, 372, 373, 148, 148, 23,
2289 24, 50, 379, 151, 148, 148, 148, 144, 14, 14,
2290 144, 14, 389, 390, 68, 14, 126, 242, 126, 126,
2291 39, 40, 41, 42, 43, 44, 45, 241, 47, 89,
2292 535, 108, 102, 508, 219, 229, 542, 146, 17, 86,
2293 149, 56, 488, 152, 402, 154, 155, -1, -1, -1,
2294 -1, -1, -1, -1, -1, 535, 433, -1, 435, -1,
2295 -1, 438, -1, -1, -1, -1, -1, 444, 445, 93,
2296 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2297 104, 105, 106, -1, -1, -1, -1, -1, -1, -1,
2298 -1, -1, -1, -1, -1, 472, 473, -1, 475, 476,
2299 -1, -1, -1, -1, 481, -1, 7, 8, -1, 10,
2300 11, 12, 13, 14, 491, 16, 17, -1, 19, 20,
2301 21, 140, 141, 142, -1, -1, -1, -1, -1, -1,
2302 -1, -1, -1, -1, -1, 512, -1, -1, -1, -1,
2303 -1, -1, -1, 520, -1, 46, 3, 4, -1, -1,
2304 7, 8, 9, 114, 115, -1, -1, -1, -1, 16,
2305 17, -1, 19, 20, 21, 22, 23, 24, -1, -1,
2306 131, 132, -1, 134, 135, -1, 137, 138, 139, 556,
2307 37, 38, -1, -1, 561, -1, -1, -1, -1, -1,
2308 -1, -1, -1, -1, -1, -1, -1, 54, -1, -1,
2309 -1, 578, 579, -1, -1, -1, 583, -1, -1, 586,
2310 -1, -1, -1, 70, 71, 72, 73, 74, 75, 76,
2311 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2312 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2313 -1, -1, -1, -1, -1, 146, -1, -1, 149, -1,
2314 -1, 152, -1, 154, 155, 112, 113, 114, 115, 116,
2315 117, 118, 119, 120, 121, 122, 123, 124, -1, 126,
2316 -1, 128, 129, 130, -1, -1, -1, -1, -1, -1,
2317 3, 4, -1, -1, 7, 8, 9, -1, 145, -1,
2318 147, -1, -1, 16, 17, 152, 19, 20, 21, 22,
2319 23, 24, -1, -1, -1, -1, -1, -1, -1, 7,
2320 8, -1, -1, -1, 37, 38, -1, -1, 16, 17,
2321 -1, 19, 20, 21, 22, -1, -1, -1, -1, -1,
2322 -1, 54, -1, -1, -1, -1, -1, -1, -1, 37,
2323 38, -1, -1, -1, -1, -1, -1, 70, 71, 72,
2324 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2325 83, 84, 85, 86, -1, -1, -1, -1, -1, -1,
2326 -1, -1, 70, 71, 72, 73, 74, 75, 76, 77,
2327 78, 79, 80, 81, 82, 83, 84, 85, 86, 112,
2328 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2329 123, 124, -1, 126, -1, 128, 129, 130, -1, -1,
2330 -1, -1, -1, -1, 112, 113, 114, 115, 116, 117,
2331 118, 119, 120, 121, 122, 123, 124, -1, 126, 152,
2332 128, 129, 130, -1, -1, -1, -1, -1, -1, -1,
2333 3, 4, -1, -1, -1, -1, 9, 145, -1, 147,
2334 -1, 149, -1, -1, 152, -1, 154, -1, 156, 22,
2335 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2336 -1, -1, -1, -1, 37, 38, -1, -1, -1, -1,
2337 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
2338 8, 54, 10, 11, 12, 13, 14, -1, 16, 17,
2339 -1, 19, 20, 21, -1, -1, -1, 70, 71, 72,
2340 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2341 83, 84, 85, 86, -1, -1, -1, -1, 46, -1,
2342 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2343 14, -1, 16, 17, -1, 19, 20, 21, -1, 112,
2344 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2345 123, 124, 36, 126, -1, 128, 129, 130, -1, -1,
2346 7, 8, 46, 10, 11, 12, 13, 14, -1, 16,
2347 17, -1, 19, 20, 21, -1, -1, 7, 8, 152,
2348 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2349 20, 21, -1, -1, -1, -1, -1, -1, -1, 46,
2350 -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
2351 -1, -1, -1, -1, -1, -1, 46, -1, 146, -1,
2352 -1, 149, -1, -1, 152, -1, 154, 155, 7, 8,
2353 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2354 19, 20, 21, 7, 8, -1, 10, 11, 12, 13,
2355 14, -1, 16, 17, -1, 19, 20, 21, -1, -1,
2356 -1, -1, 146, -1, -1, 149, -1, 46, 152, -1,
2357 154, 118, 36, -1, 7, 8, -1, 10, 11, 12,
2358 13, 14, 46, 16, 17, -1, 19, 20, 21, -1,
2359 -1, -1, -1, -1, -1, -1, -1, -1, -1, 146,
2360 -1, -1, 149, 36, -1, 152, -1, 154, -1, -1,
2361 -1, -1, -1, 46, -1, -1, 146, -1, -1, 149,
2362 -1, -1, 152, -1, 154, 7, 8, -1, 10, 11,
2363 12, 13, 14, -1, 16, 17, -1, 19, 20, 21,
2364 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
2365 17, -1, 19, 20, 21, -1, -1, -1, -1, -1,
2366 -1, -1, -1, -1, 46, -1, -1, 146, -1, -1,
2367 149, -1, 151, 152, -1, 154, -1, -1, -1, 46,
2368 -1, -1, 146, -1, -1, 149, -1, -1, 152, -1,
2369 154, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2370 16, 17, -1, 19, 20, 21, -1, -1, -1, -1,
2371 -1, -1, -1, 146, -1, -1, 149, -1, -1, 152,
2372 -1, 154, 7, 8, -1, 10, 11, 12, 13, 14,
2373 46, 16, 17, -1, 19, 20, 21, 7, 8, -1,
2374 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2375 20, 21, -1, -1, -1, -1, -1, -1, -1, -1,
2376 -1, 46, -1, -1, 146, -1, -1, 149, -1, -1,
2377 152, -1, 154, -1, -1, -1, 46, -1, -1, 146,
2378 -1, -1, 149, -1, -1, 152, -1, 154, 7, 8,
2379 -1, 10, 11, 12, 13, 14, 0, 16, 17, -1,
2380 19, 20, 21, -1, -1, -1, -1, -1, -1, -1,
2381 -1, 15, 16, 17, -1, 19, 20, 21, -1, -1,
2382 -1, -1, -1, 27, 28, -1, -1, 46, -1, -1,
2383 146, -1, -1, 149, -1, -1, 152, -1, 154, -1,
2384 -1, -1, -1, -1, 48, -1, -1, 51, -1, -1,
2385 -1, 55, -1, -1, -1, -1, -1, -1, -1, -1,
2386 -1, 146, -1, -1, 149, -1, 33, 152, -1, 154,
2387 -1, -1, -1, -1, -1, -1, 146, -1, -1, 149,
2388 -1, -1, 152, -1, 154, 52, 53, -1, -1, -1,
2389 -1, -1, -1, -1, -1, -1, -1, 64, 65, 66,
2390 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2391 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2392 -1, -1, -1, -1, -1, -1, -1, 146, -1, -1,
2393 149, -1, -1, 152, -1, 154, -1, -1, -1, -1,
2394 107, 108, 109, -1, -1, 112, 113, 114, 115, 116,
2395 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2396 127, 128, 129, 130
2397};
2398
2399/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2400 symbol of state STATE-NUM. */
2401static const unsigned char yystos[] =
2402{
2403 0, 16, 17, 19, 20, 21, 27, 28, 48, 51,
2404 55, 165, 167, 168, 169, 170, 201, 202, 203, 205,
2405 204, 49, 63, 210, 143, 54, 143, 15, 143, 39,
2406 40, 41, 42, 43, 44, 45, 47, 140, 141, 142,
2407 171, 172, 173, 0, 203, 43, 45, 174, 220, 39,
2408 40, 41, 44, 175, 217, 219, 226, 143, 143, 149,
2409 211, 19, 209, 7, 8, 10, 11, 12, 13, 14,
2410 46, 146, 149, 152, 154, 165, 168, 188, 189, 223,
2411 173, 173, 32, 34, 199, 173, 173, 18, 227, 228,
2412 26, 155, 218, 227, 19, 19, 19, 212, 147, 4,
2413 4, 4, 154, 10, 155, 189, 194, 145, 147, 199,
2414 199, 39, 41, 176, 29, 30, 198, 57, 58, 59,
2415 60, 61, 62, 177, 215, 215, 167, 231, 144, 151,
2416 36, 189, 190, 192, 193, 150, 150, 155, 194, 144,
2417 155, 193, 198, 198, 10, 118, 189, 191, 200, 11,
2418 12, 13, 163, 164, 189, 195, 4, 191, 25, 154,
2419 216, 33, 52, 53, 64, 65, 66, 67, 68, 69,
2420 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2421 80, 81, 82, 83, 84, 85, 86, 107, 108, 109,
2422 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2423 122, 123, 124, 125, 126, 127, 128, 129, 130, 158,
2424 159, 160, 229, 235, 236, 237, 238, 19, 179, 144,
2425 148, 189, 189, 153, 155, 189, 148, 195, 189, 147,
2426 223, 23, 24, 3, 4, 5, 6, 9, 22, 37,
2427 38, 85, 86, 112, 126, 128, 129, 130, 149, 152,
2428 154, 156, 158, 159, 160, 196, 223, 206, 168, 52,
2429 10, 189, 225, 11, 14, 11, 163, 177, 87, 88,
2430 89, 90, 91, 92, 93, 94, 95, 96, 161, 23,
2431 24, 93, 94, 95, 96, 97, 98, 99, 100, 101,
2432 102, 103, 104, 105, 106, 162, 189, 189, 225, 189,
2433 189, 232, 225, 225, 225, 225, 225, 189, 189, 225,
2434 177, 110, 111, 114, 115, 131, 132, 134, 135, 137,
2435 138, 139, 178, 36, 190, 181, 151, 153, 153, 181,
2436 207, 208, 200, 161, 162, 147, 147, 147, 147, 147,
2437 151, 195, 197, 154, 197, 155, 197, 19, 147, 147,
2438 147, 144, 186, 147, 3, 4, 9, 22, 23, 24,
2439 37, 38, 54, 152, 196, 222, 223, 224, 224, 224,
2440 224, 191, 189, 189, 144, 183, 144, 183, 224, 149,
2441 144, 144, 144, 144, 144, 144, 224, 224, 35, 191,
2442 189, 225, 131, 132, 133, 136, 180, 186, 186, 35,
2443 147, 147, 195, 195, 195, 195, 195, 144, 151, 155,
2444 189, 197, 153, 155, 195, 195, 195, 31, 50, 184,
2445 187, 36, 189, 213, 214, 56, 221, 197, 144, 144,
2446 224, 224, 224, 11, 50, 11, 234, 224, 149, 225,
2447 189, 225, 225, 225, 144, 144, 189, 224, 224, 144,
2448 189, 195, 195, 234, 144, 144, 144, 144, 195, 153,
2449 155, 144, 144, 35, 19, 4, 186, 179, 144, 148,
2450 19, 153, 14, 14, 147, 144, 144, 224, 4, 224,
2451 144, 144, 224, 144, 144, 144, 224, 224, 147, 144,
2452 183, 189, 148, 144, 144, 148, 195, 195, 195, 195,
2453 153, 195, 195, 189, 165, 166, 36, 189, 181, 144,
2454 224, 224, 189, 233, 224, 224, 183, 183, 225, 224,
2455 144, 225, 225, 225, 233, 224, 195, 195, 144, 148,
2456 144, 144, 148, 148, 148, 179, 184, 185, 19, 144,
2457 149, 224, 144, 148, 151, 224, 148, 183, 148, 148,
2458 195, 195, 195, 166, 50, 182, 14, 151, 163, 230,
2459 179, 189, 181, 151, 181, 148, 148, 148, 4, 224,
2460 222, 151, 163, 224, 35, 144, 222, 179, 14, 14,
2461 144, 224, 224, 14, 68, 224, 14, 224
2462};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002463
2464#define yyerrok (yyerrstatus = 0)
2465#define yyclearin (yychar = YYEMPTY)
Reid Spencerb8f85052007-07-31 03:50:36 +00002466#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002467#define YYEOF 0
Reid Spencerb8f85052007-07-31 03:50:36 +00002468
Reid Spencer68a24bd2005-08-27 18:50:39 +00002469#define YYACCEPT goto yyacceptlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002470#define YYABORT goto yyabortlab
2471#define YYERROR goto yyerrorlab
2472
2473
2474/* Like YYERROR except do call yyerror. This remains here temporarily
2475 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002476 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002477
Reid Spencer68a24bd2005-08-27 18:50:39 +00002478#define YYFAIL goto yyerrlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002479
Reid Spencer68a24bd2005-08-27 18:50:39 +00002480#define YYRECOVERING() (!!yyerrstatus)
Reid Spencerb8f85052007-07-31 03:50:36 +00002481
2482#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002483do \
2484 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencerb8f85052007-07-31 03:50:36 +00002485 { \
2486 yychar = (Token); \
2487 yylval = (Value); \
2488 yytoken = YYTRANSLATE (yychar); \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002489 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002490 goto yybackup; \
2491 } \
2492 else \
Reid Spencerb8f85052007-07-31 03:50:36 +00002493 { \
2494 yyerror (YY_("syntax error: cannot back up")); \
2495 YYERROR; \
2496 } \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002497while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002498
Reid Spencerb8f85052007-07-31 03:50:36 +00002499
Reid Spencer68a24bd2005-08-27 18:50:39 +00002500#define YYTERROR 1
2501#define YYERRCODE 256
2502
Reid Spencerb8f85052007-07-31 03:50:36 +00002503
2504/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2505 If N is 0, then set CURRENT to the empty location which ends
2506 the previous symbol: RHS[0] (always defined). */
2507
2508#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2509#ifndef YYLLOC_DEFAULT
2510# define YYLLOC_DEFAULT(Current, Rhs, N) \
2511 do \
2512 if (N) \
2513 { \
2514 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2515 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2516 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2517 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2518 } \
2519 else \
2520 { \
2521 (Current).first_line = (Current).last_line = \
2522 YYRHSLOC (Rhs, 0).last_line; \
2523 (Current).first_column = (Current).last_column = \
2524 YYRHSLOC (Rhs, 0).last_column; \
2525 } \
2526 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002527#endif
2528
Reid Spencerb8f85052007-07-31 03:50:36 +00002529
2530/* YY_LOCATION_PRINT -- Print the location on the stream.
2531 This macro was not mandated originally: define only if we know
2532 we won't break user code: when these are the locations we know. */
2533
2534#ifndef YY_LOCATION_PRINT
2535# if YYLTYPE_IS_TRIVIAL
2536# define YY_LOCATION_PRINT(File, Loc) \
2537 fprintf (File, "%d.%d-%d.%d", \
2538 (Loc).first_line, (Loc).first_column, \
2539 (Loc).last_line, (Loc).last_column)
2540# else
2541# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2542# endif
2543#endif
2544
2545
2546/* YYLEX -- calling `yylex' with the right arguments. */
2547
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002548#ifdef YYLEX_PARAM
Reid Spencerb8f85052007-07-31 03:50:36 +00002549# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002550#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002551# define YYLEX yylex ()
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002552#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002553
2554/* Enable debugging if requested. */
2555#if YYDEBUG
2556
2557# ifndef YYFPRINTF
2558# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2559# define YYFPRINTF fprintf
2560# endif
2561
2562# define YYDPRINTF(Args) \
2563do { \
2564 if (yydebug) \
2565 YYFPRINTF Args; \
2566} while (0)
2567
2568# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2569do { \
2570 if (yydebug) \
2571 { \
2572 YYFPRINTF (stderr, "%s ", Title); \
2573 yysymprint (stderr, \
2574 Type, Value); \
2575 YYFPRINTF (stderr, "\n"); \
2576 } \
2577} while (0)
2578
2579/*------------------------------------------------------------------.
2580| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2581| TOP (included). |
2582`------------------------------------------------------------------*/
2583
2584#if defined (__STDC__) || defined (__cplusplus)
2585static void
2586yy_stack_print (short int *bottom, short int *top)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002587#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002588static void
2589yy_stack_print (bottom, top)
2590 short int *bottom;
2591 short int *top;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002592#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002593{
2594 YYFPRINTF (stderr, "Stack now");
2595 for (/* Nothing. */; bottom <= top; ++bottom)
2596 YYFPRINTF (stderr, " %d", *bottom);
2597 YYFPRINTF (stderr, "\n");
2598}
2599
2600# define YY_STACK_PRINT(Bottom, Top) \
2601do { \
2602 if (yydebug) \
2603 yy_stack_print ((Bottom), (Top)); \
2604} while (0)
2605
2606
2607/*------------------------------------------------.
2608| Report that the YYRULE is going to be reduced. |
2609`------------------------------------------------*/
2610
2611#if defined (__STDC__) || defined (__cplusplus)
2612static void
2613yy_reduce_print (int yyrule)
2614#else
2615static void
2616yy_reduce_print (yyrule)
2617 int yyrule;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002618#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002619{
2620 int yyi;
2621 unsigned long int yylno = yyrline[yyrule];
2622 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2623 yyrule - 1, yylno);
2624 /* Print the symbols being reduced, and their result. */
2625 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2626 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2627 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2628}
Reid Spencered951ea2007-05-19 07:22:10 +00002629
Reid Spencerb8f85052007-07-31 03:50:36 +00002630# define YY_REDUCE_PRINT(Rule) \
2631do { \
2632 if (yydebug) \
2633 yy_reduce_print (Rule); \
2634} while (0)
Reid Spencered951ea2007-05-19 07:22:10 +00002635
Reid Spencerb8f85052007-07-31 03:50:36 +00002636/* Nonzero means print parse trace. It is left uninitialized so that
2637 multiple parsers can coexist. */
2638int yydebug;
2639#else /* !YYDEBUG */
2640# define YYDPRINTF(Args)
2641# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2642# define YY_STACK_PRINT(Bottom, Top)
2643# define YY_REDUCE_PRINT(Rule)
2644#endif /* !YYDEBUG */
Reid Spencered951ea2007-05-19 07:22:10 +00002645
Reid Spencered951ea2007-05-19 07:22:10 +00002646
Reid Spencerb8f85052007-07-31 03:50:36 +00002647/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002648#ifndef YYINITDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002649# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002650#endif
2651
Reid Spencerb8f85052007-07-31 03:50:36 +00002652/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2653 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002654
Reid Spencerb8f85052007-07-31 03:50:36 +00002655 Do not make this value too large; the results are undefined if
2656 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2657 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002658
2659#ifndef YYMAXDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002660# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002661#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002662
Reid Spencer68a24bd2005-08-27 18:50:39 +00002663
2664
Reid Spencerb8f85052007-07-31 03:50:36 +00002665#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002666
Reid Spencerb8f85052007-07-31 03:50:36 +00002667# ifndef yystrlen
2668# if defined (__GLIBC__) && defined (_STRING_H)
2669# define yystrlen strlen
2670# else
2671/* Return the length of YYSTR. */
2672static YYSIZE_T
2673# if defined (__STDC__) || defined (__cplusplus)
2674yystrlen (const char *yystr)
2675# else
2676yystrlen (yystr)
2677 const char *yystr;
2678# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002679{
Reid Spencerb8f85052007-07-31 03:50:36 +00002680 const char *yys = yystr;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002681
Reid Spencerb8f85052007-07-31 03:50:36 +00002682 while (*yys++ != '\0')
2683 continue;
2684
2685 return yys - yystr - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002686}
Reid Spencerb8f85052007-07-31 03:50:36 +00002687# endif
2688# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002689
Reid Spencerb8f85052007-07-31 03:50:36 +00002690# ifndef yystpcpy
2691# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2692# define yystpcpy stpcpy
2693# else
2694/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2695 YYDEST. */
2696static char *
2697# if defined (__STDC__) || defined (__cplusplus)
2698yystpcpy (char *yydest, const char *yysrc)
2699# else
2700yystpcpy (yydest, yysrc)
2701 char *yydest;
2702 const char *yysrc;
2703# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002704{
Reid Spencerb8f85052007-07-31 03:50:36 +00002705 char *yyd = yydest;
2706 const char *yys = yysrc;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002707
Reid Spencerb8f85052007-07-31 03:50:36 +00002708 while ((*yyd++ = *yys++) != '\0')
2709 continue;
2710
2711 return yyd - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002712}
Reid Spencerb8f85052007-07-31 03:50:36 +00002713# endif
2714# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002715
Reid Spencerb8f85052007-07-31 03:50:36 +00002716# ifndef yytnamerr
2717/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2718 quotes and backslashes, so that it's suitable for yyerror. The
2719 heuristic is that double-quoting is unnecessary unless the string
2720 contains an apostrophe, a comma, or backslash (other than
2721 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2722 null, do not copy; instead, return the length of what the result
2723 would have been. */
2724static YYSIZE_T
2725yytnamerr (char *yyres, const char *yystr)
2726{
2727 if (*yystr == '"')
2728 {
2729 size_t yyn = 0;
2730 char const *yyp = yystr;
2731
2732 for (;;)
2733 switch (*++yyp)
2734 {
2735 case '\'':
2736 case ',':
2737 goto do_not_strip_quotes;
2738
2739 case '\\':
2740 if (*++yyp != '\\')
2741 goto do_not_strip_quotes;
2742 /* Fall through. */
2743 default:
2744 if (yyres)
2745 yyres[yyn] = *yyp;
2746 yyn++;
2747 break;
2748
2749 case '"':
2750 if (yyres)
2751 yyres[yyn] = '\0';
2752 return yyn;
2753 }
2754 do_not_strip_quotes: ;
2755 }
2756
2757 if (! yyres)
2758 return yystrlen (yystr);
2759
2760 return yystpcpy (yyres, yystr) - yyres;
2761}
2762# endif
2763
2764#endif /* YYERROR_VERBOSE */
2765
Reid Spencered951ea2007-05-19 07:22:10 +00002766
2767
Reid Spencerb8f85052007-07-31 03:50:36 +00002768#if YYDEBUG
2769/*--------------------------------.
2770| Print this symbol on YYOUTPUT. |
2771`--------------------------------*/
Reid Spencered951ea2007-05-19 07:22:10 +00002772
Reid Spencerb8f85052007-07-31 03:50:36 +00002773#if defined (__STDC__) || defined (__cplusplus)
2774static void
2775yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002776#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002777static void
2778yysymprint (yyoutput, yytype, yyvaluep)
2779 FILE *yyoutput;
2780 int yytype;
2781 YYSTYPE *yyvaluep;
2782#endif
2783{
2784 /* Pacify ``unused variable'' warnings. */
2785 (void) yyvaluep;
2786
2787 if (yytype < YYNTOKENS)
2788 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2789 else
2790 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2791
2792
2793# ifdef YYPRINT
2794 if (yytype < YYNTOKENS)
2795 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2796# endif
2797 switch (yytype)
2798 {
2799 default:
2800 break;
2801 }
2802 YYFPRINTF (yyoutput, ")");
2803}
2804
2805#endif /* ! YYDEBUG */
2806/*-----------------------------------------------.
2807| Release the memory associated to this symbol. |
2808`-----------------------------------------------*/
2809
2810#if defined (__STDC__) || defined (__cplusplus)
2811static void
2812yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2813#else
2814static void
2815yydestruct (yymsg, yytype, yyvaluep)
2816 const char *yymsg;
2817 int yytype;
2818 YYSTYPE *yyvaluep;
2819#endif
2820{
2821 /* Pacify ``unused variable'' warnings. */
2822 (void) yyvaluep;
2823
2824 if (!yymsg)
2825 yymsg = "Deleting";
2826 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2827
2828 switch (yytype)
2829 {
2830
2831 default:
2832 break;
2833 }
2834}
2835
2836
2837/* Prevent warnings from -Wmissing-prototypes. */
2838
2839#ifdef YYPARSE_PARAM
2840# if defined (__STDC__) || defined (__cplusplus)
2841int yyparse (void *YYPARSE_PARAM);
2842# else
2843int yyparse ();
2844# endif
2845#else /* ! YYPARSE_PARAM */
2846#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002847int yyparse (void);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002848#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002849int yyparse ();
2850#endif
2851#endif /* ! YYPARSE_PARAM */
2852
2853
2854
2855/* The look-ahead symbol. */
2856int yychar;
2857
2858/* The semantic value of the look-ahead symbol. */
2859YYSTYPE yylval;
2860
2861/* Number of syntax errors so far. */
2862int yynerrs;
2863
2864
2865
2866/*----------.
2867| yyparse. |
2868`----------*/
2869
2870#ifdef YYPARSE_PARAM
2871# if defined (__STDC__) || defined (__cplusplus)
2872int yyparse (void *YYPARSE_PARAM)
2873# else
2874int yyparse (YYPARSE_PARAM)
2875 void *YYPARSE_PARAM;
2876# endif
2877#else /* ! YYPARSE_PARAM */
2878#if defined (__STDC__) || defined (__cplusplus)
2879int
2880yyparse (void)
2881#else
2882int
2883yyparse ()
2884
2885#endif
2886#endif
2887{
2888
2889 int yystate;
2890 int yyn;
2891 int yyresult;
2892 /* Number of tokens to shift before error messages enabled. */
2893 int yyerrstatus;
2894 /* Look-ahead token as an internal (translated) token number. */
2895 int yytoken = 0;
2896
2897 /* Three stacks and their tools:
2898 `yyss': related to states,
2899 `yyvs': related to semantic values,
2900 `yyls': related to locations.
2901
2902 Refer to the stacks thru separate pointers, to allow yyoverflow
2903 to reallocate them elsewhere. */
2904
2905 /* The state stack. */
2906 short int yyssa[YYINITDEPTH];
2907 short int *yyss = yyssa;
2908 short int *yyssp;
2909
2910 /* The semantic value stack. */
2911 YYSTYPE yyvsa[YYINITDEPTH];
2912 YYSTYPE *yyvs = yyvsa;
2913 YYSTYPE *yyvsp;
2914
2915
2916
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002917#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002918
Reid Spencerb8f85052007-07-31 03:50:36 +00002919 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002920
Reid Spencerb8f85052007-07-31 03:50:36 +00002921 /* The variables used to return semantic value and location from the
2922 action routines. */
2923 YYSTYPE yyval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002924
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002925
Reid Spencerb8f85052007-07-31 03:50:36 +00002926 /* When reducing, the number of symbols on the RHS of the reduced
2927 rule. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002928 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002929
Reid Spencerb8f85052007-07-31 03:50:36 +00002930 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002931
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 yystate = 0;
2933 yyerrstatus = 0;
2934 yynerrs = 0;
2935 yychar = YYEMPTY; /* Cause a token to be read. */
2936
2937 /* Initialize stack pointers.
2938 Waste one element of value and location stack
2939 so that they stay on the same level as the state stack.
2940 The wasted elements are never initialized. */
2941
Reid Spencerb8f85052007-07-31 03:50:36 +00002942 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943 yyvsp = yyvs;
2944
Reid Spencerb8f85052007-07-31 03:50:36 +00002945 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002946
Reid Spencerb8f85052007-07-31 03:50:36 +00002947/*------------------------------------------------------------.
2948| yynewstate -- Push a new state, which is found in yystate. |
2949`------------------------------------------------------------*/
2950 yynewstate:
2951 /* In all cases, when you get here, the value and location stacks
2952 have just been pushed. so pushing a state here evens the stacks.
2953 */
2954 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955
Reid Spencerb8f85052007-07-31 03:50:36 +00002956 yysetstate:
2957 *yyssp = yystate;
2958
2959 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960 {
2961 /* Get the current used size of the three stacks, in elements. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002962 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963
2964#ifdef yyoverflow
Reid Spencerb8f85052007-07-31 03:50:36 +00002965 {
2966 /* Give user a chance to reallocate the stack. Use copies of
2967 these so that the &'s don't force the real ones into
2968 memory. */
2969 YYSTYPE *yyvs1 = yyvs;
2970 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002971
Reid Spencerb8f85052007-07-31 03:50:36 +00002972
2973 /* Each stack pointer address is followed by the size of the
2974 data in use in that stack, in bytes. This used to be a
2975 conditional around just the two extra args, but that might
2976 be undefined if yyoverflow is a macro. */
2977 yyoverflow (YY_("memory exhausted"),
2978 &yyss1, yysize * sizeof (*yyssp),
2979 &yyvs1, yysize * sizeof (*yyvsp),
2980
2981 &yystacksize);
2982
2983 yyss = yyss1;
2984 yyvs = yyvs1;
2985 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002986#else /* no yyoverflow */
Reid Spencerb8f85052007-07-31 03:50:36 +00002987# ifndef YYSTACK_RELOCATE
2988 goto yyexhaustedlab;
2989# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002990 /* Extend the stack our own way. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002991 if (YYMAXDEPTH <= yystacksize)
2992 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993 yystacksize *= 2;
Reid Spencerb8f85052007-07-31 03:50:36 +00002994 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 yystacksize = YYMAXDEPTH;
Reid Spencerb8f85052007-07-31 03:50:36 +00002996
2997 {
2998 short int *yyss1 = yyss;
2999 union yyalloc *yyptr =
3000 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3001 if (! yyptr)
3002 goto yyexhaustedlab;
3003 YYSTACK_RELOCATE (yyss);
3004 YYSTACK_RELOCATE (yyvs);
3005
3006# undef YYSTACK_RELOCATE
3007 if (yyss1 != yyssa)
3008 YYSTACK_FREE (yyss1);
3009 }
3010# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003011#endif /* no yyoverflow */
3012
Reid Spencerb8f85052007-07-31 03:50:36 +00003013 yyssp = yyss + yysize - 1;
3014 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003015
3016
Reid Spencerb8f85052007-07-31 03:50:36 +00003017 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3018 (unsigned long int) yystacksize));
3019
3020 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003021 YYABORT;
3022 }
3023
Reid Spencerb8f85052007-07-31 03:50:36 +00003024 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003025
3026 goto yybackup;
Reid Spencerb8f85052007-07-31 03:50:36 +00003027
3028/*-----------.
3029| yybackup. |
3030`-----------*/
3031yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003032
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003033/* Do appropriate processing given the current state. */
Reid Spencerb8f85052007-07-31 03:50:36 +00003034/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003035/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00003036
Reid Spencerb8f85052007-07-31 03:50:36 +00003037 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003038
Reid Spencer68a24bd2005-08-27 18:50:39 +00003039 yyn = yypact[yystate];
Reid Spencerb8f85052007-07-31 03:50:36 +00003040 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003041 goto yydefault;
3042
Reid Spencerb8f85052007-07-31 03:50:36 +00003043 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003044
Reid Spencerb8f85052007-07-31 03:50:36 +00003045 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003046 if (yychar == YYEMPTY)
3047 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003048 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003049 yychar = YYLEX;
3050 }
3051
Reid Spencerb8f85052007-07-31 03:50:36 +00003052 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003053 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003054 yychar = yytoken = YYEOF;
3055 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003056 }
3057 else
3058 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003059 yytoken = YYTRANSLATE (yychar);
3060 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003061 }
3062
Reid Spencerb8f85052007-07-31 03:50:36 +00003063 /* If the proper action on seeing token YYTOKEN is to reduce or to
3064 detect an error, take that action. */
3065 yyn += yytoken;
3066 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003067 goto yydefault;
3068 yyn = yytable[yyn];
Reid Spencerb8f85052007-07-31 03:50:36 +00003069 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003070 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003071 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003072 goto yyerrlab;
3073 yyn = -yyn;
3074 goto yyreduce;
3075 }
3076
3077 if (yyn == YYFINAL)
3078 YYACCEPT;
3079
Reid Spencerb8f85052007-07-31 03:50:36 +00003080 /* Shift the look-ahead token. */
3081 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003082
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003083 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003084 if (yychar != YYEOF)
3085 yychar = YYEMPTY;
3086
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003087 *++yyvsp = yylval;
3088
Reid Spencerb8f85052007-07-31 03:50:36 +00003089
3090 /* Count tokens shifted since error; after three, turn off error
3091 status. */
3092 if (yyerrstatus)
3093 yyerrstatus--;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003094
3095 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003096 goto yynewstate;
3097
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003098
Reid Spencerb8f85052007-07-31 03:50:36 +00003099/*-----------------------------------------------------------.
3100| yydefault -- do the default action for the current state. |
3101`-----------------------------------------------------------*/
3102yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003103 yyn = yydefact[yystate];
3104 if (yyn == 0)
3105 goto yyerrlab;
Reid Spencerb8f85052007-07-31 03:50:36 +00003106 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003107
Reid Spencerb8f85052007-07-31 03:50:36 +00003108
3109/*-----------------------------.
3110| yyreduce -- Do a reduction. |
3111`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003112yyreduce:
Reid Spencerb8f85052007-07-31 03:50:36 +00003113 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003114 yylen = yyr2[yyn];
3115
Reid Spencerb8f85052007-07-31 03:50:36 +00003116 /* If YYLEN is nonzero, implement the default value of the action:
3117 `$$ = $1'.
3118
3119 Otherwise, the following line sets YYVAL to garbage.
3120 This behavior is undocumented and Bison
3121 users should not rely upon it. Assigning to YYVAL
3122 unconditionally makes the parser a bit smaller, and it avoids a
3123 GCC warning that YYVAL may be used uninitialized. */
3124 yyval = yyvsp[1-yylen];
3125
3126
3127 YY_REDUCE_PRINT (yyn);
3128 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003129 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003130 case 29:
3131#line 1122 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3132 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3133 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003134
Reid Spencerb8f85052007-07-31 03:50:36 +00003135 case 30:
3136#line 1122 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3137 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3138 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003139
Reid Spencerb8f85052007-07-31 03:50:36 +00003140 case 31:
3141#line 1123 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3142 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3143 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003144
Reid Spencerb8f85052007-07-31 03:50:36 +00003145 case 32:
3146#line 1123 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3147 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3148 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003149
Reid Spencerb8f85052007-07-31 03:50:36 +00003150 case 33:
3151#line 1124 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3152 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3153 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003154
Reid Spencerb8f85052007-07-31 03:50:36 +00003155 case 34:
3156#line 1124 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3157 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3158 break;
3159
3160 case 35:
3161#line 1125 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3162 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3163 break;
3164
3165 case 36:
3166#line 1125 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3167 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3168 break;
3169
3170 case 37:
3171#line 1126 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3172 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3173 break;
3174
3175 case 38:
3176#line 1126 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3177 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3178 break;
3179
3180 case 39:
3181#line 1130 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3182 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3183 break;
3184
3185 case 40:
3186#line 1130 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3187 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3188 break;
3189
3190 case 41:
3191#line 1131 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3192 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3193 break;
3194
3195 case 42:
3196#line 1131 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3197 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3198 break;
3199
3200 case 43:
3201#line 1132 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3202 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3203 break;
3204
3205 case 44:
3206#line 1132 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3207 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3208 break;
3209
3210 case 45:
3211#line 1133 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3212 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3213 break;
3214
3215 case 46:
3216#line 1133 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3217 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3218 break;
3219
3220 case 47:
3221#line 1134 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3222 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3223 break;
3224
3225 case 48:
3226#line 1134 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3227 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3228 break;
3229
3230 case 49:
3231#line 1135 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3232 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3233 break;
3234
3235 case 50:
3236#line 1135 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3237 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3238 break;
3239
3240 case 51:
3241#line 1136 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3242 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3243 break;
3244
3245 case 52:
3246#line 1136 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3247 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3248 break;
3249
3250 case 53:
3251#line 1137 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3252 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3253 break;
3254
3255 case 54:
3256#line 1138 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3257 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3258 break;
3259
3260 case 62:
3261#line 1147 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3262 { (yyval.StrVal) = 0; ;}
3263 break;
3264
3265 case 63:
3266#line 1151 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3267 {
3268 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003269 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003270 ;}
3271 break;
3272
3273 case 64:
3274#line 1155 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3275 {
3276 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003277 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003278 ;}
3279 break;
3280
3281 case 68:
3282#line 1163 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3283 {
3284 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003285 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003286 ;}
3287 break;
3288
3289 case 69:
3290#line 1168 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3291 {
3292 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003293 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003294 ;}
3295 break;
3296
3297 case 70:
3298#line 1174 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3299 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3300 break;
3301
3302 case 71:
3303#line 1175 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3304 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3305 break;
3306
3307 case 72:
3308#line 1176 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3309 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3310 break;
3311
3312 case 73:
3313#line 1177 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3314 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3315 break;
3316
3317 case 74:
3318#line 1178 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3319 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3320 break;
3321
3322 case 75:
3323#line 1182 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3324 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3325 break;
3326
3327 case 76:
3328#line 1183 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3329 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3330 break;
3331
3332 case 77:
3333#line 1184 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3334 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3335 break;
3336
3337 case 78:
3338#line 1188 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3339 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3340 break;
3341
3342 case 79:
3343#line 1189 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3344 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3345 break;
3346
3347 case 80:
3348#line 1190 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3349 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3350 break;
3351
3352 case 81:
3353#line 1191 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3354 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3355 break;
3356
3357 case 82:
3358#line 1195 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3359 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3360 break;
3361
3362 case 83:
3363#line 1196 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3364 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3365 break;
3366
3367 case 84:
3368#line 1197 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3369 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3370 break;
3371
3372 case 85:
3373#line 1201 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3374 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3375 break;
3376
3377 case 86:
3378#line 1202 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3379 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3380 break;
3381
3382 case 87:
3383#line 1203 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3384 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3385 break;
3386
3387 case 88:
3388#line 1204 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3389 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3390 break;
3391
3392 case 89:
3393#line 1205 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3394 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3395 break;
3396
3397 case 90:
3398#line 1209 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3399 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3400 break;
3401
3402 case 91:
3403#line 1210 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3404 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3405 break;
3406
3407 case 92:
3408#line 1211 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3409 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3410 break;
3411
3412 case 93:
3413#line 1214 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3414 { (yyval.UIntVal) = CallingConv::C; ;}
3415 break;
3416
3417 case 94:
3418#line 1215 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3419 { (yyval.UIntVal) = CallingConv::C; ;}
3420 break;
3421
3422 case 95:
3423#line 1216 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3424 { (yyval.UIntVal) = CallingConv::Fast; ;}
3425 break;
3426
3427 case 96:
3428#line 1217 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3429 { (yyval.UIntVal) = CallingConv::Cold; ;}
3430 break;
3431
3432 case 97:
3433#line 1218 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3434 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3435 break;
3436
3437 case 98:
3438#line 1219 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3439 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3440 break;
3441
3442 case 99:
3443#line 1220 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3444 {
3445 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003446 GEN_ERROR("Calling conv too large");
Reid Spencerb8f85052007-07-31 03:50:36 +00003447 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003448 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003449 ;}
3450 break;
3451
3452 case 100:
3453#line 1227 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3454 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3455 break;
3456
3457 case 101:
3458#line 1228 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3459 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3460 break;
3461
3462 case 102:
3463#line 1229 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3464 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3465 break;
3466
3467 case 103:
3468#line 1230 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3469 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3470 break;
3471
3472 case 104:
3473#line 1231 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3474 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3475 break;
3476
3477 case 105:
3478#line 1232 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3479 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3480 break;
3481
3482 case 106:
3483#line 1233 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3484 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3485 break;
3486
3487 case 107:
3488#line 1234 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3489 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3490 break;
3491
3492 case 108:
3493#line 1235 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3494 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3495 break;
3496
3497 case 109:
3498#line 1238 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3499 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3500 break;
3501
3502 case 110:
3503#line 1239 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3504 {
3505 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
3506 ;}
3507 break;
3508
3509 case 111:
3510#line 1244 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3511 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3512 break;
3513
3514 case 112:
3515#line 1245 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3516 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3517 break;
3518
3519 case 113:
3520#line 1246 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3521 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3522 break;
3523
3524 case 114:
3525#line 1247 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3526 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3527 break;
3528
3529 case 115:
3530#line 1250 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3531 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3532 break;
3533
3534 case 116:
3535#line 1251 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3536 {
3537 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
3538 ;}
3539 break;
3540
3541 case 117:
3542#line 1258 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3543 { (yyval.UIntVal) = 0; ;}
3544 break;
3545
3546 case 118:
3547#line 1259 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3548 {
3549 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3550 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003551 GEN_ERROR("Alignment must be a power of two");
3552 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003553;}
3554 break;
3555
3556 case 119:
3557#line 1265 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3558 { (yyval.UIntVal) = 0; ;}
3559 break;
3560
3561 case 120:
3562#line 1266 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3563 {
3564 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3565 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003566 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003567 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003568;}
3569 break;
3570
3571 case 121:
3572#line 1274 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3573 {
3574 for (unsigned i = 0, e = (yyvsp[0].StrVal)->length(); i != e; ++i)
3575 if ((*(yyvsp[0].StrVal))[i] == '"' || (*(yyvsp[0].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003576 GEN_ERROR("Invalid character in section name");
Reid Spencerb8f85052007-07-31 03:50:36 +00003577 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003578 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003579;}
3580 break;
3581
3582 case 122:
3583#line 1282 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3584 { (yyval.StrVal) = 0; ;}
3585 break;
3586
3587 case 123:
3588#line 1283 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3589 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3590 break;
3591
3592 case 124:
3593#line 1288 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3594 {;}
3595 break;
3596
3597 case 125:
3598#line 1289 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3599 {;}
3600 break;
3601
3602 case 126:
3603#line 1290 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3604 {
3605 CurGV->setSection(*(yyvsp[0].StrVal));
3606 delete (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003607 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003608 ;}
3609 break;
3610
3611 case 127:
3612#line 1295 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3613 {
3614 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003615 GEN_ERROR("Alignment must be a power of two");
Reid Spencerb8f85052007-07-31 03:50:36 +00003616 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003617 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003618 ;}
3619 break;
3620
3621 case 132:
3622#line 1311 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3623 {
3624 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003625 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003626 ;}
3627 break;
3628
3629 case 133:
3630#line 1315 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3631 {
3632 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003633 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003634 ;}
3635 break;
3636
3637 case 134:
3638#line 1319 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3639 { // Pointer type?
3640 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003641 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencerb8f85052007-07-31 03:50:36 +00003642 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3643 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003644 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003645 ;}
3646 break;
3647
3648 case 135:
3649#line 1326 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3650 { // Named types are also simple types...
3651 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003652 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003653 (yyval.TypeVal) = new PATypeHolder(tmp);
3654 ;}
3655 break;
3656
3657 case 136:
3658#line 1331 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3659 { // Type UpReference
3660 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003661 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb8f85052007-07-31 03:50:36 +00003662 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3663 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003664 UR_OUT("New Upreference!\n");
3665 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003666 ;}
3667 break;
3668
3669 case 137:
3670#line 1339 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3671 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003672 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003673 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003674 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3675 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003676 Attrs.push_back(X);
3677 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003678 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00003679 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003680 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003681 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003682 Params.push_back(Ty);
3683 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003684 if (I->Attrs != ParamAttr::None) {
3685 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3686 Attrs.push_back(X);
3687 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003688 }
3689 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3690 if (isVarArg) Params.pop_back();
3691
Reid Spencer7b5d4662007-04-09 06:16:21 +00003692 ParamAttrsList *ActualAttrs = 0;
3693 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003694 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencerb8f85052007-07-31 03:50:36 +00003695 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, ActualAttrs);
3696 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3697 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3698 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003699 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003700 ;}
3701 break;
3702
3703 case 138:
3704#line 1369 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3705 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003706 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003707 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003708 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3709 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003710 Attrs.push_back(X);
3711 }
Reid Spencerb8f85052007-07-31 03:50:36 +00003712 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003713 unsigned index = 1;
3714 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003715 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003716 Params.push_back(Ty);
3717 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003718 if (I->Attrs != ParamAttr::None) {
3719 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3720 Attrs.push_back(X);
3721 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003722 }
3723 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3724 if (isVarArg) Params.pop_back();
3725
Reid Spencer7b5d4662007-04-09 06:16:21 +00003726 ParamAttrsList *ActualAttrs = 0;
3727 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003728 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003729
Reid Spencerb8f85052007-07-31 03:50:36 +00003730 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, ActualAttrs);
3731 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3732 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003733 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003734 ;}
3735 break;
3736
3737 case 139:
3738#line 1400 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3739 { // Sized array type?
3740 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3741 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003742 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003743 ;}
3744 break;
3745
3746 case 140:
3747#line 1405 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3748 { // Vector type?
3749 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3750 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003751 GEN_ERROR("Unsigned result not equal to signed result");
3752 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3753 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencerb8f85052007-07-31 03:50:36 +00003754 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003755 GEN_ERROR("Vector length should be a power of 2");
Reid Spencerb8f85052007-07-31 03:50:36 +00003756 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3757 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003758 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003759 ;}
3760 break;
3761
3762 case 141:
3763#line 1417 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3764 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003765 std::vector<const Type*> Elements;
Reid Spencerb8f85052007-07-31 03:50:36 +00003766 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3767 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003768 Elements.push_back(*I);
3769
Reid Spencerb8f85052007-07-31 03:50:36 +00003770 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3771 delete (yyvsp[-1].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003772 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003773 ;}
3774 break;
3775
3776 case 142:
3777#line 1427 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3778 { // Empty structure type?
3779 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003780 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003781 ;}
3782 break;
3783
3784 case 143:
3785#line 1431 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3786 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003787 std::vector<const Type*> Elements;
Reid Spencerb8f85052007-07-31 03:50:36 +00003788 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3789 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003790 Elements.push_back(*I);
3791
Reid Spencerb8f85052007-07-31 03:50:36 +00003792 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3793 delete (yyvsp[-2].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003794 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003795 ;}
3796 break;
3797
3798 case 144:
3799#line 1441 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3800 { // Empty structure type?
3801 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003802 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003803 ;}
3804 break;
3805
3806 case 145:
3807#line 1448 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3808 {
3809 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3810 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3811 ;}
3812 break;
3813
3814 case 146:
3815#line 1455 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3816 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003817 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003818 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3819 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003820 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencerb8f85052007-07-31 03:50:36 +00003821 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3822 ;}
3823 break;
3824
3825 case 147:
3826#line 1462 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3827 {
3828 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3829 ;}
3830 break;
3831
3832 case 148:
3833#line 1467 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3834 {
3835 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3836 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003837 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003838 ;}
3839 break;
3840
3841 case 149:
3842#line 1472 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3843 {
3844 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003845 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003846 ;}
3847 break;
3848
3849 case 151:
3850#line 1480 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3851 {
3852 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003853 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003854 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb8f85052007-07-31 03:50:36 +00003855 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003856 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003857 ;}
3858 break;
3859
3860 case 152:
3861#line 1487 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3862 {
3863 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003864 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3865 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb8f85052007-07-31 03:50:36 +00003866 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003867 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003868 ;}
3869 break;
3870
3871 case 153:
3872#line 1494 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3873 {
3874 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003875 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003876 ;}
3877 break;
3878
3879 case 154:
3880#line 1502 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3881 {
3882 (yyval.TypeList) = new std::list<PATypeHolder>();
3883 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3884 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003885 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003886 ;}
3887 break;
3888
3889 case 155:
3890#line 1508 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3891 {
3892 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3893 delete (yyvsp[0].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003894 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003895 ;}
3896 break;
3897
3898 case 156:
3899#line 1520 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3900 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003901 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003902 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3903 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003904 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003905 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003906 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003907 const Type *ETy = ATy->getElementType();
3908 int NumElements = ATy->getNumElements();
3909
3910 // Verify that we have the correct size...
Reid Spencerb8f85052007-07-31 03:50:36 +00003911 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003912 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003913 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003914 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003915
3916 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00003917 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3918 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003919 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3920 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb8f85052007-07-31 03:50:36 +00003921 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003922 }
3923
Reid Spencerb8f85052007-07-31 03:50:36 +00003924 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3925 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003926 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003927 ;}
3928 break;
3929
3930 case 157:
3931#line 1548 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3932 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003933 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003934 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3935 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003936 if (ATy == 0)
3937 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003938 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003939
Andrew Lenharth6353e052006-12-08 18:07:09 +00003940 int NumElements = ATy->getNumElements();
3941 if (NumElements != -1 && NumElements != 0)
3942 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003943 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencerb8f85052007-07-31 03:50:36 +00003944 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3945 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003946 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003947 ;}
3948 break;
3949
3950 case 158:
3951#line 1564 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3952 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003953 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003954 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3955 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003956 if (ATy == 0)
3957 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003958 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003959
3960 int NumElements = ATy->getNumElements();
3961 const Type *ETy = ATy->getElementType();
Reid Spencerb8f85052007-07-31 03:50:36 +00003962 if (NumElements != -1 && NumElements != int((yyvsp[0].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003963 GEN_ERROR("Can't build string constant of size " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003964 itostr((int)((yyvsp[0].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003965 " when array has size " + itostr(NumElements) + "");
3966 std::vector<Constant*> Vals;
3967 if (ETy == Type::Int8Ty) {
Reid Spencerb8f85052007-07-31 03:50:36 +00003968 for (unsigned i = 0; i < (yyvsp[0].StrVal)->length(); ++i)
3969 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[0].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003970 } else {
Reid Spencerb8f85052007-07-31 03:50:36 +00003971 delete (yyvsp[0].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003972 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3973 }
Reid Spencerb8f85052007-07-31 03:50:36 +00003974 delete (yyvsp[0].StrVal);
3975 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3976 delete (yyvsp[-2].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003977 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003978 ;}
3979 break;
3980
3981 case 159:
3982#line 1591 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3983 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003984 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003985 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3986 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003987 if (PTy == 0)
3988 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003989 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003990 const Type *ETy = PTy->getElementType();
3991 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003992
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003993 // Verify that we have the correct size...
Reid Spencerb8f85052007-07-31 03:50:36 +00003994 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003995 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003996 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003997 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003998
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003999 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00004000 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4001 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004002 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4003 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb8f85052007-07-31 03:50:36 +00004004 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004005 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004006
Reid Spencerb8f85052007-07-31 03:50:36 +00004007 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
4008 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004009 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004010 ;}
4011 break;
4012
4013 case 160:
4014#line 1619 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4015 {
4016 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004017 if (STy == 0)
4018 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004019 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004020
Reid Spencerb8f85052007-07-31 03:50:36 +00004021 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004022 GEN_ERROR("Illegal number of initializers for structure type");
4023
4024 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb8f85052007-07-31 03:50:36 +00004025 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
4026 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004027 GEN_ERROR("Expected type '" +
4028 STy->getElementType(i)->getDescription() +
4029 "' for element #" + utostr(i) +
4030 " of structure initializer");
4031
4032 // Check to ensure that Type is not packed
4033 if (STy->isPacked())
4034 GEN_ERROR("Unpacked Initializer to vector type '" +
4035 STy->getDescription() + "'");
4036
Reid Spencerb8f85052007-07-31 03:50:36 +00004037 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
4038 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004039 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004040 ;}
4041 break;
4042
4043 case 161:
4044#line 1645 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4045 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004046 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004047 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4048 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004049 if (STy == 0)
4050 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004051 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004052
4053 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004054 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004055
4056 // Check to ensure that Type is not packed
4057 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004058 GEN_ERROR("Unpacked Initializer to vector type '" +
4059 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004060
Reid Spencerb8f85052007-07-31 03:50:36 +00004061 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4062 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004063 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004064 ;}
4065 break;
4066
4067 case 162:
4068#line 1665 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4069 {
4070 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004071 if (STy == 0)
4072 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004073 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004074
Reid Spencerb8f85052007-07-31 03:50:36 +00004075 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004076 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004077
4078 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb8f85052007-07-31 03:50:36 +00004079 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
4080 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004081 GEN_ERROR("Expected type '" +
4082 STy->getElementType(i)->getDescription() +
4083 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004084 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004085
4086 // Check to ensure that Type is packed
4087 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004088 GEN_ERROR("Vector initializer to non-vector type '" +
4089 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004090
Reid Spencerb8f85052007-07-31 03:50:36 +00004091 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
4092 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004093 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004094 ;}
4095 break;
4096
4097 case 163:
4098#line 1691 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4099 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004100 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004101 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
4102 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004103 if (STy == 0)
4104 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004105 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004106
4107 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004108 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004109
4110 // Check to ensure that Type is packed
4111 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004112 GEN_ERROR("Vector initializer to non-vector type '" +
4113 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004114
Reid Spencerb8f85052007-07-31 03:50:36 +00004115 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4116 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004117 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004118 ;}
4119 break;
4120
4121 case 164:
4122#line 1711 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4123 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004124 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004125 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4126 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004127 if (PTy == 0)
4128 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004129 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004130
Reid Spencerb8f85052007-07-31 03:50:36 +00004131 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4132 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004133 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004134 ;}
4135 break;
4136
4137 case 165:
4138#line 1723 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4139 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004140 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004141 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4142 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
4143 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004144 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004145 ;}
4146 break;
4147
4148 case 166:
4149#line 1730 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4150 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004151 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004152 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4153 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004154 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004155 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004156
4157 // ConstExprs can exist in the body of a function, thus creating
4158 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004159 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004160 // symbol table instead of the module symbol table for the global symbol,
4161 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004162 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004163 //
4164 Function *SavedCurFn = CurFun.CurrentFunction;
4165 CurFun.CurrentFunction = 0;
4166
Reid Spencerb8f85052007-07-31 03:50:36 +00004167 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004168 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004169
4170 CurFun.CurrentFunction = SavedCurFn;
4171
4172 // If this is an initializer for a constant pointer, which is referencing a
4173 // (currently) undefined variable, create a stub now that shall be replaced
4174 // in the future with the right type of variable.
4175 //
4176 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004177 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004178 const PointerType *PT = cast<PointerType>(Ty);
4179
4180 // First check to see if the forward references value is already created!
4181 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb8f85052007-07-31 03:50:36 +00004182 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004183
4184 if (I != CurModule.GlobalRefs.end()) {
4185 V = I->second; // Placeholder already exists, use it...
Reid Spencerb8f85052007-07-31 03:50:36 +00004186 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004187 } else {
4188 std::string Name;
Reid Spencerb8f85052007-07-31 03:50:36 +00004189 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4190 Name = (yyvsp[0].ValIDVal).getName();
4191 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004192 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004193
4194 // Create the forward referenced global.
4195 GlobalValue *GV;
4196 if (const FunctionType *FTy =
4197 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004198 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004199 CurModule.CurrentModule);
4200 } else {
4201 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004202 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004203 Name, CurModule.CurrentModule);
4204 }
4205
4206 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb8f85052007-07-31 03:50:36 +00004207 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208 V = GV;
4209 }
4210 }
4211
Reid Spencerb8f85052007-07-31 03:50:36 +00004212 (yyval.ConstVal) = cast<GlobalValue>(V);
4213 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004214 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004215 ;}
4216 break;
4217
4218 case 167:
4219#line 1796 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4220 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004221 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004222 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4223 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004224 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00004225 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4226 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4227 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004228 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004229 ;}
4230 break;
4231
4232 case 168:
4233#line 1806 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4234 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004235 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004236 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4237 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004238 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4239 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004240 (yyval.ConstVal) = Constant::getNullValue(Ty);
4241 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004242 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004243 ;}
4244 break;
4245
4246 case 169:
4247#line 1816 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4248 { // integral constants
4249 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004250 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004251 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004252 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004253 ;}
4254 break;
4255
4256 case 170:
4257#line 1822 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4258 { // arbitrary precision integer constants
4259 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4260 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004261 GEN_ERROR("Constant value does not fit in type");
4262 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004263 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4264 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4265 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004266 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004267 ;}
4268 break;
4269
4270 case 171:
4271#line 1832 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4272 { // integral constants
4273 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004274 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004275 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004276 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004277 ;}
4278 break;
4279
4280 case 172:
4281#line 1838 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4282 { // arbitrary precision integer constants
4283 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4284 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004285 GEN_ERROR("Constant value does not fit in type");
4286 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004287 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4288 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4289 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004290 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004291 ;}
4292 break;
4293
4294 case 173:
4295#line 1848 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4296 { // Boolean constants
4297 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4298 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004299 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004300 ;}
4301 break;
4302
4303 case 174:
4304#line 1853 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4305 { // Boolean constants
4306 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4307 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004308 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004309 ;}
4310 break;
4311
4312 case 175:
4313#line 1858 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4314 { // Float & Double constants
4315 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004316 GEN_ERROR("Floating point constant invalid for type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004317 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004318 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004319 ;}
4320 break;
4321
4322 case 176:
4323#line 1866 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4324 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004325 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004326 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4327 Constant *Val = (yyvsp[-3].ConstVal);
4328 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4329 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004330 GEN_ERROR("invalid cast opcode for cast from '" +
4331 Val->getType()->getDescription() + "' to '" +
4332 DestTy->getDescription() + "'");
Reid Spencerb8f85052007-07-31 03:50:36 +00004333 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4334 delete (yyvsp[-1].TypeVal);
4335 ;}
4336 break;
4337
4338 case 177:
4339#line 1878 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4340 {
4341 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004342 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004343
4344 const Type *IdxTy =
Reid Spencerb8f85052007-07-31 03:50:36 +00004345 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004346 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004347 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004348 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004349
Chris Lattnerf7469af2007-01-31 04:44:08 +00004350 SmallVector<Constant*, 8> IdxVec;
Reid Spencerb8f85052007-07-31 03:50:36 +00004351 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4352 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004353 IdxVec.push_back(C);
4354 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004355 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004356
Reid Spencerb8f85052007-07-31 03:50:36 +00004357 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004358
Reid Spencerb8f85052007-07-31 03:50:36 +00004359 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004360 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004361 ;}
4362 break;
4363
4364 case 178:
4365#line 1900 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4366 {
4367 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004368 GEN_ERROR("Select condition must be of boolean type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004369 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004370 GEN_ERROR("Select operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004371 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004372 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004373 ;}
4374 break;
4375
4376 case 179:
4377#line 1908 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4378 {
4379 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004380 GEN_ERROR("Binary operator types must match");
4381 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004382 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4383 ;}
4384 break;
4385
4386 case 180:
4387#line 1914 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4388 {
4389 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004390 GEN_ERROR("Logical operator types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004391 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4392 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4393 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004394 GEN_ERROR("Logical operator requires integral operands");
4395 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004396 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004397 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004398 ;}
4399 break;
4400
4401 case 181:
4402#line 1925 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4403 {
4404 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004405 GEN_ERROR("icmp operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004406 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4407 ;}
4408 break;
4409
4410 case 182:
4411#line 1930 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4412 {
4413 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004414 GEN_ERROR("fcmp operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004415 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4416 ;}
4417 break;
4418
4419 case 183:
4420#line 1935 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4421 {
4422 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004423 GEN_ERROR("Invalid extractelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004424 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004425 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004426 ;}
4427 break;
4428
4429 case 184:
4430#line 1941 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4431 {
4432 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004433 GEN_ERROR("Invalid insertelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004434 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004435 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004436 ;}
4437 break;
4438
4439 case 185:
4440#line 1947 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4441 {
4442 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004443 GEN_ERROR("Invalid shufflevector operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004444 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004445 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004446 ;}
4447 break;
4448
4449 case 186:
4450#line 1956 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4451 {
4452 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004453 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004454 ;}
4455 break;
4456
4457 case 187:
4458#line 1960 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4459 {
4460 (yyval.ConstVector) = new std::vector<Constant*>();
4461 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004462 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004463 ;}
4464 break;
4465
4466 case 188:
4467#line 1968 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4468 { (yyval.BoolVal) = false; ;}
4469 break;
4470
4471 case 189:
4472#line 1968 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4473 { (yyval.BoolVal) = true; ;}
4474 break;
4475
4476 case 190:
4477#line 1971 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4478 { (yyval.BoolVal) = true; ;}
4479 break;
4480
4481 case 191:
4482#line 1971 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4483 { (yyval.BoolVal) = false; ;}
4484 break;
4485
4486 case 192:
4487#line 1974 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4488 {
4489 const Type* VTy = (yyvsp[-1].TypeVal)->get();
4490 Value *V = getVal(VTy, (yyvsp[0].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004491 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4492 if (!Aliasee)
4493 GEN_ERROR("Aliases can be created only to global values");
4494
Reid Spencerb8f85052007-07-31 03:50:36 +00004495 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004496 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004497 delete (yyvsp[-1].TypeVal);
4498 ;}
4499 break;
4500
4501 case 193:
4502#line 1985 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4503 {
4504 Constant *Val = (yyvsp[-3].ConstVal);
4505 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4506 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004507 GEN_ERROR("invalid cast opcode for cast from '" +
4508 Val->getType()->getDescription() + "' to '" +
4509 DestTy->getDescription() + "'");
4510
Reid Spencerb8f85052007-07-31 03:50:36 +00004511 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004512 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004513 delete (yyvsp[-1].TypeVal);
4514 ;}
4515 break;
4516
4517 case 194:
4518#line 2006 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4519 {
4520 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004521 CurModule.ModuleDone();
4522 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004523 ;}
4524 break;
4525
4526 case 195:
4527#line 2011 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4528 {
4529 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004530 CurModule.ModuleDone();
4531 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004532 ;}
4533 break;
4534
4535 case 198:
4536#line 2024 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4537 { CurFun.isDeclare = false; ;}
4538 break;
4539
4540 case 199:
4541#line 2024 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4542 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004543 CurFun.FunctionDone();
4544 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004545 ;}
4546 break;
4547
4548 case 200:
4549#line 2028 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4550 { CurFun.isDeclare = true; ;}
4551 break;
4552
4553 case 201:
4554#line 2028 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4555 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004556 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004557 ;}
4558 break;
4559
4560 case 202:
4561#line 2031 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4562 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004563 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004564 ;}
4565 break;
4566
4567 case 203:
4568#line 2034 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4569 {
Reid Spencer14310612006-12-31 05:40:51 +00004570 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004571 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004572 // Eagerly resolve types. This is not an optimization, this is a
4573 // requirement that is due to the fact that we could have this:
4574 //
4575 // %list = type { %list * }
4576 // %list = type { %list * } ; repeated type decl
4577 //
4578 // If types are not resolved eagerly, then the two types will not be
4579 // determined to be the same type!
4580 //
Reid Spencerb8f85052007-07-31 03:50:36 +00004581 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004582
Reid Spencerb8f85052007-07-31 03:50:36 +00004583 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004584 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004585 // If this is a named type that is not a redefinition, add it to the slot
4586 // table.
Reid Spencerb8f85052007-07-31 03:50:36 +00004587 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004588 }
Reid Spencera132e042006-12-03 05:46:11 +00004589
Reid Spencerb8f85052007-07-31 03:50:36 +00004590 delete (yyvsp[0].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004591 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004592 ;}
4593 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004594
Reid Spencerb8f85052007-07-31 03:50:36 +00004595 case 204:
4596#line 2058 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4597 {
4598 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4599
4600 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004601 CHECK_FOR_ERROR
4602 // If this is a named type that is not a redefinition, add it to the slot
4603 // table.
Reid Spencerb8f85052007-07-31 03:50:36 +00004604 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004605 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004606 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004607 ;}
4608 break;
4609
4610 case 205:
4611#line 2069 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4612 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004613 /* "Externally Visible" Linkage */
Reid Spencerb8f85052007-07-31 03:50:36 +00004614 if ((yyvsp[0].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004615 GEN_ERROR("Global value initializer is not a constant");
Reid Spencerb8f85052007-07-31 03:50:36 +00004616 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), GlobalValue::ExternalLinkage,
4617 (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004618 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004619 ;}
4620 break;
4621
4622 case 206:
4623#line 2076 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4624 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004625 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004626 ;}
4627 break;
4628
4629 case 207:
4630#line 2080 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4631 {
4632 if ((yyvsp[0].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004633 GEN_ERROR("Global value initializer is not a constant");
Reid Spencerb8f85052007-07-31 03:50:36 +00004634 CurGV = ParseGlobalVariable((yyvsp[-5].StrVal), (yyvsp[-4].Linkage), (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004635 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004636 ;}
4637 break;
4638
4639 case 208:
4640#line 2085 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4641 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004642 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004643 ;}
4644 break;
4645
4646 case 209:
4647#line 2089 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4648 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004649 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004650 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4651 CurGV = ParseGlobalVariable((yyvsp[-5].StrVal), (yyvsp[-4].Linkage), (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0, (yyvsp[-2].BoolVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004652 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004653 delete (yyvsp[0].TypeVal);
4654 ;}
4655 break;
4656
4657 case 210:
4658#line 2095 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4659 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004660 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004661 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004662 ;}
4663 break;
4664
4665 case 211:
4666#line 2099 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4667 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004668 std::string Name;
Reid Spencerb8f85052007-07-31 03:50:36 +00004669 if ((yyvsp[-4].StrVal)) {
4670 Name = *(yyvsp[-4].StrVal);
4671 delete (yyvsp[-4].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004672 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004673 if (Name.empty())
4674 GEN_ERROR("Alias name cannot be empty");
4675
Reid Spencerb8f85052007-07-31 03:50:36 +00004676 Constant* Aliasee = (yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004677 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004678 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004679
Reid Spencerb8f85052007-07-31 03:50:36 +00004680 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[-1].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004681 CurModule.CurrentModule);
Reid Spencerb8f85052007-07-31 03:50:36 +00004682 GA->setVisibility((yyvsp[-3].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004683 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004684 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004685 ;}
4686 break;
4687
4688 case 212:
4689#line 2118 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4690 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004691 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004692 ;}
4693 break;
4694
4695 case 213:
4696#line 2121 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4697 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004698 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004699 ;}
4700 break;
4701
4702 case 214:
4703#line 2127 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4704 {
Chris Lattner66316012006-01-24 04:14:29 +00004705 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00004706 if (AsmSoFar.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004707 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004708 else
Reid Spencerb8f85052007-07-31 03:50:36 +00004709 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[0].StrVal));
4710 delete (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004711 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004712;}
4713 break;
4714
4715 case 215:
4716#line 2137 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4717 {
4718 CurModule.CurrentModule->setTargetTriple(*(yyvsp[0].StrVal));
4719 delete (yyvsp[0].StrVal);
4720 ;}
4721 break;
4722
4723 case 216:
4724#line 2141 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4725 {
4726 CurModule.CurrentModule->setDataLayout(*(yyvsp[0].StrVal));
4727 delete (yyvsp[0].StrVal);
4728 ;}
4729 break;
4730
4731 case 218:
4732#line 2148 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4733 {
4734 CurModule.CurrentModule->addLibrary(*(yyvsp[0].StrVal));
4735 delete (yyvsp[0].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004736 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004737 ;}
4738 break;
4739
4740 case 219:
4741#line 2153 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4742 {
4743 CurModule.CurrentModule->addLibrary(*(yyvsp[0].StrVal));
4744 delete (yyvsp[0].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004745 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004746 ;}
4747 break;
4748
4749 case 220:
4750#line 2158 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4751 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004752 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004753 ;}
4754 break;
4755
4756 case 221:
4757#line 2167 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4758 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004759 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004760 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4761 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004762 GEN_ERROR("void typed arguments are invalid");
Reid Spencerb8f85052007-07-31 03:50:36 +00004763 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4764 (yyval.ArgList) = (yyvsp[-4].ArgList);
4765 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004766 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004767 ;}
4768 break;
4769
4770 case 222:
4771#line 2177 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4772 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004773 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004774 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4775 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004776 GEN_ERROR("void typed arguments are invalid");
Reid Spencerb8f85052007-07-31 03:50:36 +00004777 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4778 (yyval.ArgList) = new ArgListType;
4779 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004780 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004781 ;}
4782 break;
4783
4784 case 223:
4785#line 2188 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4786 {
4787 (yyval.ArgList) = (yyvsp[0].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004788 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004789 ;}
4790 break;
4791
4792 case 224:
4793#line 2192 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4794 {
4795 (yyval.ArgList) = (yyvsp[-2].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004796 struct ArgListEntry E;
4797 E.Ty = new PATypeHolder(Type::VoidTy);
4798 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004799 E.Attrs = ParamAttr::None;
Reid Spencerb8f85052007-07-31 03:50:36 +00004800 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004801 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004802 ;}
4803 break;
4804
4805 case 225:
4806#line 2201 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4807 {
4808 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004809 struct ArgListEntry E;
4810 E.Ty = new PATypeHolder(Type::VoidTy);
4811 E.Name = 0;
4812 E.Attrs = ParamAttr::None;
Reid Spencerb8f85052007-07-31 03:50:36 +00004813 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004814 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004815 ;}
4816 break;
4817
4818 case 226:
4819#line 2210 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4820 {
4821 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004822 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004823 ;}
4824 break;
4825
4826 case 227:
4827#line 2216 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4828 {
4829 std::string FunctionName(*(yyvsp[-6].StrVal));
4830 delete (yyvsp[-6].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004831
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004832 // Check the function result for abstractness if this is a define. We should
4833 // have no abstract types at this point
Reid Spencerb8f85052007-07-31 03:50:36 +00004834 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4835 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004836
Reid Spencer68a24bd2005-08-27 18:50:39 +00004837 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004838 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00004839 if ((yyvsp[-2].ParamAttrs) != ParamAttr::None) {
4840 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[-2].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00004841 Attrs.push_back(PAWI);
4842 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004843 if ((yyvsp[-4].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004844 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00004845 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004846 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004847 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4848 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004849 ParamTypeList.push_back(Ty);
4850 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004851 if (I->Attrs != ParamAttr::None) {
4852 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4853 Attrs.push_back(PAWI);
4854 }
Reid Spencer14310612006-12-31 05:40:51 +00004855 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004856 }
4857
4858 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4859 if (isVarArg) ParamTypeList.pop_back();
4860
Christopher Lamb5c104242007-04-22 20:09:11 +00004861 ParamAttrsList *PAL = 0;
4862 if (!Attrs.empty())
4863 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004864
Reid Spencerb8f85052007-07-31 03:50:36 +00004865 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004866 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb8f85052007-07-31 03:50:36 +00004867 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004868
4869 ValID ID;
4870 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004871 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004872 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004873 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004874 }
4875
4876 Function *Fn = 0;
4877 // See if this function was forward referenced. If so, recycle the object.
4878 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4879 // Move the function to the end of the list, from whereever it was
4880 // previously inserted.
4881 Fn = cast<Function>(FWRef);
4882 CurModule.CurrentModule->getFunctionList().remove(Fn);
4883 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4884 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004885 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004886 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004887 // The existing function doesn't have the same type. This is an overload
4888 // error.
4889 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4890 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004891 // Neither the existing or the current function is a declaration and they
4892 // have the same name and same type. Clearly this is a redefinition.
4893 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004894 } if (Fn->isDeclaration()) {
4895 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004896 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4897 AI != AE; ++AI)
4898 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004899 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004900 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004901 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004902 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004903
Reid Spencer68a24bd2005-08-27 18:50:39 +00004904 InsertValue(Fn, CurModule.Values);
4905 }
4906
4907 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004908
4909 if (CurFun.isDeclare) {
4910 // If we have declaration, always overwrite linkage. This will allow us to
4911 // correctly handle cases, when pointer to function is passed as argument to
4912 // another function.
4913 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004914 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004915 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004916 Fn->setCallingConv((yyvsp[-8].UIntVal));
4917 Fn->setAlignment((yyvsp[0].UIntVal));
4918 if ((yyvsp[-1].StrVal)) {
4919 Fn->setSection(*(yyvsp[-1].StrVal));
4920 delete (yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00004921 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004922
4923 // Add all of the arguments we parsed to the function...
Reid Spencerb8f85052007-07-31 03:50:36 +00004924 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004925 if (isVarArg) { // Nuke the last entry
Reid Spencerb8f85052007-07-31 03:50:36 +00004926 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004927 "Not a varargs marker!");
Reid Spencerb8f85052007-07-31 03:50:36 +00004928 delete (yyvsp[-4].ArgList)->back().Ty;
4929 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004930 }
4931 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004932 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004933 unsigned Idx = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00004934 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4935 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004936 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004937 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004938 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004939 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004940 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004941 }
Reid Spencera132e042006-12-03 05:46:11 +00004942
Reid Spencerb8f85052007-07-31 03:50:36 +00004943 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004944 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004945 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004946;}
4947 break;
4948
4949 case 230:
4950#line 2338 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4951 {
4952 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004953
4954 // Make sure that we keep track of the linkage type even if there was a
4955 // previous "declare".
Reid Spencerb8f85052007-07-31 03:50:36 +00004956 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4957 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4958;}
4959 break;
4960
4961 case 233:
4962#line 2349 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4963 {
4964 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004965 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004966;}
4967 break;
4968
4969 case 234:
4970#line 2354 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4971 {
4972 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4973 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4974 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004975 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004976 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004977 ;}
4978 break;
4979
4980 case 235:
4981#line 2366 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4982 {
4983 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004984 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004985 ;}
4986 break;
4987
4988 case 236:
4989#line 2370 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4990 {
4991 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004992 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004993 ;}
4994 break;
4995
4996 case 237:
4997#line 2375 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4998 { // A reference to a direct constant
4999 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005000 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005001 ;}
5002 break;
5003
5004 case 238:
5005#line 2379 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5006 {
5007 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005008 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005009 ;}
5010 break;
5011
5012 case 239:
5013#line 2383 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5014 { // Perhaps it's an FP constant?
5015 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005016 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005017 ;}
5018 break;
5019
5020 case 240:
5021#line 2387 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5022 {
5023 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005024 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005025 ;}
5026 break;
5027
5028 case 241:
5029#line 2391 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5030 {
5031 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005032 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005033 ;}
5034 break;
5035
5036 case 242:
5037#line 2395 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5038 {
5039 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005040 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005041 ;}
5042 break;
5043
5044 case 243:
5045#line 2399 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5046 {
5047 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005048 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005049 ;}
5050 break;
5051
5052 case 244:
5053#line 2403 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5054 { // A vector zero constant.
5055 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005056 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005057 ;}
5058 break;
5059
5060 case 245:
5061#line 2407 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5062 { // Nonempty unsized packed vector
5063 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
5064 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005065
Reid Spencer9d6565a2007-02-15 02:26:10 +00005066 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005067 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005068 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005069 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005070 ETy,
5071 NumElements)
5072 )
5073 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005074
5075 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00005076 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5077 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005078 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005079 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00005080 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005081 }
5082
Reid Spencerb8f85052007-07-31 03:50:36 +00005083 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
5084 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005085 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005086 ;}
5087 break;
5088
5089 case 246:
5090#line 2432 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5091 {
5092 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005093 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005094 ;}
5095 break;
5096
5097 case 247:
5098#line 2436 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5099 {
5100 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[-2].StrVal), *(yyvsp[0].StrVal), (yyvsp[-3].BoolVal));
5101 delete (yyvsp[-2].StrVal);
5102 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005103 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005104 ;}
5105 break;
5106
5107 case 248:
5108#line 2446 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5109 { // Is it an integer reference...?
5110 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005111 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005112 ;}
5113 break;
5114
5115 case 249:
5116#line 2450 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5117 {
5118 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005119 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005120 ;}
5121 break;
5122
5123 case 250:
5124#line 2454 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5125 { // Is it a named reference...?
5126 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[0].StrVal));
5127 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005128 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005129 ;}
5130 break;
5131
5132 case 251:
5133#line 2459 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5134 { // Is it a named reference...?
5135 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[0].StrVal));
5136 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005137 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005138 ;}
5139 break;
5140
5141 case 254:
5142#line 2472 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5143 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005144 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005145 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5146 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
5147 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005148 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005149 ;}
5150 break;
5151
5152 case 255:
5153#line 2481 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5154 {
5155 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005156 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005157 ;}
5158 break;
5159
5160 case 256:
5161#line 2485 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5162 { // Do not allow functions with 0 basic blocks
5163 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005164 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005165 ;}
5166 break;
5167
5168 case 257:
5169#line 2494 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5170 {
5171 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005172 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005173 InsertValue((yyvsp[0].TermInstVal));
5174 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5175 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005176 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005177 ;}
5178 break;
5179
5180 case 258:
5181#line 2503 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5182 {
5183 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005184 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5185 if (CI2->getParent() == 0)
Reid Spencerb8f85052007-07-31 03:50:36 +00005186 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
5187 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
5188 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005189 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005190 ;}
5191 break;
5192
5193 case 259:
5194#line 2512 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5195 { // Empty space between instruction lists
5196 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00005197 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005198 ;}
5199 break;
5200
5201 case 260:
5202#line 2516 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5203 { // Labelled (named) basic block
5204 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[0].StrVal)));
5205 delete (yyvsp[0].StrVal);
Reid Spencered951ea2007-05-19 07:22:10 +00005206 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005207
Reid Spencerb8f85052007-07-31 03:50:36 +00005208 ;}
5209 break;
Reid Spencered951ea2007-05-19 07:22:10 +00005210
Reid Spencerb8f85052007-07-31 03:50:36 +00005211 case 261:
5212#line 2523 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5213 { // Return with a result...
5214 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
5215 CHECK_FOR_ERROR
5216 ;}
5217 break;
5218
5219 case 262:
5220#line 2527 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5221 { // Return with no result...
5222 (yyval.TermInstVal) = new ReturnInst();
5223 CHECK_FOR_ERROR
5224 ;}
5225 break;
5226
5227 case 263:
5228#line 2531 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5229 { // Unconditional Branch...
5230 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5231 CHECK_FOR_ERROR
5232 (yyval.TermInstVal) = new BranchInst(tmpBB);
5233 ;}
5234 break;
5235
5236 case 264:
5237#line 2536 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5238 {
5239 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5240 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5241 CHECK_FOR_ERROR
5242 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5243 CHECK_FOR_ERROR
5244 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5245 CHECK_FOR_ERROR
5246 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5247 ;}
5248 break;
5249
5250 case 265:
5251#line 2546 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5252 {
5253 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5254 CHECK_FOR_ERROR
5255 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5256 CHECK_FOR_ERROR
5257 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5258 (yyval.TermInstVal) = S;
5259
5260 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5261 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005262 for (; I != E; ++I) {
5263 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5264 S->addCase(CI, I->second);
5265 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005266 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005268 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005269 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005270 ;}
5271 break;
5272
5273 case 266:
5274#line 2565 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5275 {
5276 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005277 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005278 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005279 CHECK_FOR_ERROR
5280 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerb8f85052007-07-31 03:50:36 +00005281 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005282 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005283 ;}
5284 break;
5285
5286 case 267:
5287#line 2575 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5288 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005289
Reid Spencer14310612006-12-31 05:40:51 +00005290 // Handle the short syntax
5291 const PointerType *PFTy = 0;
5292 const FunctionType *Ty = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005293 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005294 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5295 // Pull out the types of all of the arguments...
5296 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005297 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005298 if ((yyvsp[-6].ParamAttrs) != ParamAttr::None) {
5299 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[-6].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005300 Attrs.push_back(PAWI);
5301 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005302 ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005303 unsigned index = 1;
5304 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005305 const Type *Ty = I->Val->getType();
5306 if (Ty == Type::VoidTy)
5307 GEN_ERROR("Short call syntax cannot be used with varargs");
5308 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005309 if (I->Attrs != ParamAttr::None) {
5310 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5311 Attrs.push_back(PAWI);
5312 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005313 }
5314
Christopher Lamb5c104242007-04-22 20:09:11 +00005315 ParamAttrsList *PAL = 0;
5316 if (!Attrs.empty())
5317 PAL = ParamAttrsList::get(Attrs);
Reid Spencerb8f85052007-07-31 03:50:36 +00005318 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005319 PFTy = PointerType::get(Ty);
5320 }
5321
Reid Spencerb8f85052007-07-31 03:50:36 +00005322 delete (yyvsp[-11].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005323
Reid Spencerb8f85052007-07-31 03:50:36 +00005324 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005325 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005326 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005327 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005328 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005329 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005330
Reid Spencer14310612006-12-31 05:40:51 +00005331 // Check the arguments
5332 ValueList Args;
Reid Spencerb8f85052007-07-31 03:50:36 +00005333 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005334 // Make sure no arguments is a good thing!
5335 if (Ty->getNumParams() != 0)
5336 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005337 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005338 } else { // Has arguments?
5339 // Loop through FunctionType's arguments and ensure they are specified
5340 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005341 FunctionType::param_iterator I = Ty->param_begin();
5342 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb8f85052007-07-31 03:50:36 +00005343 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005344
Reid Spencer14310612006-12-31 05:40:51 +00005345 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5346 if (ArgI->Val->getType() != *I)
5347 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005348 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005349 Args.push_back(ArgI->Val);
5350 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005351
Reid Spencer14310612006-12-31 05:40:51 +00005352 if (Ty->isVarArg()) {
5353 if (I == E)
5354 for (; ArgI != ArgE; ++ArgI)
5355 Args.push_back(ArgI->Val); // push the remaining varargs
5356 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005357 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005358 }
Reid Spencer14310612006-12-31 05:40:51 +00005359
5360 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005361 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencerb8f85052007-07-31 03:50:36 +00005362 II->setCallingConv((yyvsp[-12].UIntVal));
5363 (yyval.TermInstVal) = II;
5364 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005365 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005366 ;}
5367 break;
5368
5369 case 268:
5370#line 2654 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5371 {
5372 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005373 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005374 ;}
5375 break;
5376
5377 case 269:
5378#line 2658 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5379 {
5380 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005381 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005382 ;}
5383 break;
5384
5385 case 270:
5386#line 2665 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5387 {
5388 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5389 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005390 CHECK_FOR_ERROR
5391 if (V == 0)
5392 GEN_ERROR("May only switch on a constant pool value");
5393
Reid Spencerb8f85052007-07-31 03:50:36 +00005394 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005395 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005396 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5397 ;}
5398 break;
5399
5400 case 271:
5401#line 2676 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5402 {
5403 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5404 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005405 CHECK_FOR_ERROR
5406
5407 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005408 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005409
Reid Spencerb8f85052007-07-31 03:50:36 +00005410 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005411 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005412 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5413 ;}
5414 break;
5415
5416 case 272:
5417#line 2689 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5418 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005419 // Is this definition named?? if so, assign the name...
Reid Spencerb8f85052007-07-31 03:50:36 +00005420 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005421 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005422 InsertValue((yyvsp[0].InstVal));
5423 (yyval.InstVal) = (yyvsp[0].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005424 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005425 ;}
5426 break;
5427
5428 case 273:
5429#line 2699 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5430 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005431 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005432 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5433 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5434 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005435 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005436 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005437 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005438 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5439 delete (yyvsp[-5].TypeVal);
5440 ;}
5441 break;
5442
5443 case 274:
5444#line 2710 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5445 {
5446 (yyval.PHIList) = (yyvsp[-6].PHIList);
5447 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005448 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005449 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005450 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005451 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5452 ;}
5453 break;
5454
5455 case 275:
5456#line 2720 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5457 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005458 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005459 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005460 // Used for call and invoke instructions
Reid Spencerb8f85052007-07-31 03:50:36 +00005461 (yyval.ValueRefList) = new ValueRefList();
5462 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5463 (yyval.ValueRefList)->push_back(E);
5464 delete (yyvsp[-2].TypeVal);
5465 ;}
5466 break;
5467
5468 case 276:
5469#line 2729 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5470 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005471 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005472 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5473 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5474 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5475 (yyval.ValueRefList)->push_back(E);
5476 delete (yyvsp[-2].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005477 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005478 ;}
5479 break;
5480
5481 case 277:
5482#line 2738 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5483 { (yyval.ValueRefList) = new ValueRefList(); ;}
5484 break;
5485
5486 case 278:
5487#line 2741 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5488 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5489 break;
5490
5491 case 279:
5492#line 2742 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5493 {
5494 (yyval.ValueList) = (yyvsp[-2].ValueList);
5495 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005496 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005497 ;}
5498 break;
5499
5500 case 280:
5501#line 2749 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5502 {
5503 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005504 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005505 ;}
5506 break;
5507
5508 case 281:
5509#line 2753 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5510 {
5511 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005512 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005513 ;}
5514 break;
5515
5516 case 282:
5517#line 2758 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5518 {
Reid Spencer14310612006-12-31 05:40:51 +00005519 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005520 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5521 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5522 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005523 GEN_ERROR(
5524 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005525 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5526 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5527 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5528 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005529 GEN_ERROR("Remainder not supported on vector types");
Reid Spencerb8f85052007-07-31 03:50:36 +00005530 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005531 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005532 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005533 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005534 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5535 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005536 GEN_ERROR("binary operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005537 delete (yyvsp[-3].TypeVal);
5538 ;}
5539 break;
5540
5541 case 283:
5542#line 2779 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5543 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005544 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005545 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5546 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5547 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5548 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005549 GEN_ERROR("Logical operator requires integral operands");
5550 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005551 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005552 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005553 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005554 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005555 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5556 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005557 GEN_ERROR("binary operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005558 delete (yyvsp[-3].TypeVal);
5559 ;}
5560 break;
5561
5562 case 284:
5563#line 2796 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5564 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005565 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005566 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5567 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005568 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencerb8f85052007-07-31 03:50:36 +00005569 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005570 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005571 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005572 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005573 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5574 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005575 GEN_ERROR("icmp operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005576 delete (yyvsp[-3].TypeVal);
5577 ;}
5578 break;
5579
5580 case 285:
5581#line 2810 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5582 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005583 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005584 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5585 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005586 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencerb8f85052007-07-31 03:50:36 +00005587 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005588 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005589 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005590 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005591 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5592 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005593 GEN_ERROR("fcmp operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005594 delete (yyvsp[-3].TypeVal);
5595 ;}
5596 break;
5597
5598 case 286:
5599#line 2824 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5600 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005601 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005602 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5603 Value* Val = (yyvsp[-2].ValueVal);
5604 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5605 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005606 GEN_ERROR("invalid cast opcode for cast from '" +
5607 Val->getType()->getDescription() + "' to '" +
5608 DestTy->getDescription() + "'");
Reid Spencerb8f85052007-07-31 03:50:36 +00005609 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5610 delete (yyvsp[0].TypeVal);
5611 ;}
5612 break;
5613
5614 case 287:
5615#line 2836 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5616 {
5617 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005618 GEN_ERROR("select condition must be boolean");
Reid Spencerb8f85052007-07-31 03:50:36 +00005619 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005620 GEN_ERROR("select value types should match");
Reid Spencerb8f85052007-07-31 03:50:36 +00005621 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005622 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005623 ;}
5624 break;
5625
5626 case 288:
5627#line 2844 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5628 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005629 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005630 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5631 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5632 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005633 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005634 ;}
5635 break;
5636
5637 case 289:
5638#line 2851 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5639 {
5640 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005641 GEN_ERROR("Invalid extractelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005642 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005643 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005644 ;}
5645 break;
5646
5647 case 290:
5648#line 2857 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5649 {
5650 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005651 GEN_ERROR("Invalid insertelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005652 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005653 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005654 ;}
5655 break;
5656
5657 case 291:
5658#line 2863 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5659 {
5660 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005661 GEN_ERROR("Invalid shufflevector operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005662 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005663 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005664 ;}
5665 break;
5666
5667 case 292:
5668#line 2869 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5669 {
5670 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005671 if (!Ty->isFirstClassType())
5672 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencerb8f85052007-07-31 03:50:36 +00005673 (yyval.InstVal) = new PHINode(Ty);
5674 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5675 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5676 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005677 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencerb8f85052007-07-31 03:50:36 +00005678 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5679 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005680 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005681 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005682 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005683 ;}
5684 break;
5685
5686 case 293:
5687#line 2885 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5688 {
Reid Spencer14310612006-12-31 05:40:51 +00005689
5690 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005691 const PointerType *PFTy = 0;
5692 const FunctionType *Ty = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005693 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005694 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5695 // Pull out the types of all of the arguments...
5696 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005697 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005698 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
5699 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005700 Attrs.push_back(PAWI);
5701 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005702 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00005703 ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005704 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005705 const Type *Ty = I->Val->getType();
5706 if (Ty == Type::VoidTy)
5707 GEN_ERROR("Short call syntax cannot be used with varargs");
5708 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005709 if (I->Attrs != ParamAttr::None) {
5710 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5711 Attrs.push_back(PAWI);
5712 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005713 }
5714
Christopher Lamb5c104242007-04-22 20:09:11 +00005715 ParamAttrsList *PAL = 0;
5716 if (!Attrs.empty())
5717 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005718
Reid Spencerb8f85052007-07-31 03:50:36 +00005719 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005720 PFTy = PointerType::get(Ty);
5721 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005722
Reid Spencerb8f85052007-07-31 03:50:36 +00005723 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005724 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005725
Reid Spencer7780acb2007-04-16 06:56:07 +00005726 // Check for call to invalid intrinsic to avoid crashing later.
5727 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005728 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005729 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5730 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005731 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5732 theF->getName() + "'");
5733 }
5734
Reid Spencer14310612006-12-31 05:40:51 +00005735 // Check the arguments
5736 ValueList Args;
Reid Spencerb8f85052007-07-31 03:50:36 +00005737 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005738 // Make sure no arguments is a good thing!
5739 if (Ty->getNumParams() != 0)
5740 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005741 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005742 } else { // Has arguments?
5743 // Loop through FunctionType's arguments and ensure they are specified
5744 // correctly!
5745 //
5746 FunctionType::param_iterator I = Ty->param_begin();
5747 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb8f85052007-07-31 03:50:36 +00005748 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005749
Reid Spencer14310612006-12-31 05:40:51 +00005750 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5751 if (ArgI->Val->getType() != *I)
5752 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005753 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005754 Args.push_back(ArgI->Val);
5755 }
5756 if (Ty->isVarArg()) {
5757 if (I == E)
5758 for (; ArgI != ArgE; ++ArgI)
5759 Args.push_back(ArgI->Val); // push the remaining varargs
5760 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005761 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005762 }
Reid Spencer14310612006-12-31 05:40:51 +00005763 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005764 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencerb8f85052007-07-31 03:50:36 +00005765 CI->setTailCall((yyvsp[-7].BoolVal));
5766 CI->setCallingConv((yyvsp[-6].UIntVal));
5767 (yyval.InstVal) = CI;
5768 delete (yyvsp[-2].ValueRefList);
5769 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005770 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005771 ;}
5772 break;
5773
5774 case 294:
5775#line 2969 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5776 {
5777 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005778 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005779 ;}
5780 break;
5781
5782 case 295:
5783#line 2974 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5784 {
5785 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005786 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005787 ;}
5788 break;
5789
5790 case 296:
5791#line 2978 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5792 {
5793 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005794 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005795 ;}
5796 break;
5797
5798 case 297:
5799#line 2985 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5800 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005801 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005802 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5803 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5804 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005805 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005806 ;}
5807 break;
5808
5809 case 298:
5810#line 2992 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5811 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005812 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005813 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5814 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005815 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005816 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5817 delete (yyvsp[-4].TypeVal);
5818 ;}
5819 break;
5820
5821 case 299:
5822#line 3000 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5823 {
Reid Spencer14310612006-12-31 05:40:51 +00005824 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005825 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5826 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5827 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005828 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005829 ;}
5830 break;
5831
5832 case 300:
5833#line 3007 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5834 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005835 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005836 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5837 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005838 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005839 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5840 delete (yyvsp[-4].TypeVal);
5841 ;}
5842 break;
5843
5844 case 301:
5845#line 3015 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5846 {
5847 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005848 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005849 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5850 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005851 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005852 ;}
5853 break;
5854
5855 case 302:
5856#line 3023 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5857 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005858 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005859 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5860 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005861 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005862 (*(yyvsp[-2].TypeVal))->getDescription());
5863 if (!cast<PointerType>((yyvsp[-2].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005864 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005865 (*(yyvsp[-2].TypeVal))->getDescription());
5866 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005867 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005868 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-4].BoolVal), (yyvsp[0].UIntVal));
5869 delete (yyvsp[-2].TypeVal);
5870 ;}
5871 break;
5872
5873 case 303:
5874#line 3037 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5875 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005876 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005877 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5878 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005879 if (!PT)
5880 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005881 (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005882 const Type *ElTy = PT->getElementType();
Reid Spencerb8f85052007-07-31 03:50:36 +00005883 if (ElTy != (yyvsp[-4].ValueVal)->getType())
5884 GEN_ERROR("Can't store '" + (yyvsp[-4].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005885 "' into space of type '" + ElTy->getDescription() + "'");
5886
Reid Spencerb8f85052007-07-31 03:50:36 +00005887 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005888 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005889 (yyval.InstVal) = new StoreInst((yyvsp[-4].ValueVal), tmpVal, (yyvsp[-6].BoolVal), (yyvsp[0].UIntVal));
5890 delete (yyvsp[-2].TypeVal);
5891 ;}
5892 break;
5893
5894 case 304:
5895#line 3054 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5896 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005897 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005898 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5899 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005900 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005901
Reid Spencerb8f85052007-07-31 03:50:36 +00005902 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005903 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00005904 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5905 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005906 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005907 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5908 delete (yyvsp[-2].TypeVal);
5909 delete (yyvsp[0].ValueList);
5910 ;}
5911 break;
5912
5913
5914 default: break;
5915 }
5916
5917/* Line 1126 of yacc.c. */
5918#line 5919 "llvmAsmParser.tab.c"
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005919
5920 yyvsp -= yylen;
5921 yyssp -= yylen;
Reid Spencer7780acb2007-04-16 06:56:07 +00005922
Reid Spencerb8f85052007-07-31 03:50:36 +00005923
5924 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005925
5926 *++yyvsp = yyval;
5927
5928
Reid Spencerb8f85052007-07-31 03:50:36 +00005929 /* Now `shift' the result of the reduction. Determine what state
5930 that goes to, based on the state we popped back to and the rule
5931 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005932
5933 yyn = yyr1[yyn];
5934
Reid Spencerb8f85052007-07-31 03:50:36 +00005935 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5936 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005937 yystate = yytable[yystate];
5938 else
Reid Spencerb8f85052007-07-31 03:50:36 +00005939 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005940
5941 goto yynewstate;
5942
5943
Reid Spencerb8f85052007-07-31 03:50:36 +00005944/*------------------------------------.
5945| yyerrlab -- here on detecting error |
5946`------------------------------------*/
5947yyerrlab:
5948 /* If not already recovering from an error, report this error. */
5949 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005950 {
5951 ++yynerrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005952#if YYERROR_VERBOSE
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005953 yyn = yypact[yystate];
5954
Reid Spencerb8f85052007-07-31 03:50:36 +00005955 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005956 {
Reid Spencerb8f85052007-07-31 03:50:36 +00005957 int yytype = YYTRANSLATE (yychar);
5958 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5959 YYSIZE_T yysize = yysize0;
5960 YYSIZE_T yysize1;
5961 int yysize_overflow = 0;
5962 char *yymsg = 0;
5963# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5964 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5965 int yyx;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005966
Reid Spencerb8f85052007-07-31 03:50:36 +00005967#if 0
5968 /* This is so xgettext sees the translatable formats that are
5969 constructed on the fly. */
5970 YY_("syntax error, unexpected %s");
5971 YY_("syntax error, unexpected %s, expecting %s");
5972 YY_("syntax error, unexpected %s, expecting %s or %s");
5973 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5974 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5975#endif
5976 char *yyfmt;
5977 char const *yyf;
5978 static char const yyunexpected[] = "syntax error, unexpected %s";
5979 static char const yyexpecting[] = ", expecting %s";
5980 static char const yyor[] = " or %s";
5981 char yyformat[sizeof yyunexpected
5982 + sizeof yyexpecting - 1
5983 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5984 * (sizeof yyor - 1))];
5985 char const *yyprefix = yyexpecting;
5986
5987 /* Start YYX at -YYN if negative to avoid negative indexes in
5988 YYCHECK. */
5989 int yyxbegin = yyn < 0 ? -yyn : 0;
5990
5991 /* Stay within bounds of both yycheck and yytname. */
5992 int yychecklim = YYLAST - yyn;
5993 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5994 int yycount = 1;
5995
5996 yyarg[0] = yytname[yytype];
5997 yyfmt = yystpcpy (yyformat, yyunexpected);
5998
5999 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
6000 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6001 {
6002 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6003 {
6004 yycount = 1;
6005 yysize = yysize0;
6006 yyformat[sizeof yyunexpected - 1] = '\0';
6007 break;
6008 }
6009 yyarg[yycount++] = yytname[yyx];
6010 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6011 yysize_overflow |= yysize1 < yysize;
6012 yysize = yysize1;
6013 yyfmt = yystpcpy (yyfmt, yyprefix);
6014 yyprefix = yyor;
6015 }
6016
6017 yyf = YY_(yyformat);
6018 yysize1 = yysize + yystrlen (yyf);
6019 yysize_overflow |= yysize1 < yysize;
6020 yysize = yysize1;
6021
6022 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6023 yymsg = (char *) YYSTACK_ALLOC (yysize);
6024 if (yymsg)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006025 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006026 /* Avoid sprintf, as that infringes on the user's name space.
6027 Don't have undefined behavior even if the translation
6028 produced a string with the wrong number of "%s"s. */
6029 char *yyp = yymsg;
6030 int yyi = 0;
6031 while ((*yyp = *yyf))
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006032 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006033 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6034 {
6035 yyp += yytnamerr (yyp, yyarg[yyi++]);
6036 yyf += 2;
6037 }
6038 else
6039 {
6040 yyp++;
6041 yyf++;
6042 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006043 }
Reid Spencerb8f85052007-07-31 03:50:36 +00006044 yyerror (yymsg);
6045 YYSTACK_FREE (yymsg);
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006046 }
6047 else
Reid Spencerb8f85052007-07-31 03:50:36 +00006048 {
6049 yyerror (YY_("syntax error"));
6050 goto yyexhaustedlab;
6051 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006052 }
6053 else
6054#endif /* YYERROR_VERBOSE */
Reid Spencerb8f85052007-07-31 03:50:36 +00006055 yyerror (YY_("syntax error"));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006056 }
6057
Reid Spencerb8f85052007-07-31 03:50:36 +00006058
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006059
6060 if (yyerrstatus == 3)
6061 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006062 /* If just tried and failed to reuse look-ahead token after an
6063 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006064
Reid Spencerb8f85052007-07-31 03:50:36 +00006065 if (yychar <= YYEOF)
6066 {
6067 /* Return failure if at end of input. */
6068 if (yychar == YYEOF)
6069 YYABORT;
6070 }
6071 else
6072 {
6073 yydestruct ("Error: discarding", yytoken, &yylval);
6074 yychar = YYEMPTY;
6075 }
6076 }
6077
6078 /* Else will try to reuse look-ahead token after shifting the error
6079 token. */
6080 goto yyerrlab1;
6081
6082
6083/*---------------------------------------------------.
6084| yyerrorlab -- error raised explicitly by YYERROR. |
6085`---------------------------------------------------*/
6086yyerrorlab:
6087
6088 /* Pacify compilers like GCC when the user code never invokes
6089 YYERROR and the label yyerrorlab therefore never appears in user
6090 code. */
6091 if (0)
6092 goto yyerrorlab;
6093
6094yyvsp -= yylen;
6095 yyssp -= yylen;
6096 yystate = *yyssp;
6097 goto yyerrlab1;
6098
6099
6100/*-------------------------------------------------------------.
6101| yyerrlab1 -- common code for both syntax error and YYERROR. |
6102`-------------------------------------------------------------*/
6103yyerrlab1:
6104 yyerrstatus = 3; /* Each real token shifted decrements this. */
6105
6106 for (;;)
6107 {
6108 yyn = yypact[yystate];
6109 if (yyn != YYPACT_NINF)
6110 {
6111 yyn += YYTERROR;
6112 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6113 {
6114 yyn = yytable[yyn];
6115 if (0 < yyn)
6116 break;
6117 }
6118 }
6119
6120 /* Pop the current state because it cannot handle the error token. */
6121 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006122 YYABORT;
6123
Reid Spencere4d87aa2006-12-23 06:05:41 +00006124
Reid Spencerb8f85052007-07-31 03:50:36 +00006125 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6126 YYPOPSTACK;
6127 yystate = *yyssp;
6128 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006129 }
6130
6131 if (yyn == YYFINAL)
6132 YYACCEPT;
6133
Reid Spencer68a24bd2005-08-27 18:50:39 +00006134 *++yyvsp = yylval;
Reid Spencerb8f85052007-07-31 03:50:36 +00006135
6136
6137 /* Shift the error token. */
6138 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006139
Reid Spencer68a24bd2005-08-27 18:50:39 +00006140 yystate = yyn;
6141 goto yynewstate;
6142
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006143
Reid Spencerb8f85052007-07-31 03:50:36 +00006144/*-------------------------------------.
6145| yyacceptlab -- YYACCEPT comes here. |
6146`-------------------------------------*/
6147yyacceptlab:
6148 yyresult = 0;
6149 goto yyreturn;
6150
6151/*-----------------------------------.
6152| yyabortlab -- YYABORT comes here. |
6153`-----------------------------------*/
6154yyabortlab:
6155 yyresult = 1;
6156 goto yyreturn;
6157
6158#ifndef yyoverflow
6159/*-------------------------------------------------.
6160| yyexhaustedlab -- memory exhaustion comes here. |
6161`-------------------------------------------------*/
6162yyexhaustedlab:
6163 yyerror (YY_("memory exhausted"));
6164 yyresult = 2;
6165 /* Fall through. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006166#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00006167
6168yyreturn:
6169 if (yychar != YYEOF && yychar != YYEMPTY)
6170 yydestruct ("Cleanup: discarding lookahead",
6171 yytoken, &yylval);
6172 while (yyssp != yyss)
6173 {
6174 yydestruct ("Cleanup: popping",
6175 yystos[*yyssp], yyvsp);
6176 YYPOPSTACK;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006177 }
Reid Spencerb8f85052007-07-31 03:50:36 +00006178#ifndef yyoverflow
6179 if (yyss != yyssa)
6180 YYSTACK_FREE (yyss);
6181#endif
6182 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006183}
Reid Spencerb8f85052007-07-31 03:50:36 +00006184
6185
6186#line 3071 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006187
6188
Reid Spencer14310612006-12-31 05:40:51 +00006189// common code from the two 'RunVMAsmParser' functions
6190static Module* RunParser(Module * M) {
6191
6192 llvmAsmlineno = 1; // Reset the current line number...
6193 CurModule.CurrentModule = M;
6194#if YYDEBUG
6195 yydebug = Debug;
6196#endif
6197
6198 // Check to make sure the parser succeeded
6199 if (yyparse()) {
6200 if (ParserResult)
6201 delete ParserResult;
6202 return 0;
6203 }
6204
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006205 // Emit an error if there are any unresolved types left.
6206 if (!CurModule.LateResolveTypes.empty()) {
6207 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6208 if (DID.Type == ValID::LocalName) {
6209 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6210 } else {
6211 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6212 }
6213 if (ParserResult)
6214 delete ParserResult;
6215 return 0;
6216 }
6217
6218 // Emit an error if there are any unresolved values left.
6219 if (!CurModule.LateResolveValues.empty()) {
6220 Value *V = CurModule.LateResolveValues.back();
6221 std::map<Value*, std::pair<ValID, int> >::iterator I =
6222 CurModule.PlaceHolderInfo.find(V);
6223
6224 if (I != CurModule.PlaceHolderInfo.end()) {
6225 ValID &DID = I->second.first;
6226 if (DID.Type == ValID::LocalName) {
6227 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6228 } else {
6229 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6230 }
6231 if (ParserResult)
6232 delete ParserResult;
6233 return 0;
6234 }
6235 }
6236
Reid Spencer14310612006-12-31 05:40:51 +00006237 // Check to make sure that parsing produced a result
6238 if (!ParserResult)
6239 return 0;
6240
6241 // Reset ParserResult variable while saving its value for the result.
6242 Module *Result = ParserResult;
6243 ParserResult = 0;
6244
6245 return Result;
6246}
6247
Reid Spencer61c83e02006-08-18 08:43:06 +00006248void llvm::GenerateError(const std::string &message, int LineNo) {
6249 if (LineNo == -1) LineNo = llvmAsmlineno;
6250 // TODO: column number in exception
6251 if (TheParseError)
6252 TheParseError->setError(CurFilename, message, LineNo);
6253 TriggerError = 1;
6254}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006255
6256int yyerror(const char *ErrorMsg) {
6257 std::string where
6258 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6259 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006260 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6261 if (yychar != YYEMPTY && yychar != 0)
6262 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6263 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006264 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006265 return 0;
6266}
Reid Spencerb8f85052007-07-31 03:50:36 +00006267