blob: a93ceb8a6515a51b21c1d2858037a4c370a72058 [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. */
Reid Spenceree0142e2007-07-31 06:37:43 +00001529#define YYLAST 1527
Reid Spencerb8f85052007-07-31 03:50:36 +00001530
1531/* YYNTOKENS -- Number of terminals. */
1532#define YYNTOKENS 157
1533/* YYNNTS -- Number of nonterminals. */
1534#define YYNNTS 82
1535/* YYNRULES -- Number of rules. */
Reid Spenceree0142e2007-07-31 06:37:43 +00001536#define YYNRULES 305
Reid Spencerb8f85052007-07-31 03:50:36 +00001537/* YYNRULES -- Number of states. */
Reid Spenceree0142e2007-07-31 06:37:43 +00001538#define YYNSTATES 589
Reid Spencerb8f85052007-07-31 03:50:36 +00001539
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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001608 213, 216, 218, 220, 222, 224, 226, 227, 230, 231,
1609 234, 235, 239, 242, 243, 245, 246, 250, 252, 255,
1610 257, 259, 261, 263, 265, 267, 270, 272, 275, 281,
1611 287, 293, 299, 303, 306, 312, 317, 320, 322, 324,
1612 326, 330, 332, 336, 338, 339, 341, 345, 350, 354,
1613 358, 363, 368, 372, 379, 385, 388, 391, 394, 397,
1614 400, 403, 406, 409, 412, 415, 418, 421, 428, 434,
1615 443, 450, 457, 465, 473, 480, 489, 498, 502, 504,
1616 506, 508, 510, 511, 514, 521, 523, 524, 526, 529,
1617 530, 534, 535, 539, 543, 547, 551, 552, 560, 561,
1618 570, 571, 580, 586, 589, 593, 595, 599, 603, 607,
1619 611, 613, 614, 620, 624, 626, 630, 632, 633, 643,
1620 645, 647, 652, 654, 656, 659, 663, 664, 666, 668,
1621 670, 672, 674, 676, 678, 680, 682, 686, 688, 694,
1622 696, 698, 700, 702, 704, 706, 709, 712, 715, 719,
1623 722, 723, 725, 728, 731, 735, 745, 755, 764, 779,
1624 781, 783, 790, 796, 799, 806, 814, 818, 824, 825,
1625 826, 830, 833, 835, 841, 847, 854, 861, 866, 873,
1626 878, 883, 890, 897, 900, 909, 911, 913, 914, 918,
1627 925, 929, 936, 939, 945, 953
Reid Spencerb8f85052007-07-31 03:50:36 +00001628};
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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001655 132, -1, 131, -1, 134, -1, -1, 181, 180, -1,
1656 -1, 50, 4, -1, -1, 144, 50, 4, -1, 31,
1657 19, -1, -1, 184, -1, -1, 144, 187, 186, -1,
1658 184, -1, 50, 4, -1, 11, -1, 12, -1, 13,
1659 -1, 14, -1, 46, -1, 188, -1, 189, 145, -1,
1660 223, -1, 146, 4, -1, 189, 147, 193, 148, 181,
1661 -1, 10, 147, 193, 148, 181, -1, 149, 4, 150,
1662 189, 151, -1, 152, 4, 150, 189, 153, -1, 154,
1663 194, 155, -1, 154, 155, -1, 152, 154, 194, 155,
1664 153, -1, 152, 154, 155, 153, -1, 189, 179, -1,
1665 189, -1, 10, -1, 190, -1, 192, 144, 190, -1,
1666 192, -1, 192, 144, 36, -1, 36, -1, -1, 189,
1667 -1, 194, 144, 189, -1, 189, 149, 197, 151, -1,
1668 189, 149, 151, -1, 189, 156, 19, -1, 189, 152,
1669 197, 153, -1, 189, 154, 197, 155, -1, 189, 154,
1670 155, -1, 189, 152, 154, 197, 155, 153, -1, 189,
1671 152, 154, 155, 153, -1, 189, 37, -1, 189, 38,
1672 -1, 189, 223, -1, 189, 196, -1, 189, 22, -1,
1673 163, 3, -1, 163, 5, -1, 163, 4, -1, 163,
1674 6, -1, 11, 23, -1, 11, 24, -1, 164, 9,
1675 -1, 160, 147, 195, 35, 189, 148, -1, 112, 147,
1676 195, 234, 148, -1, 126, 147, 195, 144, 195, 144,
1677 195, 148, -1, 158, 147, 195, 144, 195, 148, -1,
1678 159, 147, 195, 144, 195, 148, -1, 85, 161, 147,
1679 195, 144, 195, 148, -1, 86, 162, 147, 195, 144,
1680 195, 148, -1, 128, 147, 195, 144, 195, 148, -1,
1681 129, 147, 195, 144, 195, 144, 195, 148, -1, 130,
1682 147, 195, 144, 195, 144, 195, 148, -1, 197, 144,
1683 195, -1, 195, -1, 29, -1, 30, -1, 34, -1,
1684 -1, 191, 223, -1, 118, 147, 200, 35, 189, 148,
1685 -1, 202, -1, -1, 203, -1, 202, 203, -1, -1,
1686 28, 204, 219, -1, -1, 27, 205, 220, -1, 55,
1687 54, 209, -1, 167, 15, 189, -1, 167, 15, 10,
1688 -1, -1, 169, 173, 199, 198, 195, 206, 186, -1,
1689 -1, 169, 171, 173, 199, 198, 195, 207, 186, -1,
1690 -1, 169, 172, 173, 199, 198, 189, 208, 186, -1,
1691 169, 173, 32, 176, 200, -1, 48, 210, -1, 51,
1692 143, 211, -1, 19, -1, 49, 143, 19, -1, 63,
1693 143, 19, -1, 149, 212, 151, -1, 212, 144, 19,
1694 -1, 19, -1, -1, 213, 144, 189, 179, 166, -1,
1695 189, 179, 166, -1, 213, -1, 213, 144, 36, -1,
1696 36, -1, -1, 177, 191, 168, 147, 214, 148, 181,
1697 185, 182, -1, 25, -1, 154, -1, 175, 173, 215,
1698 216, -1, 26, -1, 155, -1, 226, 218, -1, 174,
1699 173, 215, -1, -1, 56, -1, 3, -1, 4, -1,
1700 9, -1, 23, -1, 24, -1, 37, -1, 38, -1,
1701 22, -1, 152, 197, 153, -1, 196, -1, 54, 221,
1702 19, 144, 19, -1, 7, -1, 8, -1, 165, -1,
1703 168, -1, 223, -1, 222, -1, 189, 224, -1, 226,
1704 227, -1, 217, 227, -1, 228, 167, 229, -1, 228,
1705 231, -1, -1, 18, -1, 64, 225, -1, 64, 10,
1706 -1, 65, 14, 224, -1, 65, 11, 224, 144, 14,
1707 224, 144, 14, 224, -1, 66, 163, 224, 144, 14,
1708 224, 149, 230, 151, -1, 66, 163, 224, 144, 14,
1709 224, 149, 151, -1, 67, 177, 191, 224, 147, 233,
1710 148, 181, 35, 14, 224, 68, 14, 224, -1, 68,
1711 -1, 69, -1, 230, 163, 222, 144, 14, 224, -1,
1712 163, 222, 144, 14, 224, -1, 167, 236, -1, 189,
1713 149, 224, 144, 224, 151, -1, 232, 144, 149, 224,
1714 144, 224, 151, -1, 189, 224, 179, -1, 233, 144,
1715 189, 224, 179, -1, -1, -1, 234, 144, 225, -1,
1716 53, 52, -1, 52, -1, 158, 189, 224, 144, 224,
1717 -1, 159, 189, 224, 144, 224, -1, 85, 161, 189,
1718 224, 144, 224, -1, 86, 162, 189, 224, 144, 224,
1719 -1, 160, 225, 35, 189, -1, 126, 225, 144, 225,
1720 144, 225, -1, 127, 225, 144, 189, -1, 128, 225,
1721 144, 225, -1, 129, 225, 144, 225, 144, 225, -1,
1722 130, 225, 144, 225, 144, 225, -1, 125, 232, -1,
1723 235, 177, 191, 224, 147, 233, 148, 181, -1, 238,
1724 -1, 33, -1, -1, 107, 189, 183, -1, 107, 189,
1725 144, 11, 224, 183, -1, 108, 189, 183, -1, 108,
1726 189, 144, 11, 224, 183, -1, 109, 225, -1, 237,
1727 110, 189, 224, 183, -1, 237, 111, 225, 144, 189,
1728 224, 183, -1, 112, 189, 224, 234, -1
Reid Spencerb8f85052007-07-31 03:50:36 +00001729};
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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001745 1239, 1244, 1245, 1246, 1247, 1248, 1251, 1252, 1259, 1260,
1746 1266, 1267, 1275, 1283, 1284, 1289, 1290, 1291, 1296, 1309,
1747 1309, 1309, 1309, 1312, 1316, 1320, 1327, 1332, 1340, 1370,
1748 1401, 1406, 1418, 1428, 1432, 1442, 1449, 1456, 1463, 1468,
1749 1473, 1480, 1481, 1488, 1495, 1503, 1509, 1521, 1549, 1565,
1750 1592, 1620, 1646, 1666, 1692, 1712, 1724, 1731, 1797, 1807,
1751 1817, 1823, 1833, 1839, 1849, 1854, 1859, 1867, 1879, 1901,
1752 1909, 1915, 1926, 1931, 1936, 1942, 1948, 1957, 1961, 1969,
1753 1969, 1972, 1972, 1975, 1986, 2007, 2012, 2020, 2021, 2025,
1754 2025, 2029, 2029, 2032, 2035, 2059, 2070, 2070, 2081, 2080,
1755 2090, 2089, 2100, 2119, 2122, 2128, 2138, 2142, 2147, 2149,
1756 2154, 2159, 2168, 2178, 2189, 2193, 2202, 2211, 2216, 2337,
1757 2337, 2339, 2348, 2348, 2350, 2355, 2367, 2371, 2376, 2380,
1758 2384, 2388, 2392, 2396, 2400, 2404, 2408, 2433, 2437, 2447,
1759 2451, 2455, 2460, 2467, 2467, 2473, 2482, 2486, 2495, 2504,
1760 2513, 2517, 2524, 2528, 2532, 2537, 2547, 2566, 2575, 2655,
1761 2659, 2666, 2677, 2690, 2700, 2711, 2721, 2730, 2739, 2742,
1762 2743, 2750, 2754, 2759, 2780, 2797, 2811, 2825, 2837, 2845,
1763 2852, 2858, 2864, 2870, 2885, 2970, 2975, 2979, 2986, 2993,
1764 3001, 3008, 3016, 3024, 3038, 3055
Reid Spencerb8f85052007-07-31 03:50:36 +00001765};
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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001856 179, 180, 180, 180, 180, 180, 181, 181, 182, 182,
1857 183, 183, 184, 185, 185, 186, 186, 187, 187, 188,
1858 188, 188, 188, 189, 189, 189, 189, 189, 189, 189,
1859 189, 189, 189, 189, 189, 189, 190, 191, 191, 192,
1860 192, 193, 193, 193, 193, 194, 194, 195, 195, 195,
Reid Spencerb8f85052007-07-31 03:50:36 +00001861 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
Reid Spenceree0142e2007-07-31 06:37:43 +00001862 195, 195, 195, 195, 195, 195, 195, 196, 196, 196,
1863 196, 196, 196, 196, 196, 196, 196, 197, 197, 198,
1864 198, 199, 199, 200, 200, 201, 201, 202, 202, 204,
1865 203, 205, 203, 203, 203, 203, 206, 203, 207, 203,
1866 208, 203, 203, 203, 203, 209, 210, 210, 211, 212,
1867 212, 212, 213, 213, 214, 214, 214, 214, 215, 216,
1868 216, 217, 218, 218, 219, 220, 221, 221, 222, 222,
1869 222, 222, 222, 222, 222, 222, 222, 222, 222, 223,
1870 223, 223, 223, 224, 224, 225, 226, 226, 227, 228,
1871 228, 228, 229, 229, 229, 229, 229, 229, 229, 229,
1872 229, 230, 230, 231, 232, 232, 233, 233, 233, 234,
1873 234, 235, 235, 236, 236, 236, 236, 236, 236, 236,
1874 236, 236, 236, 236, 236, 236, 237, 237, 238, 238,
1875 238, 238, 238, 238, 238, 238
Reid Spencerb8f85052007-07-31 03:50:36 +00001876};
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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001892 2, 1, 1, 1, 1, 1, 0, 2, 0, 2,
1893 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1894 1, 1, 1, 1, 1, 2, 1, 2, 5, 5,
1895 5, 5, 3, 2, 5, 4, 2, 1, 1, 1,
1896 3, 1, 3, 1, 0, 1, 3, 4, 3, 3,
1897 4, 4, 3, 6, 5, 2, 2, 2, 2, 2,
1898 2, 2, 2, 2, 2, 2, 2, 6, 5, 8,
1899 6, 6, 7, 7, 6, 8, 8, 3, 1, 1,
1900 1, 1, 0, 2, 6, 1, 0, 1, 2, 0,
1901 3, 0, 3, 3, 3, 3, 0, 7, 0, 8,
1902 0, 8, 5, 2, 3, 1, 3, 3, 3, 3,
1903 1, 0, 5, 3, 1, 3, 1, 0, 9, 1,
1904 1, 4, 1, 1, 2, 3, 0, 1, 1, 1,
1905 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1906 1, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1907 0, 1, 2, 2, 3, 9, 9, 8, 14, 1,
1908 1, 6, 5, 2, 6, 7, 3, 5, 0, 0,
1909 3, 2, 1, 5, 5, 6, 6, 4, 6, 4,
1910 4, 6, 6, 2, 8, 1, 1, 0, 3, 6,
1911 3, 6, 2, 5, 7, 4
Reid Spencerb8f85052007-07-31 03:50:36 +00001912};
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{
Reid Spenceree0142e2007-07-31 06:37:43 +00001919 68, 58, 65, 59, 66, 60, 201, 199, 0, 0,
1920 0, 0, 0, 0, 78, 67, 0, 68, 197, 82,
1921 85, 0, 0, 213, 0, 0, 63, 0, 69, 70,
Reid Spencerb8f85052007-07-31 03:50:36 +00001922 72, 71, 73, 75, 74, 76, 77, 79, 80, 81,
Reid Spenceree0142e2007-07-31 06:37:43 +00001923 78, 78, 192, 1, 198, 83, 84, 78, 202, 86,
1924 87, 88, 89, 78, 260, 200, 260, 0, 0, 221,
1925 214, 215, 203, 249, 250, 205, 129, 130, 131, 132,
1926 133, 0, 0, 0, 0, 251, 252, 134, 204, 136,
1927 192, 192, 90, 191, 0, 93, 93, 261, 257, 64,
1928 232, 233, 234, 256, 216, 217, 220, 0, 154, 137,
1929 0, 0, 0, 0, 143, 155, 0, 135, 154, 0,
1930 0, 92, 91, 0, 189, 190, 0, 0, 94, 95,
1931 96, 97, 98, 0, 235, 0, 297, 259, 0, 218,
1932 153, 109, 149, 151, 0, 0, 0, 0, 0, 0,
1933 142, 0, 0, 0, 148, 0, 147, 0, 212, 129,
1934 130, 131, 0, 0, 0, 206, 99, 0, 229, 230,
1935 231, 296, 282, 0, 0, 0, 0, 93, 269, 270,
Reid Spencerb8f85052007-07-31 03:50:36 +00001936 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,
Reid Spenceree0142e2007-07-31 06:37:43 +00001940 0, 0, 258, 93, 273, 0, 295, 219, 146, 0,
1941 116, 0, 0, 145, 0, 156, 116, 208, 210, 0,
1942 193, 174, 175, 170, 172, 171, 173, 176, 169, 165,
1943 166, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1944 0, 0, 0, 0, 0, 168, 167, 125, 0, 281,
1945 263, 0, 262, 0, 0, 55, 0, 0, 29, 30,
Reid Spencerb8f85052007-07-31 03:50:36 +00001946 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
1947 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
Reid Spenceree0142e2007-07-31 06:37:43 +00001948 44, 45, 46, 47, 48, 0, 120, 120, 302, 0,
1949 0, 293, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerb8f85052007-07-31 03:50:36 +00001950 0, 0, 0, 101, 103, 102, 100, 104, 105, 106,
Reid Spenceree0142e2007-07-31 06:37:43 +00001951 107, 108, 110, 152, 150, 139, 140, 141, 144, 138,
1952 125, 125, 0, 0, 0, 0, 0, 0, 0, 0,
1953 158, 188, 0, 0, 0, 162, 0, 159, 0, 0,
1954 0, 0, 207, 227, 238, 239, 240, 245, 241, 242,
1955 243, 244, 236, 0, 247, 254, 253, 255, 0, 264,
1956 0, 0, 0, 0, 0, 298, 0, 300, 279, 0,
Reid Spencerb8f85052007-07-31 03:50:36 +00001957 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spenceree0142e2007-07-31 06:37:43 +00001958 0, 0, 114, 113, 111, 115, 112, 117, 209, 211,
1959 0, 0, 0, 279, 0, 0, 0, 0, 0, 157,
1960 143, 155, 0, 160, 161, 0, 0, 0, 0, 0,
1961 127, 125, 226, 109, 224, 0, 237, 0, 0, 0,
1962 0, 0, 0, 0, 0, 0, 0, 305, 0, 0,
1963 0, 289, 290, 0, 0, 0, 0, 287, 0, 120,
1964 0, 0, 0, 0, 0, 0, 0, 0, 0, 187,
1965 164, 0, 0, 0, 0, 122, 128, 126, 62, 0,
1966 116, 0, 246, 0, 0, 278, 0, 0, 120, 121,
1967 120, 0, 0, 0, 0, 0, 0, 283, 284, 278,
1968 0, 303, 0, 194, 0, 0, 178, 0, 0, 0,
1969 0, 163, 0, 0, 0, 61, 223, 225, 109, 123,
1970 0, 0, 0, 0, 0, 285, 286, 299, 301, 280,
1971 0, 0, 288, 291, 292, 0, 120, 0, 0, 0,
1972 184, 0, 0, 180, 181, 177, 62, 124, 118, 248,
1973 0, 0, 109, 0, 116, 274, 0, 116, 304, 182,
1974 183, 0, 0, 0, 222, 0, 228, 0, 267, 0,
1975 0, 276, 0, 0, 275, 294, 179, 185, 186, 119,
1976 265, 0, 266, 0, 109, 0, 0, 0, 277, 0,
1977 0, 0, 0, 272, 0, 0, 271, 0, 268
Reid Spencerb8f85052007-07-31 03:50:36 +00001978};
1979
1980/* YYDEFGOTO[NTERM-NUM]. */
1981static const short int yydefgoto[] =
1982{
Reid Spenceree0142e2007-07-31 06:37:43 +00001983 -1, 252, 253, 254, 278, 295, 152, 153, 75, 506,
Reid Spencerb8f85052007-07-31 03:50:36 +00001984 12, 76, 14, 15, 40, 41, 42, 47, 53, 113,
Reid Spenceree0142e2007-07-31 06:37:43 +00001985 123, 322, 218, 397, 325, 556, 375, 420, 538, 352,
1986 421, 77, 154, 132, 147, 133, 134, 106, 341, 364,
Reid Spencerb8f85052007-07-31 03:50:36 +00001987 342, 116, 84, 148, 16, 17, 18, 20, 19, 257,
Reid Spenceree0142e2007-07-31 06:37:43 +00001988 330, 331, 62, 23, 60, 97, 424, 425, 124, 160,
1989 54, 92, 55, 48, 427, 365, 79, 367, 262, 56,
1990 88, 89, 212, 560, 127, 301, 514, 437, 213, 214,
Reid Spencerb8f85052007-07-31 03:50:36 +00001991 215, 216
1992};
1993
1994/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1995 STATE-NUM. */
Reid Spenceree0142e2007-07-31 06:37:43 +00001996#define YYPACT_NINF -513
Reid Spencerb8f85052007-07-31 03:50:36 +00001997static const short int yypact[] =
1998{
Reid Spenceree0142e2007-07-31 06:37:43 +00001999 414, -513, -513, -513, -513, -513, -513, -513, -7, -92,
2000 5, -42, 130, 11, 223, -513, 148, 484, -513, 131,
2001 102, 47, 62, -513, 60, 141, -513, 1169, -513, -513,
2002 -513, -513, -513, -513, -513, -513, -513, -513, -513, -513,
2003 147, 147, 226, -513, -513, -513, -513, 147, -513, -513,
2004 -513, -513, -513, 147, 199, -513, -8, 201, 211, 217,
2005 -513, -513, -513, -513, -513, 93, -513, -513, -513, -513,
2006 -513, 241, 247, 4, 811, -513, -513, -513, 162, -513,
2007 242, 242, 275, -513, 49, 167, 167, -513, -513, 279,
2008 -513, -513, -513, -513, -513, -513, -513, -49, 928, -513,
2009 133, 143, 851, 93, -513, 162, -125, -513, 928, 49,
2010 49, -513, -513, 965, -513, -513, 1188, 293, -513, -513,
2011 -513, -513, -513, 1225, -513, -10, 1384, -513, 283, -513,
2012 -513, 162, -513, 166, 174, 1262, 1262, 172, -89, 1262,
2013 -513, 178, 1188, 1262, 93, 168, 162, 33, -513, 40,
2014 319, 320, 125, 321, 631, -513, -513, 76, -513, -513,
2015 -513, -513, -513, 280, 1336, 108, 324, 167, -513, -513,
2016 -513, -513, -513, -513, -513, -513, -513, -513, -513, -513,
2017 -513, -513, -513, -513, -513, 704, 474, 1262, 1262, 1262,
2018 1262, -513, -513, -513, -513, -513, -513, -513, -513, -513,
2019 -513, -513, -513, 1262, 1262, 1262, 1262, 1262, 1262, 1262,
2020 1262, 1262, -513, 167, -513, 26, -513, -513, 252, 1002,
2021 -513, -33, -72, -513, 185, 162, -513, -513, 162, 965,
2022 -513, -513, -513, -513, -513, -513, -513, -513, -513, -513,
2023 -513, 704, 474, 184, 192, 200, 202, 204, 1077, 1373,
2024 891, 327, 206, 207, 213, -513, -513, 224, 214, -513,
2025 93, 472, -513, 606, 606, -513, 606, 1225, -513, -513,
2026 -513, -513, -513, -513, -513, -513, -513, -513, 1262, -513,
2027 -513, -513, -513, -513, -513, -513, -513, -513, -513, -513,
2028 -513, -513, -513, -513, -513, 1262, 57, 128, -513, 472,
2029 99, 225, 227, 228, 231, 232, 234, 472, 472, 335,
2030 1225, 1262, 1262, -513, -513, -513, -513, -513, -513, -513,
2031 -513, -513, -513, -513, -513, 123, -513, -513, -513, 123,
2032 224, 224, 344, 233, 235, 1188, 1188, 1188, 1188, 1188,
2033 -513, -513, -45, 909, -79, -513, -67, -513, 1188, 1188,
2034 1188, -11, -513, 1114, -513, -513, -513, -513, -513, -513,
2035 -513, -513, 329, 1188, -513, -513, -513, -513, 244, -513,
2036 248, 606, 472, 472, 12, -513, 17, -513, -513, 606,
2037 245, 1262, 1262, 1262, 1262, 1262, 249, 251, 1262, 606,
2038 472, 257, -513, -513, -513, -513, -513, -513, -513, -513,
2039 1262, 1188, 1188, -513, 258, 259, 262, 263, 1188, -513,
2040 255, 631, -61, -513, -513, 265, 266, 376, 393, 409,
2041 -513, 224, -513, 162, 271, 268, -513, 399, -73, 405,
2042 406, 274, 281, 282, 606, 419, 606, 284, 288, 606,
2043 301, 162, -513, 302, 304, 606, 606, 162, 303, 307,
2044 1262, 8, 308, 309, -40, 1188, 1188, 1188, 1188, -513,
2045 -513, 311, 1188, 1188, 1262, -513, -513, -513, 84, 1151,
2046 -513, 310, -513, 606, 606, 1262, 606, 606, 307, -513,
2047 307, 1262, 606, 312, 1262, 1262, 1262, -513, -513, 1262,
2048 377, -513, 472, -513, 1188, 1188, -513, 313, 318, 317,
2049 323, -513, 322, 330, 156, -513, -513, -513, 162, 39,
2050 453, 333, 334, 472, -37, -513, -513, -513, -513, -513,
2051 331, 606, -513, -513, -513, -28, 307, 337, 338, 1188,
2052 -513, 1188, 1188, -513, -513, -513, 84, -513, 437, -513,
2053 476, 1, -513, 1262, -513, -513, 351, -513, -513, -513,
2054 -513, 358, 359, 360, -513, 509, -513, 606, -513, 766,
2055 18, 252, 472, 55, -513, 123, -513, -513, -513, -513,
2056 -513, 370, -513, 766, -513, 501, 502, 374, 252, 606,
2057 606, 505, 452, -513, 606, 507, -513, 606, -513
Reid Spencerb8f85052007-07-31 03:50:36 +00002058};
2059
2060/* YYPGOTO[NTERM-NUM]. */
2061static const short int yypgoto[] =
2062{
Reid Spenceree0142e2007-07-31 06:37:43 +00002063 -513, 396, 397, 398, 286, 287, -164, -513, 0, -6,
2064 436, 9, -513, -513, -513, -513, 45, -513, -513, -513,
2065 -156, -513, -417, -513, -223, -513, -284, 19, -513, -294,
2066 -513, -513, -26, 314, -118, -513, 423, 432, -58, -150,
2067 -228, 104, 239, 332, -513, -513, 520, -513, -513, -513,
2068 -513, -513, -513, -513, -513, -513, -513, -513, 454, -513,
2069 -513, -513, -513, -513, -513, -512, -140, -239, -173, -513,
2070 482, -513, -513, -513, -513, -513, 52, 157, -513, -513,
2071 -513, -513
Reid Spencerb8f85052007-07-31 03:50:36 +00002072};
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. */
Reid Spenceree0142e2007-07-31 06:37:43 +00002078#define YYTABLE_NINF -197
Reid Spencerb8f85052007-07-31 03:50:36 +00002079static const short int yytable[] =
2080{
Reid Spenceree0142e2007-07-31 06:37:43 +00002081 11, 78, 266, 329, 255, 157, 468, 230, 101, 13,
2082 87, 267, 265, 377, 256, 158, 298, 11, 90, 139,
2083 418, 344, 346, 434, 368, 369, 13, 370, 436, 265,
2084 140, 302, 303, 304, 305, 306, 398, 399, 309, 419,
2085 63, 64, 21, -55, -55, -55, -55, 571, 105, 1,
2086 2, 24, 3, 4, 5, 139, 22, 310, 155, 25,
2087 378, 577, 435, 231, 232, 408, 224, 435, 386, 387,
2088 418, 408, 131, 107, 413, 108, 105, 408, 114, 115,
2089 472, 327, 131, 408, 227, 80, 81, 146, 414, 11,
2090 575, 536, 85, 2, 461, 128, 4, 146, 86, 408,
2091 1, 26, 129, 3, 481, 5, 409, 543, 496, 221,
2092 222, 544, 107, 225, 108, 412, 543, 228, 326, 263,
2093 547, 366, 264, 366, 366, 561, 366, 467, 233, 234,
2094 235, 236, 431, 432, 433, 428, 311, 312, 261, 391,
2095 438, 49, 50, 51, 159, 27, 52, 91, 43, 371,
2096 448, 449, 558, 107, 28, 108, 493, 578, 102, 366,
2097 61, 296, 297, 261, 299, 491, 258, 366, 366, 572,
2098 392, 393, 394, 395, 45, 396, 46, 300, 261, 261,
2099 261, 261, 261, 307, 308, 261, 392, 393, 394, 395,
2100 57, 396, 389, 131, 517, 478, 518, 480, 313, 314,
2101 483, 374, 107, 146, 108, 58, 487, 488, 440, 59,
2102 442, 443, 444, 142, 143, 315, 316, 87, 317, 318,
2103 94, 319, 320, 321, 117, 118, 119, 120, 121, 122,
2104 95, 366, 366, 366, 511, 512, 96, 515, 516, 366,
2105 98, 146, 548, 520, 107, 99, 108, 509, 379, 366,
2106 366, 100, 372, 526, 392, 393, 394, 395, 82, 396,
2107 83, 255, 29, 30, 31, 32, 33, 34, 35, 373,
2108 36, 256, 376, 107, 542, 108, 83, 403, 404, 405,
2109 406, 407, 546, 135, 146, 390, 261, 37, 38, 39,
2110 415, 416, 417, 136, 366, 1, 366, 156, 3, 366,
2111 5, 107, 217, 108, 535, 366, 366, 107, 519, 108,
2112 219, 522, 523, 524, 111, 229, 112, 411, 570, 109,
2113 110, 563, 220, 574, 565, 223, 226, 423, -56, -57,
2114 237, 335, 259, 366, 366, 265, 366, 366, 328, 336,
2115 582, 583, 366, 452, 453, 586, 347, 337, 588, 338,
2116 459, 339, 366, 348, 349, 261, 441, 261, 261, 261,
2117 350, 353, 447, 37, 38, 39, 313, 314, 351, 380,
2118 388, 381, 382, 366, 451, 383, 384, 559, 385, 400,
2119 401, 366, 402, 315, 316, 426, 317, 318, 429, 319,
2120 320, 321, 430, 445, 439, 446, 573, 497, 498, 499,
2121 500, 450, 455, 456, 502, 503, 457, 458, 460, 462,
2122 463, 464, 465, 466, -196, 469, 470, 366, 471, 473,
2123 474, 475, 366, 479, 492, 476, 477, 435, 481, -64,
2124 1, 2, 482, 3, 4, 5, 527, 528, 504, 366,
2125 366, 6, 7, 508, 366, 484, 485, 366, 486, 513,
2126 489, 490, 494, 495, 510, 261, 521, 529, 261, 261,
2127 261, 531, 8, 513, 501, 9, 530, 532, 505, 10,
2128 533, 551, 539, 552, 553, 354, 355, 540, 534, 63,
2129 64, 356, 545, 541, -195, 549, 550, 555, 1, 2,
2130 557, 3, 4, 5, 357, 358, 359, 279, 280, -64,
2131 1, 2, 564, 3, 4, 5, 566, 567, 568, 360,
2132 361, 6, 7, 569, 576, 579, 580, 562, 581, 584,
2133 585, 587, 209, 210, 211, 126, 362, 333, 537, 334,
2134 554, 141, 8, 324, 138, 9, 505, 44, 93, 10,
2135 125, 525, 170, 171, 172, 173, 174, 175, 176, 177,
2136 178, 179, 180, 181, 182, 183, 184, 241, 242, 0,
2137 454, 332, 0, 0, 0, 0, 0, 281, 282, 283,
2138 284, 285, 286, 287, 288, 289, 290, 291, 292, 293,
2139 294, 0, 0, 0, 243, 191, 192, 193, 194, 195,
2140 196, 197, 198, 199, 200, 201, 202, 0, 244, 0,
2141 245, 246, 247, 0, 0, 0, 0, 0, 0, 354,
2142 355, 0, 0, 63, 64, 356, 0, 107, 0, 108,
2143 0, 0, 1, 2, 363, 3, 4, 5, 357, 358,
2144 359, 0, 0, 0, 0, 0, 0, 0, 63, 64,
2145 0, 0, 0, 360, 361, 0, 0, 1, 2, 0,
2146 3, 4, 5, 238, 0, 0, 0, 0, 0, 0,
2147 362, 0, 0, 0, 0, 0, 0, 0, 239, 240,
2148 0, 0, 0, 0, 0, 0, 170, 171, 172, 173,
2149 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2150 184, 241, 242, 0, 0, 0, 0, 0, 0, 0,
2151 0, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2152 179, 180, 181, 182, 183, 184, 241, 242, 243, 191,
2153 192, 193, 194, 195, 196, 197, 198, 199, 200, 201,
2154 202, 0, 244, 0, 245, 246, 247, 0, 0, 0,
2155 0, 0, 0, 243, 191, 192, 193, 194, 195, 196,
2156 197, 198, 199, 200, 201, 202, 0, 244, 363, 245,
2157 246, 247, 0, 0, 0, 0, 0, 0, 0, 354,
2158 355, 0, 0, 0, 0, 356, 107, 0, 108, 0,
2159 248, 0, 0, 249, 0, 250, 0, 251, 357, 358,
2160 359, 268, 269, 270, 271, 272, 273, 274, 275, 276,
2161 277, 0, 0, 360, 361, 0, 0, 0, 0, 0,
2162 0, 0, 0, 0, 0, 0, 0, 0, 63, 64,
2163 362, 103, 66, 67, 68, 69, 0, 1, 2, 0,
2164 3, 4, 5, 0, 0, 0, 170, 171, 172, 173,
2165 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
2166 184, 241, 242, 0, 0, 0, 0, 70, 63, 64,
2167 0, 103, 66, 67, 68, 69, 0, 1, 2, 0,
2168 3, 4, 5, 0, 0, 0, 0, 0, 243, 191,
2169 192, 193, 194, 195, 196, 197, 198, 199, 200, 201,
2170 202, 0, 244, 0, 245, 246, 247, 70, 63, 64,
Reid Spencerb8f85052007-07-31 03:50:36 +00002171 0, 103, 149, 150, 151, 69, 0, 1, 2, 0,
Reid Spenceree0142e2007-07-31 06:37:43 +00002172 3, 4, 5, 0, 0, 0, 63, 64, 363, 103,
2173 149, 150, 151, 69, 0, 1, 2, 0, 3, 4,
2174 5, 0, 0, 0, 0, 63, 64, 70, 103, 66,
Reid Spencerb8f85052007-07-31 03:50:36 +00002175 67, 68, 69, 0, 1, 2, 0, 3, 4, 5,
Reid Spenceree0142e2007-07-31 06:37:43 +00002176 0, 0, 0, 0, 0, 70, 0, 71, 0, 0,
2177 72, 0, 0, 73, 130, 74, 104, 0, 0, 0,
2178 0, 0, 63, 64, 70, 144, 66, 67, 68, 69,
2179 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
Reid Spencerb8f85052007-07-31 03:50:36 +00002180 0, 0, 0, 0, 0, 0, 0, 71, 0, 0,
Reid Spenceree0142e2007-07-31 06:37:43 +00002181 72, 0, 0, 73, 0, 74, 137, 0, 0, 63,
2182 64, 70, 103, 66, 67, 68, 69, 0, 1, 2,
2183 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2184 0, 0, 0, 0, 0, 0, 0, 71, 323, 0,
2185 72, 0, 0, 73, 0, 74, 345, 0, 70, 0,
2186 0, 0, 0, 0, 0, 71, 0, 0, 72, 0,
2187 0, 73, 0, 74, 410, 0, 0, 0, 0, 0,
2188 0, 0, 0, 0, 71, 0, 0, 72, 0, 0,
2189 73, 0, 74, 145, 63, 64, 0, 103, 149, 150,
2190 151, 69, 0, 1, 2, 0, 3, 4, 5, 0,
2191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2192 0, 71, 0, 0, 72, 0, 0, 73, 0, 74,
2193 0, 63, 64, 70, 103, 66, 67, 68, 69, 0,
2194 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2195 0, 0, 0, 0, 0, 0, 0, 0, 71, 0,
2196 422, 72, 0, 0, 73, 0, 74, 0, 63, 64,
2197 70, 103, 66, 67, 68, 69, 0, 1, 2, 0,
2198 3, 4, 5, 0, 0, 0, 63, 64, 0, 65,
2199 66, 67, 68, 69, 0, 1, 2, 507, 3, 4,
2200 5, 0, 0, 0, 0, 63, 64, 70, 103, 149,
2201 150, 151, 69, 0, 1, 2, 0, 3, 4, 5,
2202 0, 0, 0, 0, 0, 70, 0, 0, 0, 0,
2203 0, 0, 0, 71, 0, 0, 72, 0, 340, 73,
2204 0, 74, 63, 64, 70, 144, 66, 67, 68, 69,
2205 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2206 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2207 71, 0, 0, 72, 0, 0, 73, 0, 74, 63,
2208 64, 70, 103, 66, 67, 68, 69, 0, 1, 2,
2209 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2210 0, 0, 0, 0, 0, 0, 0, 71, 0, 0,
2211 72, 0, 0, 73, 0, 74, 0, 0, 70, 0,
2212 0, 0, 0, 0, 0, 71, 0, 0, 72, 0,
2213 0, 73, 0, 74, 0, 0, 0, 0, 0, 0,
2214 0, 0, 0, 0, 71, 0, 0, 72, 0, 0,
2215 73, 0, 74, 63, 64, 0, 260, 66, 67, 68,
2216 69, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2217 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2218 0, 71, 0, 0, 72, 0, 0, 73, 0, 74,
2219 63, 64, 70, 103, 149, 150, 151, 69, 0, 1,
2220 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2221 0, 0, 0, 0, 0, 0, 0, 0, 71, 0,
2222 0, 72, 0, 0, 73, 0, 74, 161, 0, 70,
2223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2224 0, 0, 0, 0, 0, 0, 162, 163, 0, 0,
2225 0, 0, 0, 0, 0, 0, 0, 0, 164, 165,
2226 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
2227 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
2228 186, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2229 0, 0, 71, 0, 0, 72, 0, 0, 73, 0,
2230 74, 187, 188, 189, 0, 0, 190, 191, 192, 193,
2231 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
2232 204, 205, 206, 207, 208, 0, 0, 0, 0, 71,
2233 0, 0, 72, 0, 0, 73, 0, 343
Reid Spencerb8f85052007-07-31 03:50:36 +00002234};
2235
2236static const short int yycheck[] =
2237{
Reid Spenceree0142e2007-07-31 06:37:43 +00002238 0, 27, 166, 226, 154, 123, 423, 147, 4, 0,
2239 18, 167, 11, 297, 154, 25, 189, 17, 26, 144,
2240 31, 249, 250, 11, 263, 264, 17, 266, 11, 11,
2241 155, 204, 205, 206, 207, 208, 330, 331, 211, 50,
2242 7, 8, 49, 3, 4, 5, 6, 559, 74, 16,
2243 17, 143, 19, 20, 21, 144, 63, 213, 116, 54,
2244 299, 573, 50, 23, 24, 144, 155, 50, 307, 308,
2245 31, 144, 98, 145, 153, 147, 102, 144, 29, 30,
2246 153, 153, 108, 144, 142, 40, 41, 113, 155, 89,
2247 35, 508, 47, 17, 155, 144, 20, 123, 53, 144,
2248 16, 143, 151, 19, 144, 21, 151, 144, 148, 135,
2249 136, 148, 145, 139, 147, 343, 144, 143, 151, 11,
2250 148, 261, 14, 263, 264, 542, 266, 421, 3, 4,
2251 5, 6, 371, 372, 373, 363, 110, 111, 164, 312,
2252 379, 39, 40, 41, 154, 15, 44, 155, 0, 267,
2253 389, 390, 151, 145, 143, 147, 148, 574, 154, 299,
2254 19, 187, 188, 189, 190, 449, 157, 307, 308, 151,
2255 131, 132, 133, 134, 43, 136, 45, 203, 204, 205,
2256 206, 207, 208, 209, 210, 211, 131, 132, 133, 134,
2257 143, 136, 310, 219, 478, 434, 480, 436, 114, 115,
2258 439, 144, 145, 229, 147, 143, 445, 446, 381, 149,
2259 383, 384, 385, 109, 110, 131, 132, 18, 134, 135,
2260 19, 137, 138, 139, 57, 58, 59, 60, 61, 62,
2261 19, 371, 372, 373, 473, 474, 19, 476, 477, 379,
2262 147, 267, 526, 482, 145, 4, 147, 470, 149, 389,
2263 390, 4, 278, 492, 131, 132, 133, 134, 32, 136,
2264 34, 411, 39, 40, 41, 42, 43, 44, 45, 295,
2265 47, 411, 144, 145, 513, 147, 34, 335, 336, 337,
2266 338, 339, 521, 150, 310, 311, 312, 140, 141, 142,
2267 348, 349, 350, 150, 434, 16, 436, 4, 19, 439,
2268 21, 145, 19, 147, 148, 445, 446, 145, 481, 147,
2269 144, 484, 485, 486, 39, 147, 41, 343, 557, 80,
2270 81, 544, 148, 562, 547, 153, 148, 353, 9, 9,
2271 9, 147, 52, 473, 474, 11, 476, 477, 153, 147,
2272 579, 580, 482, 401, 402, 584, 19, 147, 587, 147,
2273 408, 147, 492, 147, 147, 381, 382, 383, 384, 385,
2274 147, 147, 388, 140, 141, 142, 114, 115, 144, 144,
2275 35, 144, 144, 513, 400, 144, 144, 541, 144, 35,
2276 147, 521, 147, 131, 132, 56, 134, 135, 144, 137,
2277 138, 139, 144, 144, 149, 144, 560, 455, 456, 457,
2278 458, 144, 144, 144, 462, 463, 144, 144, 153, 144,
2279 144, 35, 19, 4, 0, 144, 148, 557, 19, 14,
2280 14, 147, 562, 4, 450, 144, 144, 50, 144, 15,
2281 16, 17, 144, 19, 20, 21, 494, 495, 464, 579,
2282 580, 27, 28, 469, 584, 144, 144, 587, 144, 475,
2283 147, 144, 144, 144, 144, 481, 144, 144, 484, 485,
2284 486, 144, 48, 489, 153, 51, 148, 144, 468, 55,
2285 148, 529, 19, 531, 532, 3, 4, 144, 148, 7,
2286 8, 9, 151, 149, 0, 148, 148, 50, 16, 17,
2287 14, 19, 20, 21, 22, 23, 24, 23, 24, 15,
2288 16, 17, 151, 19, 20, 21, 148, 148, 148, 37,
2289 38, 27, 28, 4, 144, 14, 14, 543, 144, 14,
2290 68, 14, 126, 126, 126, 89, 54, 241, 509, 242,
2291 536, 108, 48, 219, 102, 51, 536, 17, 56, 55,
2292 86, 489, 70, 71, 72, 73, 74, 75, 76, 77,
2293 78, 79, 80, 81, 82, 83, 84, 85, 86, -1,
2294 403, 229, -1, -1, -1, -1, -1, 93, 94, 95,
2295 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
2296 106, -1, -1, -1, 112, 113, 114, 115, 116, 117,
2297 118, 119, 120, 121, 122, 123, 124, -1, 126, -1,
2298 128, 129, 130, -1, -1, -1, -1, -1, -1, 3,
2299 4, -1, -1, 7, 8, 9, -1, 145, -1, 147,
2300 -1, -1, 16, 17, 152, 19, 20, 21, 22, 23,
2301 24, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2302 -1, -1, -1, 37, 38, -1, -1, 16, 17, -1,
2303 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
2304 54, -1, -1, -1, -1, -1, -1, -1, 37, 38,
2305 -1, -1, -1, -1, -1, -1, 70, 71, 72, 73,
2306 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2307 84, 85, 86, -1, -1, -1, -1, -1, -1, -1,
2308 -1, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2309 79, 80, 81, 82, 83, 84, 85, 86, 112, 113,
2310 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2311 124, -1, 126, -1, 128, 129, 130, -1, -1, -1,
2312 -1, -1, -1, 112, 113, 114, 115, 116, 117, 118,
2313 119, 120, 121, 122, 123, 124, -1, 126, 152, 128,
2314 129, 130, -1, -1, -1, -1, -1, -1, -1, 3,
2315 4, -1, -1, -1, -1, 9, 145, -1, 147, -1,
2316 149, -1, -1, 152, -1, 154, -1, 156, 22, 23,
2317 24, 87, 88, 89, 90, 91, 92, 93, 94, 95,
2318 96, -1, -1, 37, 38, -1, -1, -1, -1, -1,
2319 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2320 54, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2321 19, 20, 21, -1, -1, -1, 70, 71, 72, 73,
2322 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2323 84, 85, 86, -1, -1, -1, -1, 46, 7, 8,
Reid Spencerb8f85052007-07-31 03:50:36 +00002324 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
Reid Spenceree0142e2007-07-31 06:37:43 +00002325 19, 20, 21, -1, -1, -1, -1, -1, 112, 113,
2326 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2327 124, -1, 126, -1, 128, 129, 130, 46, 7, 8,
2328 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2329 19, 20, 21, -1, -1, -1, 7, 8, 152, 10,
2330 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2331 21, -1, -1, -1, -1, 7, 8, 46, 10, 11,
Reid Spencerb8f85052007-07-31 03:50:36 +00002332 12, 13, 14, -1, 16, 17, -1, 19, 20, 21,
Reid Spenceree0142e2007-07-31 06:37:43 +00002333 -1, -1, -1, -1, -1, 46, -1, 146, -1, -1,
2334 149, -1, -1, 152, 36, 154, 155, -1, -1, -1,
2335 -1, -1, 7, 8, 46, 10, 11, 12, 13, 14,
2336 -1, 16, 17, -1, 19, 20, 21, -1, -1, -1,
Reid Spencerb8f85052007-07-31 03:50:36 +00002337 -1, -1, -1, -1, -1, -1, -1, 146, -1, -1,
Reid Spenceree0142e2007-07-31 06:37:43 +00002338 149, -1, -1, 152, -1, 154, 155, -1, -1, 7,
2339 8, 46, 10, 11, 12, 13, 14, -1, 16, 17,
2340 -1, 19, 20, 21, -1, -1, -1, -1, -1, -1,
2341 -1, -1, -1, -1, -1, -1, -1, 146, 36, -1,
2342 149, -1, -1, 152, -1, 154, 155, -1, 46, -1,
2343 -1, -1, -1, -1, -1, 146, -1, -1, 149, -1,
2344 -1, 152, -1, 154, 155, -1, -1, -1, -1, -1,
2345 -1, -1, -1, -1, 146, -1, -1, 149, -1, -1,
2346 152, -1, 154, 118, 7, 8, -1, 10, 11, 12,
2347 13, 14, -1, 16, 17, -1, 19, 20, 21, -1,
2348 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2349 -1, 146, -1, -1, 149, -1, -1, 152, -1, 154,
2350 -1, 7, 8, 46, 10, 11, 12, 13, 14, -1,
2351 16, 17, -1, 19, 20, 21, -1, -1, -1, -1,
2352 -1, -1, -1, -1, -1, -1, -1, -1, 146, -1,
2353 36, 149, -1, -1, 152, -1, 154, -1, 7, 8,
2354 46, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2355 19, 20, 21, -1, -1, -1, 7, 8, -1, 10,
2356 11, 12, 13, 14, -1, 16, 17, 36, 19, 20,
2357 21, -1, -1, -1, -1, 7, 8, 46, 10, 11,
2358 12, 13, 14, -1, 16, 17, -1, 19, 20, 21,
2359 -1, -1, -1, -1, -1, 46, -1, -1, -1, -1,
2360 -1, -1, -1, 146, -1, -1, 149, -1, 151, 152,
2361 -1, 154, 7, 8, 46, 10, 11, 12, 13, 14,
2362 -1, 16, 17, -1, 19, 20, 21, -1, -1, -1,
2363 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2364 146, -1, -1, 149, -1, -1, 152, -1, 154, 7,
2365 8, 46, 10, 11, 12, 13, 14, -1, 16, 17,
2366 -1, 19, 20, 21, -1, -1, -1, -1, -1, -1,
2367 -1, -1, -1, -1, -1, -1, -1, 146, -1, -1,
2368 149, -1, -1, 152, -1, 154, -1, -1, 46, -1,
2369 -1, -1, -1, -1, -1, 146, -1, -1, 149, -1,
2370 -1, 152, -1, 154, -1, -1, -1, -1, -1, -1,
2371 -1, -1, -1, -1, 146, -1, -1, 149, -1, -1,
2372 152, -1, 154, 7, 8, -1, 10, 11, 12, 13,
2373 14, -1, 16, 17, -1, 19, 20, 21, -1, -1,
2374 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2375 -1, 146, -1, -1, 149, -1, -1, 152, -1, 154,
2376 7, 8, 46, 10, 11, 12, 13, 14, -1, 16,
2377 17, -1, 19, 20, 21, -1, -1, -1, -1, -1,
2378 -1, -1, -1, -1, -1, -1, -1, -1, 146, -1,
2379 -1, 149, -1, -1, 152, -1, 154, 33, -1, 46,
2380 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2381 -1, -1, -1, -1, -1, -1, 52, 53, -1, -1,
2382 -1, -1, -1, -1, -1, -1, -1, -1, 64, 65,
2383 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2384 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2385 86, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2386 -1, -1, 146, -1, -1, 149, -1, -1, 152, -1,
2387 154, 107, 108, 109, -1, -1, 112, 113, 114, 115,
2388 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2389 126, 127, 128, 129, 130, -1, -1, -1, -1, 146,
2390 -1, -1, 149, -1, -1, 152, -1, 154
Reid Spencerb8f85052007-07-31 03:50:36 +00002391};
2392
2393/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2394 symbol of state STATE-NUM. */
2395static const unsigned char yystos[] =
2396{
2397 0, 16, 17, 19, 20, 21, 27, 28, 48, 51,
2398 55, 165, 167, 168, 169, 170, 201, 202, 203, 205,
2399 204, 49, 63, 210, 143, 54, 143, 15, 143, 39,
2400 40, 41, 42, 43, 44, 45, 47, 140, 141, 142,
2401 171, 172, 173, 0, 203, 43, 45, 174, 220, 39,
2402 40, 41, 44, 175, 217, 219, 226, 143, 143, 149,
2403 211, 19, 209, 7, 8, 10, 11, 12, 13, 14,
2404 46, 146, 149, 152, 154, 165, 168, 188, 189, 223,
2405 173, 173, 32, 34, 199, 173, 173, 18, 227, 228,
2406 26, 155, 218, 227, 19, 19, 19, 212, 147, 4,
2407 4, 4, 154, 10, 155, 189, 194, 145, 147, 199,
2408 199, 39, 41, 176, 29, 30, 198, 57, 58, 59,
2409 60, 61, 62, 177, 215, 215, 167, 231, 144, 151,
2410 36, 189, 190, 192, 193, 150, 150, 155, 194, 144,
2411 155, 193, 198, 198, 10, 118, 189, 191, 200, 11,
2412 12, 13, 163, 164, 189, 195, 4, 191, 25, 154,
2413 216, 33, 52, 53, 64, 65, 66, 67, 68, 69,
2414 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2415 80, 81, 82, 83, 84, 85, 86, 107, 108, 109,
2416 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2417 122, 123, 124, 125, 126, 127, 128, 129, 130, 158,
2418 159, 160, 229, 235, 236, 237, 238, 19, 179, 144,
2419 148, 189, 189, 153, 155, 189, 148, 195, 189, 147,
2420 223, 23, 24, 3, 4, 5, 6, 9, 22, 37,
2421 38, 85, 86, 112, 126, 128, 129, 130, 149, 152,
2422 154, 156, 158, 159, 160, 196, 223, 206, 168, 52,
2423 10, 189, 225, 11, 14, 11, 163, 177, 87, 88,
2424 89, 90, 91, 92, 93, 94, 95, 96, 161, 23,
2425 24, 93, 94, 95, 96, 97, 98, 99, 100, 101,
2426 102, 103, 104, 105, 106, 162, 189, 189, 225, 189,
2427 189, 232, 225, 225, 225, 225, 225, 189, 189, 225,
2428 177, 110, 111, 114, 115, 131, 132, 134, 135, 137,
2429 138, 139, 178, 36, 190, 181, 151, 153, 153, 181,
2430 207, 208, 200, 161, 162, 147, 147, 147, 147, 147,
2431 151, 195, 197, 154, 197, 155, 197, 19, 147, 147,
2432 147, 144, 186, 147, 3, 4, 9, 22, 23, 24,
2433 37, 38, 54, 152, 196, 222, 223, 224, 224, 224,
2434 224, 191, 189, 189, 144, 183, 144, 183, 224, 149,
2435 144, 144, 144, 144, 144, 144, 224, 224, 35, 191,
Reid Spenceree0142e2007-07-31 06:37:43 +00002436 189, 225, 131, 132, 133, 134, 136, 180, 186, 186,
2437 35, 147, 147, 195, 195, 195, 195, 195, 144, 151,
2438 155, 189, 197, 153, 155, 195, 195, 195, 31, 50,
2439 184, 187, 36, 189, 213, 214, 56, 221, 197, 144,
2440 144, 224, 224, 224, 11, 50, 11, 234, 224, 149,
2441 225, 189, 225, 225, 225, 144, 144, 189, 224, 224,
2442 144, 189, 195, 195, 234, 144, 144, 144, 144, 195,
2443 153, 155, 144, 144, 35, 19, 4, 186, 179, 144,
2444 148, 19, 153, 14, 14, 147, 144, 144, 224, 4,
2445 224, 144, 144, 224, 144, 144, 144, 224, 224, 147,
2446 144, 183, 189, 148, 144, 144, 148, 195, 195, 195,
2447 195, 153, 195, 195, 189, 165, 166, 36, 189, 181,
2448 144, 224, 224, 189, 233, 224, 224, 183, 183, 225,
2449 224, 144, 225, 225, 225, 233, 224, 195, 195, 144,
2450 148, 144, 144, 148, 148, 148, 179, 184, 185, 19,
2451 144, 149, 224, 144, 148, 151, 224, 148, 183, 148,
2452 148, 195, 195, 195, 166, 50, 182, 14, 151, 163,
2453 230, 179, 189, 181, 151, 181, 148, 148, 148, 4,
2454 224, 222, 151, 163, 224, 35, 144, 222, 179, 14,
2455 14, 144, 224, 224, 14, 68, 224, 14, 224
Reid Spencerb8f85052007-07-31 03:50:36 +00002456};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002457
2458#define yyerrok (yyerrstatus = 0)
2459#define yyclearin (yychar = YYEMPTY)
Reid Spencerb8f85052007-07-31 03:50:36 +00002460#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002461#define YYEOF 0
Reid Spencerb8f85052007-07-31 03:50:36 +00002462
Reid Spencer68a24bd2005-08-27 18:50:39 +00002463#define YYACCEPT goto yyacceptlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002464#define YYABORT goto yyabortlab
2465#define YYERROR goto yyerrorlab
2466
2467
2468/* Like YYERROR except do call yyerror. This remains here temporarily
2469 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002470 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002471
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472#define YYFAIL goto yyerrlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002473
Reid Spencer68a24bd2005-08-27 18:50:39 +00002474#define YYRECOVERING() (!!yyerrstatus)
Reid Spencerb8f85052007-07-31 03:50:36 +00002475
2476#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002477do \
2478 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencerb8f85052007-07-31 03:50:36 +00002479 { \
2480 yychar = (Token); \
2481 yylval = (Value); \
2482 yytoken = YYTRANSLATE (yychar); \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002483 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002484 goto yybackup; \
2485 } \
2486 else \
Reid Spencerb8f85052007-07-31 03:50:36 +00002487 { \
2488 yyerror (YY_("syntax error: cannot back up")); \
2489 YYERROR; \
2490 } \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002491while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002492
Reid Spencerb8f85052007-07-31 03:50:36 +00002493
Reid Spencer68a24bd2005-08-27 18:50:39 +00002494#define YYTERROR 1
2495#define YYERRCODE 256
2496
Reid Spencerb8f85052007-07-31 03:50:36 +00002497
2498/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2499 If N is 0, then set CURRENT to the empty location which ends
2500 the previous symbol: RHS[0] (always defined). */
2501
2502#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2503#ifndef YYLLOC_DEFAULT
2504# define YYLLOC_DEFAULT(Current, Rhs, N) \
2505 do \
2506 if (N) \
2507 { \
2508 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2509 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2510 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2511 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2512 } \
2513 else \
2514 { \
2515 (Current).first_line = (Current).last_line = \
2516 YYRHSLOC (Rhs, 0).last_line; \
2517 (Current).first_column = (Current).last_column = \
2518 YYRHSLOC (Rhs, 0).last_column; \
2519 } \
2520 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002521#endif
2522
Reid Spencerb8f85052007-07-31 03:50:36 +00002523
2524/* YY_LOCATION_PRINT -- Print the location on the stream.
2525 This macro was not mandated originally: define only if we know
2526 we won't break user code: when these are the locations we know. */
2527
2528#ifndef YY_LOCATION_PRINT
2529# if YYLTYPE_IS_TRIVIAL
2530# define YY_LOCATION_PRINT(File, Loc) \
2531 fprintf (File, "%d.%d-%d.%d", \
2532 (Loc).first_line, (Loc).first_column, \
2533 (Loc).last_line, (Loc).last_column)
2534# else
2535# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2536# endif
2537#endif
2538
2539
2540/* YYLEX -- calling `yylex' with the right arguments. */
2541
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002542#ifdef YYLEX_PARAM
Reid Spencerb8f85052007-07-31 03:50:36 +00002543# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002544#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002545# define YYLEX yylex ()
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002546#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002547
2548/* Enable debugging if requested. */
2549#if YYDEBUG
2550
2551# ifndef YYFPRINTF
2552# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2553# define YYFPRINTF fprintf
2554# endif
2555
2556# define YYDPRINTF(Args) \
2557do { \
2558 if (yydebug) \
2559 YYFPRINTF Args; \
2560} while (0)
2561
2562# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2563do { \
2564 if (yydebug) \
2565 { \
2566 YYFPRINTF (stderr, "%s ", Title); \
2567 yysymprint (stderr, \
2568 Type, Value); \
2569 YYFPRINTF (stderr, "\n"); \
2570 } \
2571} while (0)
2572
2573/*------------------------------------------------------------------.
2574| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2575| TOP (included). |
2576`------------------------------------------------------------------*/
2577
2578#if defined (__STDC__) || defined (__cplusplus)
2579static void
2580yy_stack_print (short int *bottom, short int *top)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002581#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002582static void
2583yy_stack_print (bottom, top)
2584 short int *bottom;
2585 short int *top;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002586#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002587{
2588 YYFPRINTF (stderr, "Stack now");
2589 for (/* Nothing. */; bottom <= top; ++bottom)
2590 YYFPRINTF (stderr, " %d", *bottom);
2591 YYFPRINTF (stderr, "\n");
2592}
2593
2594# define YY_STACK_PRINT(Bottom, Top) \
2595do { \
2596 if (yydebug) \
2597 yy_stack_print ((Bottom), (Top)); \
2598} while (0)
2599
2600
2601/*------------------------------------------------.
2602| Report that the YYRULE is going to be reduced. |
2603`------------------------------------------------*/
2604
2605#if defined (__STDC__) || defined (__cplusplus)
2606static void
2607yy_reduce_print (int yyrule)
2608#else
2609static void
2610yy_reduce_print (yyrule)
2611 int yyrule;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002612#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002613{
2614 int yyi;
2615 unsigned long int yylno = yyrline[yyrule];
2616 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2617 yyrule - 1, yylno);
2618 /* Print the symbols being reduced, and their result. */
2619 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2620 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2621 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2622}
Reid Spencered951ea2007-05-19 07:22:10 +00002623
Reid Spencerb8f85052007-07-31 03:50:36 +00002624# define YY_REDUCE_PRINT(Rule) \
2625do { \
2626 if (yydebug) \
2627 yy_reduce_print (Rule); \
2628} while (0)
Reid Spencered951ea2007-05-19 07:22:10 +00002629
Reid Spencerb8f85052007-07-31 03:50:36 +00002630/* Nonzero means print parse trace. It is left uninitialized so that
2631 multiple parsers can coexist. */
2632int yydebug;
2633#else /* !YYDEBUG */
2634# define YYDPRINTF(Args)
2635# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2636# define YY_STACK_PRINT(Bottom, Top)
2637# define YY_REDUCE_PRINT(Rule)
2638#endif /* !YYDEBUG */
Reid Spencered951ea2007-05-19 07:22:10 +00002639
Reid Spencered951ea2007-05-19 07:22:10 +00002640
Reid Spencerb8f85052007-07-31 03:50:36 +00002641/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002642#ifndef YYINITDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002643# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002644#endif
2645
Reid Spencerb8f85052007-07-31 03:50:36 +00002646/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2647 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002648
Reid Spencerb8f85052007-07-31 03:50:36 +00002649 Do not make this value too large; the results are undefined if
2650 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2651 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002652
2653#ifndef YYMAXDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002654# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002655#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002656
Reid Spencer68a24bd2005-08-27 18:50:39 +00002657
2658
Reid Spencerb8f85052007-07-31 03:50:36 +00002659#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002660
Reid Spencerb8f85052007-07-31 03:50:36 +00002661# ifndef yystrlen
2662# if defined (__GLIBC__) && defined (_STRING_H)
2663# define yystrlen strlen
2664# else
2665/* Return the length of YYSTR. */
2666static YYSIZE_T
2667# if defined (__STDC__) || defined (__cplusplus)
2668yystrlen (const char *yystr)
2669# else
2670yystrlen (yystr)
2671 const char *yystr;
2672# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002673{
Reid Spencerb8f85052007-07-31 03:50:36 +00002674 const char *yys = yystr;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002675
Reid Spencerb8f85052007-07-31 03:50:36 +00002676 while (*yys++ != '\0')
2677 continue;
2678
2679 return yys - yystr - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002680}
Reid Spencerb8f85052007-07-31 03:50:36 +00002681# endif
2682# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002683
Reid Spencerb8f85052007-07-31 03:50:36 +00002684# ifndef yystpcpy
2685# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2686# define yystpcpy stpcpy
2687# else
2688/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2689 YYDEST. */
2690static char *
2691# if defined (__STDC__) || defined (__cplusplus)
2692yystpcpy (char *yydest, const char *yysrc)
2693# else
2694yystpcpy (yydest, yysrc)
2695 char *yydest;
2696 const char *yysrc;
2697# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002698{
Reid Spencerb8f85052007-07-31 03:50:36 +00002699 char *yyd = yydest;
2700 const char *yys = yysrc;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002701
Reid Spencerb8f85052007-07-31 03:50:36 +00002702 while ((*yyd++ = *yys++) != '\0')
2703 continue;
2704
2705 return yyd - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002706}
Reid Spencerb8f85052007-07-31 03:50:36 +00002707# endif
2708# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002709
Reid Spencerb8f85052007-07-31 03:50:36 +00002710# ifndef yytnamerr
2711/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2712 quotes and backslashes, so that it's suitable for yyerror. The
2713 heuristic is that double-quoting is unnecessary unless the string
2714 contains an apostrophe, a comma, or backslash (other than
2715 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2716 null, do not copy; instead, return the length of what the result
2717 would have been. */
2718static YYSIZE_T
2719yytnamerr (char *yyres, const char *yystr)
2720{
2721 if (*yystr == '"')
2722 {
2723 size_t yyn = 0;
2724 char const *yyp = yystr;
2725
2726 for (;;)
2727 switch (*++yyp)
2728 {
2729 case '\'':
2730 case ',':
2731 goto do_not_strip_quotes;
2732
2733 case '\\':
2734 if (*++yyp != '\\')
2735 goto do_not_strip_quotes;
2736 /* Fall through. */
2737 default:
2738 if (yyres)
2739 yyres[yyn] = *yyp;
2740 yyn++;
2741 break;
2742
2743 case '"':
2744 if (yyres)
2745 yyres[yyn] = '\0';
2746 return yyn;
2747 }
2748 do_not_strip_quotes: ;
2749 }
2750
2751 if (! yyres)
2752 return yystrlen (yystr);
2753
2754 return yystpcpy (yyres, yystr) - yyres;
2755}
2756# endif
2757
2758#endif /* YYERROR_VERBOSE */
2759
Reid Spencered951ea2007-05-19 07:22:10 +00002760
2761
Reid Spencerb8f85052007-07-31 03:50:36 +00002762#if YYDEBUG
2763/*--------------------------------.
2764| Print this symbol on YYOUTPUT. |
2765`--------------------------------*/
Reid Spencered951ea2007-05-19 07:22:10 +00002766
Reid Spencerb8f85052007-07-31 03:50:36 +00002767#if defined (__STDC__) || defined (__cplusplus)
2768static void
2769yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002770#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002771static void
2772yysymprint (yyoutput, yytype, yyvaluep)
2773 FILE *yyoutput;
2774 int yytype;
2775 YYSTYPE *yyvaluep;
2776#endif
2777{
2778 /* Pacify ``unused variable'' warnings. */
2779 (void) yyvaluep;
2780
2781 if (yytype < YYNTOKENS)
2782 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2783 else
2784 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2785
2786
2787# ifdef YYPRINT
2788 if (yytype < YYNTOKENS)
2789 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2790# endif
2791 switch (yytype)
2792 {
2793 default:
2794 break;
2795 }
2796 YYFPRINTF (yyoutput, ")");
2797}
2798
2799#endif /* ! YYDEBUG */
2800/*-----------------------------------------------.
2801| Release the memory associated to this symbol. |
2802`-----------------------------------------------*/
2803
2804#if defined (__STDC__) || defined (__cplusplus)
2805static void
2806yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2807#else
2808static void
2809yydestruct (yymsg, yytype, yyvaluep)
2810 const char *yymsg;
2811 int yytype;
2812 YYSTYPE *yyvaluep;
2813#endif
2814{
2815 /* Pacify ``unused variable'' warnings. */
2816 (void) yyvaluep;
2817
2818 if (!yymsg)
2819 yymsg = "Deleting";
2820 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2821
2822 switch (yytype)
2823 {
2824
2825 default:
2826 break;
2827 }
2828}
2829
2830
2831/* Prevent warnings from -Wmissing-prototypes. */
2832
2833#ifdef YYPARSE_PARAM
2834# if defined (__STDC__) || defined (__cplusplus)
2835int yyparse (void *YYPARSE_PARAM);
2836# else
2837int yyparse ();
2838# endif
2839#else /* ! YYPARSE_PARAM */
2840#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002841int yyparse (void);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002842#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002843int yyparse ();
2844#endif
2845#endif /* ! YYPARSE_PARAM */
2846
2847
2848
2849/* The look-ahead symbol. */
2850int yychar;
2851
2852/* The semantic value of the look-ahead symbol. */
2853YYSTYPE yylval;
2854
2855/* Number of syntax errors so far. */
2856int yynerrs;
2857
2858
2859
2860/*----------.
2861| yyparse. |
2862`----------*/
2863
2864#ifdef YYPARSE_PARAM
2865# if defined (__STDC__) || defined (__cplusplus)
2866int yyparse (void *YYPARSE_PARAM)
2867# else
2868int yyparse (YYPARSE_PARAM)
2869 void *YYPARSE_PARAM;
2870# endif
2871#else /* ! YYPARSE_PARAM */
2872#if defined (__STDC__) || defined (__cplusplus)
2873int
2874yyparse (void)
2875#else
2876int
2877yyparse ()
2878
2879#endif
2880#endif
2881{
2882
2883 int yystate;
2884 int yyn;
2885 int yyresult;
2886 /* Number of tokens to shift before error messages enabled. */
2887 int yyerrstatus;
2888 /* Look-ahead token as an internal (translated) token number. */
2889 int yytoken = 0;
2890
2891 /* Three stacks and their tools:
2892 `yyss': related to states,
2893 `yyvs': related to semantic values,
2894 `yyls': related to locations.
2895
2896 Refer to the stacks thru separate pointers, to allow yyoverflow
2897 to reallocate them elsewhere. */
2898
2899 /* The state stack. */
2900 short int yyssa[YYINITDEPTH];
2901 short int *yyss = yyssa;
2902 short int *yyssp;
2903
2904 /* The semantic value stack. */
2905 YYSTYPE yyvsa[YYINITDEPTH];
2906 YYSTYPE *yyvs = yyvsa;
2907 YYSTYPE *yyvsp;
2908
2909
2910
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002911#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002912
Reid Spencerb8f85052007-07-31 03:50:36 +00002913 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002914
Reid Spencerb8f85052007-07-31 03:50:36 +00002915 /* The variables used to return semantic value and location from the
2916 action routines. */
2917 YYSTYPE yyval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002918
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002919
Reid Spencerb8f85052007-07-31 03:50:36 +00002920 /* When reducing, the number of symbols on the RHS of the reduced
2921 rule. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002922 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002923
Reid Spencerb8f85052007-07-31 03:50:36 +00002924 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002925
Reid Spencer68a24bd2005-08-27 18:50:39 +00002926 yystate = 0;
2927 yyerrstatus = 0;
2928 yynerrs = 0;
2929 yychar = YYEMPTY; /* Cause a token to be read. */
2930
2931 /* Initialize stack pointers.
2932 Waste one element of value and location stack
2933 so that they stay on the same level as the state stack.
2934 The wasted elements are never initialized. */
2935
Reid Spencerb8f85052007-07-31 03:50:36 +00002936 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937 yyvsp = yyvs;
2938
Reid Spencerb8f85052007-07-31 03:50:36 +00002939 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002940
Reid Spencerb8f85052007-07-31 03:50:36 +00002941/*------------------------------------------------------------.
2942| yynewstate -- Push a new state, which is found in yystate. |
2943`------------------------------------------------------------*/
2944 yynewstate:
2945 /* In all cases, when you get here, the value and location stacks
2946 have just been pushed. so pushing a state here evens the stacks.
2947 */
2948 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002949
Reid Spencerb8f85052007-07-31 03:50:36 +00002950 yysetstate:
2951 *yyssp = yystate;
2952
2953 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 {
2955 /* Get the current used size of the three stacks, in elements. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002956 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957
2958#ifdef yyoverflow
Reid Spencerb8f85052007-07-31 03:50:36 +00002959 {
2960 /* Give user a chance to reallocate the stack. Use copies of
2961 these so that the &'s don't force the real ones into
2962 memory. */
2963 YYSTYPE *yyvs1 = yyvs;
2964 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002965
Reid Spencerb8f85052007-07-31 03:50:36 +00002966
2967 /* Each stack pointer address is followed by the size of the
2968 data in use in that stack, in bytes. This used to be a
2969 conditional around just the two extra args, but that might
2970 be undefined if yyoverflow is a macro. */
2971 yyoverflow (YY_("memory exhausted"),
2972 &yyss1, yysize * sizeof (*yyssp),
2973 &yyvs1, yysize * sizeof (*yyvsp),
2974
2975 &yystacksize);
2976
2977 yyss = yyss1;
2978 yyvs = yyvs1;
2979 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002980#else /* no yyoverflow */
Reid Spencerb8f85052007-07-31 03:50:36 +00002981# ifndef YYSTACK_RELOCATE
2982 goto yyexhaustedlab;
2983# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002984 /* Extend the stack our own way. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002985 if (YYMAXDEPTH <= yystacksize)
2986 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002987 yystacksize *= 2;
Reid Spencerb8f85052007-07-31 03:50:36 +00002988 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002989 yystacksize = YYMAXDEPTH;
Reid Spencerb8f85052007-07-31 03:50:36 +00002990
2991 {
2992 short int *yyss1 = yyss;
2993 union yyalloc *yyptr =
2994 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2995 if (! yyptr)
2996 goto yyexhaustedlab;
2997 YYSTACK_RELOCATE (yyss);
2998 YYSTACK_RELOCATE (yyvs);
2999
3000# undef YYSTACK_RELOCATE
3001 if (yyss1 != yyssa)
3002 YYSTACK_FREE (yyss1);
3003 }
3004# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00003005#endif /* no yyoverflow */
3006
Reid Spencerb8f85052007-07-31 03:50:36 +00003007 yyssp = yyss + yysize - 1;
3008 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009
3010
Reid Spencerb8f85052007-07-31 03:50:36 +00003011 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3012 (unsigned long int) yystacksize));
3013
3014 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003015 YYABORT;
3016 }
3017
Reid Spencerb8f85052007-07-31 03:50:36 +00003018 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003019
3020 goto yybackup;
Reid Spencerb8f85052007-07-31 03:50:36 +00003021
3022/*-----------.
3023| yybackup. |
3024`-----------*/
3025yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003026
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003027/* Do appropriate processing given the current state. */
Reid Spencerb8f85052007-07-31 03:50:36 +00003028/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003029/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00003030
Reid Spencerb8f85052007-07-31 03:50:36 +00003031 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00003032
Reid Spencer68a24bd2005-08-27 18:50:39 +00003033 yyn = yypact[yystate];
Reid Spencerb8f85052007-07-31 03:50:36 +00003034 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003035 goto yydefault;
3036
Reid Spencerb8f85052007-07-31 03:50:36 +00003037 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003038
Reid Spencerb8f85052007-07-31 03:50:36 +00003039 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003040 if (yychar == YYEMPTY)
3041 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003042 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003043 yychar = YYLEX;
3044 }
3045
Reid Spencerb8f85052007-07-31 03:50:36 +00003046 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003047 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003048 yychar = yytoken = YYEOF;
3049 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003050 }
3051 else
3052 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003053 yytoken = YYTRANSLATE (yychar);
3054 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003055 }
3056
Reid Spencerb8f85052007-07-31 03:50:36 +00003057 /* If the proper action on seeing token YYTOKEN is to reduce or to
3058 detect an error, take that action. */
3059 yyn += yytoken;
3060 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003061 goto yydefault;
3062 yyn = yytable[yyn];
Reid Spencerb8f85052007-07-31 03:50:36 +00003063 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003064 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003065 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003066 goto yyerrlab;
3067 yyn = -yyn;
3068 goto yyreduce;
3069 }
3070
3071 if (yyn == YYFINAL)
3072 YYACCEPT;
3073
Reid Spencerb8f85052007-07-31 03:50:36 +00003074 /* Shift the look-ahead token. */
3075 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003076
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003077 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003078 if (yychar != YYEOF)
3079 yychar = YYEMPTY;
3080
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003081 *++yyvsp = yylval;
3082
Reid Spencerb8f85052007-07-31 03:50:36 +00003083
3084 /* Count tokens shifted since error; after three, turn off error
3085 status. */
3086 if (yyerrstatus)
3087 yyerrstatus--;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00003088
3089 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003090 goto yynewstate;
3091
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003092
Reid Spencerb8f85052007-07-31 03:50:36 +00003093/*-----------------------------------------------------------.
3094| yydefault -- do the default action for the current state. |
3095`-----------------------------------------------------------*/
3096yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003097 yyn = yydefact[yystate];
3098 if (yyn == 0)
3099 goto yyerrlab;
Reid Spencerb8f85052007-07-31 03:50:36 +00003100 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003101
Reid Spencerb8f85052007-07-31 03:50:36 +00003102
3103/*-----------------------------.
3104| yyreduce -- Do a reduction. |
3105`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003106yyreduce:
Reid Spencerb8f85052007-07-31 03:50:36 +00003107 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003108 yylen = yyr2[yyn];
3109
Reid Spencerb8f85052007-07-31 03:50:36 +00003110 /* If YYLEN is nonzero, implement the default value of the action:
3111 `$$ = $1'.
3112
3113 Otherwise, the following line sets YYVAL to garbage.
3114 This behavior is undocumented and Bison
3115 users should not rely upon it. Assigning to YYVAL
3116 unconditionally makes the parser a bit smaller, and it avoids a
3117 GCC warning that YYVAL may be used uninitialized. */
3118 yyval = yyvsp[1-yylen];
3119
3120
3121 YY_REDUCE_PRINT (yyn);
3122 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003123 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003124 case 29:
3125#line 1122 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3126 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3127 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003128
Reid Spencerb8f85052007-07-31 03:50:36 +00003129 case 30:
3130#line 1122 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3131 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3132 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003133
Reid Spencerb8f85052007-07-31 03:50:36 +00003134 case 31:
3135#line 1123 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3136 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3137 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003138
Reid Spencerb8f85052007-07-31 03:50:36 +00003139 case 32:
3140#line 1123 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3141 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3142 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003143
Reid Spencerb8f85052007-07-31 03:50:36 +00003144 case 33:
3145#line 1124 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3146 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3147 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003148
Reid Spencerb8f85052007-07-31 03:50:36 +00003149 case 34:
3150#line 1124 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3151 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3152 break;
3153
3154 case 35:
3155#line 1125 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3156 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3157 break;
3158
3159 case 36:
3160#line 1125 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3161 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3162 break;
3163
3164 case 37:
3165#line 1126 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3166 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3167 break;
3168
3169 case 38:
3170#line 1126 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3171 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3172 break;
3173
3174 case 39:
3175#line 1130 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3176 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3177 break;
3178
3179 case 40:
3180#line 1130 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3181 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3182 break;
3183
3184 case 41:
3185#line 1131 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3186 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3187 break;
3188
3189 case 42:
3190#line 1131 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3191 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3192 break;
3193
3194 case 43:
3195#line 1132 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3196 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3197 break;
3198
3199 case 44:
3200#line 1132 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3201 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3202 break;
3203
3204 case 45:
3205#line 1133 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3206 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3207 break;
3208
3209 case 46:
3210#line 1133 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3211 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3212 break;
3213
3214 case 47:
3215#line 1134 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3216 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3217 break;
3218
3219 case 48:
3220#line 1134 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3221 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3222 break;
3223
3224 case 49:
3225#line 1135 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3226 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3227 break;
3228
3229 case 50:
3230#line 1135 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3231 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3232 break;
3233
3234 case 51:
3235#line 1136 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3236 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3237 break;
3238
3239 case 52:
3240#line 1136 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3241 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3242 break;
3243
3244 case 53:
3245#line 1137 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3246 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3247 break;
3248
3249 case 54:
3250#line 1138 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3251 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3252 break;
3253
3254 case 62:
3255#line 1147 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3256 { (yyval.StrVal) = 0; ;}
3257 break;
3258
3259 case 63:
3260#line 1151 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3261 {
3262 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003263 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003264 ;}
3265 break;
3266
3267 case 64:
3268#line 1155 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3269 {
3270 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003271 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003272 ;}
3273 break;
3274
3275 case 68:
3276#line 1163 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3277 {
3278 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003279 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003280 ;}
3281 break;
3282
3283 case 69:
3284#line 1168 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3285 {
3286 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003287 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003288 ;}
3289 break;
3290
3291 case 70:
3292#line 1174 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3293 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3294 break;
3295
3296 case 71:
3297#line 1175 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3298 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3299 break;
3300
3301 case 72:
3302#line 1176 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3303 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3304 break;
3305
3306 case 73:
3307#line 1177 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3308 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3309 break;
3310
3311 case 74:
3312#line 1178 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3313 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3314 break;
3315
3316 case 75:
3317#line 1182 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3318 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3319 break;
3320
3321 case 76:
3322#line 1183 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3323 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3324 break;
3325
3326 case 77:
3327#line 1184 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3328 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3329 break;
3330
3331 case 78:
3332#line 1188 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3333 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3334 break;
3335
3336 case 79:
3337#line 1189 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3338 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3339 break;
3340
3341 case 80:
3342#line 1190 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3343 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3344 break;
3345
3346 case 81:
3347#line 1191 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3348 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3349 break;
3350
3351 case 82:
3352#line 1195 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3353 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3354 break;
3355
3356 case 83:
3357#line 1196 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3358 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3359 break;
3360
3361 case 84:
3362#line 1197 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3363 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3364 break;
3365
3366 case 85:
3367#line 1201 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3368 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3369 break;
3370
3371 case 86:
3372#line 1202 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3373 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3374 break;
3375
3376 case 87:
3377#line 1203 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3378 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3379 break;
3380
3381 case 88:
3382#line 1204 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3383 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3384 break;
3385
3386 case 89:
3387#line 1205 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3388 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3389 break;
3390
3391 case 90:
3392#line 1209 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3393 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3394 break;
3395
3396 case 91:
3397#line 1210 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3398 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3399 break;
3400
3401 case 92:
3402#line 1211 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3403 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3404 break;
3405
3406 case 93:
3407#line 1214 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3408 { (yyval.UIntVal) = CallingConv::C; ;}
3409 break;
3410
3411 case 94:
3412#line 1215 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3413 { (yyval.UIntVal) = CallingConv::C; ;}
3414 break;
3415
3416 case 95:
3417#line 1216 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3418 { (yyval.UIntVal) = CallingConv::Fast; ;}
3419 break;
3420
3421 case 96:
3422#line 1217 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3423 { (yyval.UIntVal) = CallingConv::Cold; ;}
3424 break;
3425
3426 case 97:
3427#line 1218 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3428 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3429 break;
3430
3431 case 98:
3432#line 1219 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3433 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3434 break;
3435
3436 case 99:
3437#line 1220 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3438 {
3439 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003440 GEN_ERROR("Calling conv too large");
Reid Spencerb8f85052007-07-31 03:50:36 +00003441 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003442 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003443 ;}
3444 break;
3445
3446 case 100:
3447#line 1227 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3448 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3449 break;
3450
3451 case 101:
3452#line 1228 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3453 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3454 break;
3455
3456 case 102:
3457#line 1229 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3458 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3459 break;
3460
3461 case 103:
3462#line 1230 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3463 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3464 break;
3465
3466 case 104:
3467#line 1231 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3468 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3469 break;
3470
3471 case 105:
3472#line 1232 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3473 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3474 break;
3475
3476 case 106:
3477#line 1233 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3478 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3479 break;
3480
3481 case 107:
3482#line 1234 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3483 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3484 break;
3485
3486 case 108:
3487#line 1235 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3488 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3489 break;
3490
3491 case 109:
3492#line 1238 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3493 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3494 break;
3495
3496 case 110:
3497#line 1239 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3498 {
3499 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
3500 ;}
3501 break;
3502
3503 case 111:
3504#line 1244 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3505 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3506 break;
3507
3508 case 112:
3509#line 1245 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3510 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3511 break;
3512
3513 case 113:
3514#line 1246 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3515 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3516 break;
3517
3518 case 114:
3519#line 1247 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3520 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3521 break;
3522
3523 case 115:
Reid Spenceree0142e2007-07-31 06:37:43 +00003524#line 1248 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3525 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003526 break;
3527
3528 case 116:
3529#line 1251 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spenceree0142e2007-07-31 06:37:43 +00003530 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3531 break;
3532
3533 case 117:
3534#line 1252 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003535 {
3536 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
3537 ;}
3538 break;
3539
Reid Spenceree0142e2007-07-31 06:37:43 +00003540 case 118:
3541#line 1259 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003542 { (yyval.UIntVal) = 0; ;}
3543 break;
3544
Reid Spenceree0142e2007-07-31 06:37:43 +00003545 case 119:
3546#line 1260 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003547 {
3548 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3549 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003550 GEN_ERROR("Alignment must be a power of two");
3551 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003552;}
3553 break;
3554
Reid Spencerb8f85052007-07-31 03:50:36 +00003555 case 120:
3556#line 1266 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spenceree0142e2007-07-31 06:37:43 +00003557 { (yyval.UIntVal) = 0; ;}
3558 break;
3559
3560 case 121:
3561#line 1267 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003562 {
3563 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3564 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003565 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003566 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003567;}
3568 break;
3569
Reid Spenceree0142e2007-07-31 06:37:43 +00003570 case 122:
3571#line 1275 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003572 {
3573 for (unsigned i = 0, e = (yyvsp[0].StrVal)->length(); i != e; ++i)
3574 if ((*(yyvsp[0].StrVal))[i] == '"' || (*(yyvsp[0].StrVal))[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003575 GEN_ERROR("Invalid character in section name");
Reid Spencerb8f85052007-07-31 03:50:36 +00003576 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003577 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003578;}
3579 break;
3580
Reid Spenceree0142e2007-07-31 06:37:43 +00003581 case 123:
3582#line 1283 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003583 { (yyval.StrVal) = 0; ;}
3584 break;
3585
Reid Spencerb8f85052007-07-31 03:50:36 +00003586 case 124:
Reid Spenceree0142e2007-07-31 06:37:43 +00003587#line 1284 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3588 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003589 break;
3590
3591 case 125:
3592#line 1289 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
3593 {;}
3594 break;
3595
3596 case 126:
3597#line 1290 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spenceree0142e2007-07-31 06:37:43 +00003598 {;}
3599 break;
3600
3601 case 127:
3602#line 1291 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003603 {
3604 CurGV->setSection(*(yyvsp[0].StrVal));
3605 delete (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003606 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003607 ;}
3608 break;
3609
Reid Spenceree0142e2007-07-31 06:37:43 +00003610 case 128:
3611#line 1296 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003612 {
3613 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003614 GEN_ERROR("Alignment must be a power of two");
Reid Spencerb8f85052007-07-31 03:50:36 +00003615 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003616 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003617 ;}
3618 break;
3619
Reid Spenceree0142e2007-07-31 06:37:43 +00003620 case 133:
3621#line 1312 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003622 {
3623 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003624 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003625 ;}
3626 break;
3627
Reid Spenceree0142e2007-07-31 06:37:43 +00003628 case 134:
3629#line 1316 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003630 {
3631 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003632 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003633 ;}
3634 break;
3635
Reid Spenceree0142e2007-07-31 06:37:43 +00003636 case 135:
3637#line 1320 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003638 { // Pointer type?
3639 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003640 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencerb8f85052007-07-31 03:50:36 +00003641 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3642 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003643 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003644 ;}
3645 break;
3646
Reid Spenceree0142e2007-07-31 06:37:43 +00003647 case 136:
3648#line 1327 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003649 { // Named types are also simple types...
3650 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003651 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003652 (yyval.TypeVal) = new PATypeHolder(tmp);
3653 ;}
3654 break;
3655
Reid Spenceree0142e2007-07-31 06:37:43 +00003656 case 137:
3657#line 1332 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003658 { // Type UpReference
3659 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003660 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencerb8f85052007-07-31 03:50:36 +00003661 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3662 (yyval.TypeVal) = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003663 UR_OUT("New Upreference!\n");
3664 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003665 ;}
3666 break;
3667
Reid Spenceree0142e2007-07-31 06:37:43 +00003668 case 138:
3669#line 1340 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003670 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003671 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003672 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003673 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3674 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003675 Attrs.push_back(X);
3676 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003677 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00003678 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003679 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003680 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003681 Params.push_back(Ty);
3682 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003683 if (I->Attrs != ParamAttr::None) {
3684 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3685 Attrs.push_back(X);
3686 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003687 }
3688 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3689 if (isVarArg) Params.pop_back();
3690
Reid Spencer7b5d4662007-04-09 06:16:21 +00003691 ParamAttrsList *ActualAttrs = 0;
3692 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003693 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencerb8f85052007-07-31 03:50:36 +00003694 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, ActualAttrs);
3695 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3696 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3697 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003698 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003699 ;}
3700 break;
3701
Reid Spenceree0142e2007-07-31 06:37:43 +00003702 case 139:
3703#line 1370 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003704 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003705 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003706 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003707 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
3708 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00003709 Attrs.push_back(X);
3710 }
Reid Spencerb8f85052007-07-31 03:50:36 +00003711 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003712 unsigned index = 1;
3713 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003714 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003715 Params.push_back(Ty);
3716 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003717 if (I->Attrs != ParamAttr::None) {
3718 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3719 Attrs.push_back(X);
3720 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003721 }
3722 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3723 if (isVarArg) Params.pop_back();
3724
Reid Spencer7b5d4662007-04-09 06:16:21 +00003725 ParamAttrsList *ActualAttrs = 0;
3726 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003727 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003728
Reid Spencerb8f85052007-07-31 03:50:36 +00003729 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, ActualAttrs);
3730 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3731 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003732 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003733 ;}
3734 break;
3735
Reid Spenceree0142e2007-07-31 06:37:43 +00003736 case 140:
3737#line 1401 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003738 { // Sized array type?
3739 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3740 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003741 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003742 ;}
3743 break;
3744
Reid Spenceree0142e2007-07-31 06:37:43 +00003745 case 141:
3746#line 1406 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003747 { // Vector type?
3748 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3749 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003750 GEN_ERROR("Unsigned result not equal to signed result");
3751 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3752 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencerb8f85052007-07-31 03:50:36 +00003753 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003754 GEN_ERROR("Vector length should be a power of 2");
Reid Spencerb8f85052007-07-31 03:50:36 +00003755 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3756 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003757 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003758 ;}
3759 break;
3760
Reid Spenceree0142e2007-07-31 06:37:43 +00003761 case 142:
3762#line 1418 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003763 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003764 std::vector<const Type*> Elements;
Reid Spencerb8f85052007-07-31 03:50:36 +00003765 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3766 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003767 Elements.push_back(*I);
3768
Reid Spencerb8f85052007-07-31 03:50:36 +00003769 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3770 delete (yyvsp[-1].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003771 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003772 ;}
3773 break;
3774
Reid Spenceree0142e2007-07-31 06:37:43 +00003775 case 143:
3776#line 1428 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003777 { // Empty structure type?
3778 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003779 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003780 ;}
3781 break;
3782
Reid Spenceree0142e2007-07-31 06:37:43 +00003783 case 144:
3784#line 1432 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003785 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003786 std::vector<const Type*> Elements;
Reid Spencerb8f85052007-07-31 03:50:36 +00003787 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3788 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003789 Elements.push_back(*I);
3790
Reid Spencerb8f85052007-07-31 03:50:36 +00003791 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3792 delete (yyvsp[-2].TypeList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003793 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003794 ;}
3795 break;
3796
Reid Spenceree0142e2007-07-31 06:37:43 +00003797 case 145:
3798#line 1442 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003799 { // Empty structure type?
3800 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003801 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003802 ;}
3803 break;
3804
Reid Spenceree0142e2007-07-31 06:37:43 +00003805 case 146:
3806#line 1449 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003807 {
3808 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3809 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3810 ;}
3811 break;
3812
Reid Spenceree0142e2007-07-31 06:37:43 +00003813 case 147:
3814#line 1456 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003815 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003816 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003817 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3818 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003819 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencerb8f85052007-07-31 03:50:36 +00003820 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3821 ;}
3822 break;
3823
Reid Spenceree0142e2007-07-31 06:37:43 +00003824 case 148:
3825#line 1463 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003826 {
3827 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3828 ;}
3829 break;
3830
Reid Spenceree0142e2007-07-31 06:37:43 +00003831 case 149:
3832#line 1468 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003833 {
3834 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3835 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003836 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003837 ;}
3838 break;
3839
Reid Spenceree0142e2007-07-31 06:37:43 +00003840 case 150:
3841#line 1473 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003842 {
3843 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003844 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003845 ;}
3846 break;
3847
Reid Spenceree0142e2007-07-31 06:37:43 +00003848 case 152:
3849#line 1481 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003850 {
3851 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer18da0722007-04-11 02:44:20 +00003852 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003853 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb8f85052007-07-31 03:50:36 +00003854 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003855 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003856 ;}
3857 break;
3858
Reid Spenceree0142e2007-07-31 06:37:43 +00003859 case 153:
3860#line 1488 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003861 {
3862 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003863 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3864 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencerb8f85052007-07-31 03:50:36 +00003865 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003866 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003867 ;}
3868 break;
3869
Reid Spenceree0142e2007-07-31 06:37:43 +00003870 case 154:
3871#line 1495 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003872 {
3873 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003874 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003875 ;}
3876 break;
3877
Reid Spenceree0142e2007-07-31 06:37:43 +00003878 case 155:
3879#line 1503 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003880 {
3881 (yyval.TypeList) = new std::list<PATypeHolder>();
3882 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3883 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003884 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003885 ;}
3886 break;
3887
Reid Spenceree0142e2007-07-31 06:37:43 +00003888 case 156:
3889#line 1509 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003890 {
3891 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3892 delete (yyvsp[0].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003893 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003894 ;}
3895 break;
3896
Reid Spenceree0142e2007-07-31 06:37:43 +00003897 case 157:
3898#line 1521 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003899 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003900 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003901 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3902 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003903 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003904 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003905 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003906 const Type *ETy = ATy->getElementType();
3907 int NumElements = ATy->getNumElements();
3908
3909 // Verify that we have the correct size...
Reid Spencerb8f85052007-07-31 03:50:36 +00003910 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003911 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003912 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003913 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003914
3915 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00003916 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3917 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003918 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3919 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb8f85052007-07-31 03:50:36 +00003920 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003921 }
3922
Reid Spencerb8f85052007-07-31 03:50:36 +00003923 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3924 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003925 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003926 ;}
3927 break;
3928
Reid Spenceree0142e2007-07-31 06:37:43 +00003929 case 158:
3930#line 1549 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003931 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003932 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003933 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3934 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003935 if (ATy == 0)
3936 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003937 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003938
Andrew Lenharth6353e052006-12-08 18:07:09 +00003939 int NumElements = ATy->getNumElements();
3940 if (NumElements != -1 && NumElements != 0)
3941 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003942 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencerb8f85052007-07-31 03:50:36 +00003943 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3944 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003945 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003946 ;}
3947 break;
3948
Reid Spenceree0142e2007-07-31 06:37:43 +00003949 case 159:
3950#line 1565 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003951 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003952 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003953 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3954 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003955 if (ATy == 0)
3956 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003957 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003958
3959 int NumElements = ATy->getNumElements();
3960 const Type *ETy = ATy->getElementType();
Reid Spencerb8f85052007-07-31 03:50:36 +00003961 if (NumElements != -1 && NumElements != int((yyvsp[0].StrVal)->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003962 GEN_ERROR("Can't build string constant of size " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003963 itostr((int)((yyvsp[0].StrVal)->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003964 " when array has size " + itostr(NumElements) + "");
3965 std::vector<Constant*> Vals;
3966 if (ETy == Type::Int8Ty) {
Reid Spencerb8f85052007-07-31 03:50:36 +00003967 for (unsigned i = 0; i < (yyvsp[0].StrVal)->length(); ++i)
3968 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[0].StrVal))[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003969 } else {
Reid Spencerb8f85052007-07-31 03:50:36 +00003970 delete (yyvsp[0].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003971 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3972 }
Reid Spencerb8f85052007-07-31 03:50:36 +00003973 delete (yyvsp[0].StrVal);
3974 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3975 delete (yyvsp[-2].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003976 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003977 ;}
3978 break;
3979
Reid Spenceree0142e2007-07-31 06:37:43 +00003980 case 160:
3981#line 1592 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003982 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003983 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00003984 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3985 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003986 if (PTy == 0)
3987 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00003988 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003989 const Type *ETy = PTy->getElementType();
3990 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003991
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003992 // Verify that we have the correct size...
Reid Spencerb8f85052007-07-31 03:50:36 +00003993 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003994 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencerb8f85052007-07-31 03:50:36 +00003995 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003996 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003997
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003998 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00003999 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4000 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004001 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4002 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencerb8f85052007-07-31 03:50:36 +00004003 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004004 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00004005
Reid Spencerb8f85052007-07-31 03:50:36 +00004006 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
4007 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004008 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004009 ;}
4010 break;
4011
Reid Spenceree0142e2007-07-31 06:37:43 +00004012 case 161:
4013#line 1620 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004014 {
4015 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004016 if (STy == 0)
4017 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004018 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004019
Reid Spencerb8f85052007-07-31 03:50:36 +00004020 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004021 GEN_ERROR("Illegal number of initializers for structure type");
4022
4023 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb8f85052007-07-31 03:50:36 +00004024 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
4025 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004026 GEN_ERROR("Expected type '" +
4027 STy->getElementType(i)->getDescription() +
4028 "' for element #" + utostr(i) +
4029 " of structure initializer");
4030
4031 // Check to ensure that Type is not packed
4032 if (STy->isPacked())
4033 GEN_ERROR("Unpacked Initializer to vector type '" +
4034 STy->getDescription() + "'");
4035
Reid Spencerb8f85052007-07-31 03:50:36 +00004036 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
4037 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004038 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004039 ;}
4040 break;
4041
Reid Spenceree0142e2007-07-31 06:37:43 +00004042 case 162:
4043#line 1646 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004044 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004045 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004046 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4047 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004048 if (STy == 0)
4049 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004050 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004051
4052 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004053 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004054
4055 // Check to ensure that Type is not packed
4056 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00004057 GEN_ERROR("Unpacked Initializer to vector type '" +
4058 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004059
Reid Spencerb8f85052007-07-31 03:50:36 +00004060 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4061 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004062 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004063 ;}
4064 break;
4065
Reid Spenceree0142e2007-07-31 06:37:43 +00004066 case 163:
4067#line 1666 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004068 {
4069 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004070 if (STy == 0)
4071 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004072 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004073
Reid Spencerb8f85052007-07-31 03:50:36 +00004074 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004075 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004076
4077 // Check to ensure that constants are compatible with the type initializer!
Reid Spencerb8f85052007-07-31 03:50:36 +00004078 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
4079 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004080 GEN_ERROR("Expected type '" +
4081 STy->getElementType(i)->getDescription() +
4082 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004083 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004084
4085 // Check to ensure that Type is packed
4086 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004087 GEN_ERROR("Vector initializer to non-vector type '" +
4088 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004089
Reid Spencerb8f85052007-07-31 03:50:36 +00004090 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
4091 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004092 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004093 ;}
4094 break;
4095
Reid Spenceree0142e2007-07-31 06:37:43 +00004096 case 164:
4097#line 1692 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004098 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004099 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004100 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
4101 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004102 if (STy == 0)
4103 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004104 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004105
4106 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004107 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004108
4109 // Check to ensure that Type is packed
4110 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004111 GEN_ERROR("Vector initializer to non-vector type '" +
4112 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004113
Reid Spencerb8f85052007-07-31 03:50:36 +00004114 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4115 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004116 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004117 ;}
4118 break;
4119
Reid Spenceree0142e2007-07-31 06:37:43 +00004120 case 165:
4121#line 1712 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004122 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004123 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004124 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4125 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004126 if (PTy == 0)
4127 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00004128 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004129
Reid Spencerb8f85052007-07-31 03:50:36 +00004130 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4131 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004132 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004133 ;}
4134 break;
4135
Reid Spenceree0142e2007-07-31 06:37:43 +00004136 case 166:
4137#line 1724 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004138 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004139 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004140 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4141 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
4142 delete (yyvsp[-1].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004143 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004144 ;}
4145 break;
4146
Reid Spenceree0142e2007-07-31 06:37:43 +00004147 case 167:
4148#line 1731 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004149 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004150 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004151 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4152 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004153 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004154 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004155
4156 // ConstExprs can exist in the body of a function, thus creating
4157 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004158 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004159 // symbol table instead of the module symbol table for the global symbol,
4160 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004161 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004162 //
4163 Function *SavedCurFn = CurFun.CurrentFunction;
4164 CurFun.CurrentFunction = 0;
4165
Reid Spencerb8f85052007-07-31 03:50:36 +00004166 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004167 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004168
4169 CurFun.CurrentFunction = SavedCurFn;
4170
4171 // If this is an initializer for a constant pointer, which is referencing a
4172 // (currently) undefined variable, create a stub now that shall be replaced
4173 // in the future with the right type of variable.
4174 //
4175 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004176 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004177 const PointerType *PT = cast<PointerType>(Ty);
4178
4179 // First check to see if the forward references value is already created!
4180 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencerb8f85052007-07-31 03:50:36 +00004181 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004182
4183 if (I != CurModule.GlobalRefs.end()) {
4184 V = I->second; // Placeholder already exists, use it...
Reid Spencerb8f85052007-07-31 03:50:36 +00004185 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004186 } else {
4187 std::string Name;
Reid Spencerb8f85052007-07-31 03:50:36 +00004188 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4189 Name = (yyvsp[0].ValIDVal).getName();
4190 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004191 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004192
4193 // Create the forward referenced global.
4194 GlobalValue *GV;
4195 if (const FunctionType *FTy =
4196 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004197 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004198 CurModule.CurrentModule);
4199 } else {
4200 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004201 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004202 Name, CurModule.CurrentModule);
4203 }
4204
4205 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencerb8f85052007-07-31 03:50:36 +00004206 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207 V = GV;
4208 }
4209 }
4210
Reid Spencerb8f85052007-07-31 03:50:36 +00004211 (yyval.ConstVal) = cast<GlobalValue>(V);
4212 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004213 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004214 ;}
4215 break;
4216
Reid Spenceree0142e2007-07-31 06:37:43 +00004217 case 168:
4218#line 1797 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004219 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004220 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004221 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4222 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004223 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00004224 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4225 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4226 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004227 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004228 ;}
4229 break;
4230
Reid Spenceree0142e2007-07-31 06:37:43 +00004231 case 169:
4232#line 1807 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004233 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004234 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004235 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4236 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004237 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4238 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004239 (yyval.ConstVal) = Constant::getNullValue(Ty);
4240 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004241 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004242 ;}
4243 break;
4244
Reid Spenceree0142e2007-07-31 06:37:43 +00004245 case 170:
4246#line 1817 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004247 { // integral constants
4248 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004249 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004250 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004251 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004252 ;}
4253 break;
4254
Reid Spenceree0142e2007-07-31 06:37:43 +00004255 case 171:
4256#line 1823 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004257 { // arbitrary precision integer constants
4258 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4259 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004260 GEN_ERROR("Constant value does not fit in type");
4261 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004262 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4263 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4264 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004265 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004266 ;}
4267 break;
4268
Reid Spenceree0142e2007-07-31 06:37:43 +00004269 case 172:
4270#line 1833 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004271 { // integral constants
4272 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004273 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004274 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004275 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004276 ;}
4277 break;
4278
Reid Spenceree0142e2007-07-31 06:37:43 +00004279 case 173:
4280#line 1839 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004281 { // arbitrary precision integer constants
4282 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4283 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004284 GEN_ERROR("Constant value does not fit in type");
4285 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004286 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4287 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
4288 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004289 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004290 ;}
4291 break;
4292
Reid Spenceree0142e2007-07-31 06:37:43 +00004293 case 174:
4294#line 1849 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004295 { // Boolean constants
4296 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4297 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004298 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004299 ;}
4300 break;
4301
Reid Spenceree0142e2007-07-31 06:37:43 +00004302 case 175:
4303#line 1854 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004304 { // Boolean constants
4305 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4306 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004307 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004308 ;}
4309 break;
4310
Reid Spenceree0142e2007-07-31 06:37:43 +00004311 case 176:
4312#line 1859 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004313 { // Float & Double constants
4314 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004315 GEN_ERROR("Floating point constant invalid for type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004316 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004317 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004318 ;}
4319 break;
4320
Reid Spenceree0142e2007-07-31 06:37:43 +00004321 case 177:
4322#line 1867 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004323 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004324 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004325 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4326 Constant *Val = (yyvsp[-3].ConstVal);
4327 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4328 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004329 GEN_ERROR("invalid cast opcode for cast from '" +
4330 Val->getType()->getDescription() + "' to '" +
4331 DestTy->getDescription() + "'");
Reid Spencerb8f85052007-07-31 03:50:36 +00004332 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4333 delete (yyvsp[-1].TypeVal);
4334 ;}
4335 break;
4336
Reid Spenceree0142e2007-07-31 06:37:43 +00004337 case 178:
4338#line 1879 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004339 {
4340 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004341 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004342
4343 const Type *IdxTy =
Reid Spencerb8f85052007-07-31 03:50:36 +00004344 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004345 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004346 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004347 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004348
Chris Lattnerf7469af2007-01-31 04:44:08 +00004349 SmallVector<Constant*, 8> IdxVec;
Reid Spencerb8f85052007-07-31 03:50:36 +00004350 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4351 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004352 IdxVec.push_back(C);
4353 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004354 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004355
Reid Spencerb8f85052007-07-31 03:50:36 +00004356 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004357
Reid Spencerb8f85052007-07-31 03:50:36 +00004358 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004359 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004360 ;}
4361 break;
4362
Reid Spenceree0142e2007-07-31 06:37:43 +00004363 case 179:
4364#line 1901 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004365 {
4366 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004367 GEN_ERROR("Select condition must be of boolean type");
Reid Spencerb8f85052007-07-31 03:50:36 +00004368 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004369 GEN_ERROR("Select operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004370 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004372 ;}
4373 break;
4374
Reid Spenceree0142e2007-07-31 06:37:43 +00004375 case 180:
4376#line 1909 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004377 {
4378 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004379 GEN_ERROR("Binary operator types must match");
4380 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004381 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4382 ;}
4383 break;
4384
Reid Spenceree0142e2007-07-31 06:37:43 +00004385 case 181:
4386#line 1915 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004387 {
4388 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004389 GEN_ERROR("Logical operator types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004390 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4391 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4392 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004393 GEN_ERROR("Logical operator requires integral operands");
4394 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004395 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004396 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004397 ;}
4398 break;
4399
Reid Spenceree0142e2007-07-31 06:37:43 +00004400 case 182:
4401#line 1926 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004402 {
4403 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004404 GEN_ERROR("icmp operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004405 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4406 ;}
4407 break;
4408
Reid Spenceree0142e2007-07-31 06:37:43 +00004409 case 183:
4410#line 1931 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004411 {
4412 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004413 GEN_ERROR("fcmp operand types must match");
Reid Spencerb8f85052007-07-31 03:50:36 +00004414 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4415 ;}
4416 break;
4417
Reid Spenceree0142e2007-07-31 06:37:43 +00004418 case 184:
4419#line 1936 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004420 {
4421 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004422 GEN_ERROR("Invalid extractelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004423 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004424 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004425 ;}
4426 break;
4427
Reid Spenceree0142e2007-07-31 06:37:43 +00004428 case 185:
4429#line 1942 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004430 {
4431 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004432 GEN_ERROR("Invalid insertelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004433 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004434 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004435 ;}
4436 break;
4437
Reid Spenceree0142e2007-07-31 06:37:43 +00004438 case 186:
4439#line 1948 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004440 {
4441 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004442 GEN_ERROR("Invalid shufflevector operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00004443 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004444 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004445 ;}
4446 break;
4447
Reid Spenceree0142e2007-07-31 06:37:43 +00004448 case 187:
4449#line 1957 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004450 {
4451 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004452 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004453 ;}
4454 break;
4455
Reid Spenceree0142e2007-07-31 06:37:43 +00004456 case 188:
4457#line 1961 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004458 {
4459 (yyval.ConstVector) = new std::vector<Constant*>();
4460 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004461 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004462 ;}
4463 break;
4464
Reid Spenceree0142e2007-07-31 06:37:43 +00004465 case 189:
4466#line 1969 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004467 { (yyval.BoolVal) = false; ;}
4468 break;
4469
Reid Spencerb8f85052007-07-31 03:50:36 +00004470 case 190:
Reid Spenceree0142e2007-07-31 06:37:43 +00004471#line 1969 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004472 { (yyval.BoolVal) = true; ;}
4473 break;
4474
4475 case 191:
Reid Spenceree0142e2007-07-31 06:37:43 +00004476#line 1972 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4477 { (yyval.BoolVal) = true; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00004478 break;
4479
4480 case 192:
Reid Spenceree0142e2007-07-31 06:37:43 +00004481#line 1972 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4482 { (yyval.BoolVal) = false; ;}
4483 break;
4484
4485 case 193:
4486#line 1975 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004487 {
4488 const Type* VTy = (yyvsp[-1].TypeVal)->get();
4489 Value *V = getVal(VTy, (yyvsp[0].ValIDVal));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004490 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4491 if (!Aliasee)
4492 GEN_ERROR("Aliases can be created only to global values");
4493
Reid Spencerb8f85052007-07-31 03:50:36 +00004494 (yyval.ConstVal) = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004495 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004496 delete (yyvsp[-1].TypeVal);
4497 ;}
4498 break;
4499
Reid Spenceree0142e2007-07-31 06:37:43 +00004500 case 194:
4501#line 1986 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004502 {
4503 Constant *Val = (yyvsp[-3].ConstVal);
4504 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4505 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004506 GEN_ERROR("invalid cast opcode for cast from '" +
4507 Val->getType()->getDescription() + "' to '" +
4508 DestTy->getDescription() + "'");
4509
Reid Spencerb8f85052007-07-31 03:50:36 +00004510 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004511 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004512 delete (yyvsp[-1].TypeVal);
4513 ;}
4514 break;
4515
Reid Spencerb8f85052007-07-31 03:50:36 +00004516 case 195:
Reid Spenceree0142e2007-07-31 06:37:43 +00004517#line 2007 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004518 {
4519 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004520 CurModule.ModuleDone();
4521 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004522 ;}
4523 break;
4524
Reid Spenceree0142e2007-07-31 06:37:43 +00004525 case 196:
4526#line 2012 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4527 {
4528 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4529 CurModule.ModuleDone();
4530 CHECK_FOR_ERROR;
4531 ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00004532 break;
4533
4534 case 199:
Reid Spenceree0142e2007-07-31 06:37:43 +00004535#line 2025 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4536 { CurFun.isDeclare = false; ;}
4537 break;
4538
4539 case 200:
4540#line 2025 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004541 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004542 CurFun.FunctionDone();
4543 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004544 ;}
4545 break;
4546
Reid Spenceree0142e2007-07-31 06:37:43 +00004547 case 201:
4548#line 2029 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004549 { CurFun.isDeclare = true; ;}
4550 break;
4551
Reid Spencerb8f85052007-07-31 03:50:36 +00004552 case 202:
Reid Spenceree0142e2007-07-31 06:37:43 +00004553#line 2029 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004554 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004555 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004556 ;}
4557 break;
4558
4559 case 203:
Reid Spenceree0142e2007-07-31 06:37:43 +00004560#line 2032 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4561 {
4562 CHECK_FOR_ERROR
4563 ;}
4564 break;
4565
4566 case 204:
4567#line 2035 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004568 {
Reid Spencer14310612006-12-31 05:40:51 +00004569 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004570 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004571 // Eagerly resolve types. This is not an optimization, this is a
4572 // requirement that is due to the fact that we could have this:
4573 //
4574 // %list = type { %list * }
4575 // %list = type { %list * } ; repeated type decl
4576 //
4577 // If types are not resolved eagerly, then the two types will not be
4578 // determined to be the same type!
4579 //
Reid Spencerb8f85052007-07-31 03:50:36 +00004580 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004581
Reid Spencerb8f85052007-07-31 03:50:36 +00004582 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004583 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004584 // If this is a named type that is not a redefinition, add it to the slot
4585 // table.
Reid Spencerb8f85052007-07-31 03:50:36 +00004586 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004587 }
Reid Spencera132e042006-12-03 05:46:11 +00004588
Reid Spencerb8f85052007-07-31 03:50:36 +00004589 delete (yyvsp[0].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004590 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004591 ;}
4592 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004593
Reid Spenceree0142e2007-07-31 06:37:43 +00004594 case 205:
4595#line 2059 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004596 {
4597 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4598
4599 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004600 CHECK_FOR_ERROR
4601 // If this is a named type that is not a redefinition, add it to the slot
4602 // table.
Reid Spencerb8f85052007-07-31 03:50:36 +00004603 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004604 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004605 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004606 ;}
4607 break;
4608
Reid Spenceree0142e2007-07-31 06:37:43 +00004609 case 206:
4610#line 2070 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004611 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004612 /* "Externally Visible" Linkage */
Reid Spencerb8f85052007-07-31 03:50:36 +00004613 if ((yyvsp[0].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004614 GEN_ERROR("Global value initializer is not a constant");
Reid Spencerb8f85052007-07-31 03:50:36 +00004615 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), GlobalValue::ExternalLinkage,
4616 (yyvsp[-3].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal), (yyvsp[-2].BoolVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004617 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004618 ;}
4619 break;
4620
Reid Spenceree0142e2007-07-31 06:37:43 +00004621 case 207:
4622#line 2077 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004623 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004624 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004625 ;}
4626 break;
4627
Reid Spenceree0142e2007-07-31 06:37:43 +00004628 case 208:
4629#line 2081 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004630 {
4631 if ((yyvsp[0].ConstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004632 GEN_ERROR("Global value initializer is not a constant");
Reid Spencerb8f85052007-07-31 03:50:36 +00004633 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 +00004634 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004635 ;}
4636 break;
4637
Reid Spenceree0142e2007-07-31 06:37:43 +00004638 case 209:
4639#line 2086 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004640 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004641 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004642 ;}
4643 break;
4644
Reid Spenceree0142e2007-07-31 06:37:43 +00004645 case 210:
4646#line 2090 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004647 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004648 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004649 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4650 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 +00004651 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004652 delete (yyvsp[0].TypeVal);
4653 ;}
4654 break;
4655
Reid Spenceree0142e2007-07-31 06:37:43 +00004656 case 211:
4657#line 2096 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004658 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004659 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004660 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004661 ;}
4662 break;
4663
Reid Spenceree0142e2007-07-31 06:37:43 +00004664 case 212:
4665#line 2100 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004666 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004667 std::string Name;
Reid Spencerb8f85052007-07-31 03:50:36 +00004668 if ((yyvsp[-4].StrVal)) {
4669 Name = *(yyvsp[-4].StrVal);
4670 delete (yyvsp[-4].StrVal);
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004671 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004672 if (Name.empty())
4673 GEN_ERROR("Alias name cannot be empty");
4674
Reid Spencerb8f85052007-07-31 03:50:36 +00004675 Constant* Aliasee = (yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004676 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004677 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004678
Reid Spencerb8f85052007-07-31 03:50:36 +00004679 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[-1].Linkage), Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004680 CurModule.CurrentModule);
Reid Spencerb8f85052007-07-31 03:50:36 +00004681 GA->setVisibility((yyvsp[-3].Visibility));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004682 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004683 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004684 ;}
4685 break;
4686
Reid Spenceree0142e2007-07-31 06:37:43 +00004687 case 213:
4688#line 2119 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004689 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004690 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004691 ;}
4692 break;
4693
Reid Spenceree0142e2007-07-31 06:37:43 +00004694 case 214:
4695#line 2122 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004696 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004697 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004698 ;}
4699 break;
4700
Reid Spenceree0142e2007-07-31 06:37:43 +00004701 case 215:
4702#line 2128 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004703 {
Chris Lattner66316012006-01-24 04:14:29 +00004704 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00004705 if (AsmSoFar.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004706 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004707 else
Reid Spencerb8f85052007-07-31 03:50:36 +00004708 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[0].StrVal));
4709 delete (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004710 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004711;}
4712 break;
4713
Reid Spenceree0142e2007-07-31 06:37:43 +00004714 case 216:
4715#line 2138 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004716 {
4717 CurModule.CurrentModule->setTargetTriple(*(yyvsp[0].StrVal));
4718 delete (yyvsp[0].StrVal);
4719 ;}
4720 break;
4721
Reid Spenceree0142e2007-07-31 06:37:43 +00004722 case 217:
4723#line 2142 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004724 {
4725 CurModule.CurrentModule->setDataLayout(*(yyvsp[0].StrVal));
4726 delete (yyvsp[0].StrVal);
4727 ;}
4728 break;
4729
Reid Spencerb8f85052007-07-31 03:50:36 +00004730 case 219:
Reid Spenceree0142e2007-07-31 06:37:43 +00004731#line 2149 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004732 {
4733 CurModule.CurrentModule->addLibrary(*(yyvsp[0].StrVal));
4734 delete (yyvsp[0].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004735 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004736 ;}
4737 break;
4738
4739 case 220:
Reid Spenceree0142e2007-07-31 06:37:43 +00004740#line 2154 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004741 {
Reid Spenceree0142e2007-07-31 06:37:43 +00004742 CurModule.CurrentModule->addLibrary(*(yyvsp[0].StrVal));
4743 delete (yyvsp[0].StrVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004744 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004745 ;}
4746 break;
4747
4748 case 221:
Reid Spenceree0142e2007-07-31 06:37:43 +00004749#line 2159 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
4750 {
4751 CHECK_FOR_ERROR
4752 ;}
4753 break;
4754
4755 case 222:
4756#line 2168 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004757 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004758 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004759 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4760 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004761 GEN_ERROR("void typed arguments are invalid");
Reid Spencerb8f85052007-07-31 03:50:36 +00004762 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4763 (yyval.ArgList) = (yyvsp[-4].ArgList);
4764 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004765 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004766 ;}
4767 break;
4768
Reid Spenceree0142e2007-07-31 06:37:43 +00004769 case 223:
4770#line 2178 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004771 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004772 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00004773 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4774 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004775 GEN_ERROR("void typed arguments are invalid");
Reid Spencerb8f85052007-07-31 03:50:36 +00004776 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4777 (yyval.ArgList) = new ArgListType;
4778 (yyval.ArgList)->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004779 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004780 ;}
4781 break;
4782
Reid Spenceree0142e2007-07-31 06:37:43 +00004783 case 224:
4784#line 2189 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004785 {
4786 (yyval.ArgList) = (yyvsp[0].ArgList);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004787 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004788 ;}
4789 break;
4790
Reid Spenceree0142e2007-07-31 06:37:43 +00004791 case 225:
4792#line 2193 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004793 {
4794 (yyval.ArgList) = (yyvsp[-2].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004795 struct ArgListEntry E;
4796 E.Ty = new PATypeHolder(Type::VoidTy);
4797 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004798 E.Attrs = ParamAttr::None;
Reid Spencerb8f85052007-07-31 03:50:36 +00004799 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004800 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004801 ;}
4802 break;
4803
Reid Spenceree0142e2007-07-31 06:37:43 +00004804 case 226:
4805#line 2202 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004806 {
4807 (yyval.ArgList) = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004808 struct ArgListEntry E;
4809 E.Ty = new PATypeHolder(Type::VoidTy);
4810 E.Name = 0;
4811 E.Attrs = ParamAttr::None;
Reid Spencerb8f85052007-07-31 03:50:36 +00004812 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004813 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004814 ;}
4815 break;
4816
Reid Spenceree0142e2007-07-31 06:37:43 +00004817 case 227:
4818#line 2211 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004819 {
4820 (yyval.ArgList) = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004821 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004822 ;}
4823 break;
4824
Reid Spenceree0142e2007-07-31 06:37:43 +00004825 case 228:
4826#line 2217 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004827 {
4828 std::string FunctionName(*(yyvsp[-6].StrVal));
4829 delete (yyvsp[-6].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004830
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004831 // Check the function result for abstractness if this is a define. We should
4832 // have no abstract types at this point
Reid Spencerb8f85052007-07-31 03:50:36 +00004833 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4834 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004835
Reid Spencer68a24bd2005-08-27 18:50:39 +00004836 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004837 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00004838 if ((yyvsp[-2].ParamAttrs) != ParamAttr::None) {
4839 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[-2].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00004840 Attrs.push_back(PAWI);
4841 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004842 if ((yyvsp[-4].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004843 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00004844 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004845 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004846 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4847 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004848 ParamTypeList.push_back(Ty);
4849 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004850 if (I->Attrs != ParamAttr::None) {
4851 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4852 Attrs.push_back(PAWI);
4853 }
Reid Spencer14310612006-12-31 05:40:51 +00004854 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004855 }
4856
4857 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4858 if (isVarArg) ParamTypeList.pop_back();
4859
Christopher Lamb5c104242007-04-22 20:09:11 +00004860 ParamAttrsList *PAL = 0;
4861 if (!Attrs.empty())
4862 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004863
Reid Spencerb8f85052007-07-31 03:50:36 +00004864 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004865 const PointerType *PFT = PointerType::get(FT);
Reid Spencerb8f85052007-07-31 03:50:36 +00004866 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004867
4868 ValID ID;
4869 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004870 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004871 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004872 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004873 }
4874
4875 Function *Fn = 0;
4876 // See if this function was forward referenced. If so, recycle the object.
4877 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4878 // Move the function to the end of the list, from whereever it was
4879 // previously inserted.
4880 Fn = cast<Function>(FWRef);
4881 CurModule.CurrentModule->getFunctionList().remove(Fn);
4882 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4883 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004884 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004885 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004886 // The existing function doesn't have the same type. This is an overload
4887 // error.
4888 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4889 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004890 // Neither the existing or the current function is a declaration and they
4891 // have the same name and same type. Clearly this is a redefinition.
4892 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004893 } if (Fn->isDeclaration()) {
4894 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004895 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4896 AI != AE; ++AI)
4897 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004898 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004899 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004900 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004901 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004902
Reid Spencer68a24bd2005-08-27 18:50:39 +00004903 InsertValue(Fn, CurModule.Values);
4904 }
4905
4906 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004907
4908 if (CurFun.isDeclare) {
4909 // If we have declaration, always overwrite linkage. This will allow us to
4910 // correctly handle cases, when pointer to function is passed as argument to
4911 // another function.
4912 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004913 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004914 }
Reid Spencerb8f85052007-07-31 03:50:36 +00004915 Fn->setCallingConv((yyvsp[-8].UIntVal));
4916 Fn->setAlignment((yyvsp[0].UIntVal));
4917 if ((yyvsp[-1].StrVal)) {
4918 Fn->setSection(*(yyvsp[-1].StrVal));
4919 delete (yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00004920 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004921
4922 // Add all of the arguments we parsed to the function...
Reid Spencerb8f85052007-07-31 03:50:36 +00004923 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004924 if (isVarArg) { // Nuke the last entry
Reid Spencerb8f85052007-07-31 03:50:36 +00004925 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004926 "Not a varargs marker!");
Reid Spencerb8f85052007-07-31 03:50:36 +00004927 delete (yyvsp[-4].ArgList)->back().Ty;
4928 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004929 }
4930 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004931 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004932 unsigned Idx = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00004933 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4934 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004935 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004936 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004937 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004938 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004939 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004940 }
Reid Spencera132e042006-12-03 05:46:11 +00004941
Reid Spencerb8f85052007-07-31 03:50:36 +00004942 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004943 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004944 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004945;}
4946 break;
4947
Reid Spenceree0142e2007-07-31 06:37:43 +00004948 case 231:
4949#line 2339 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004950 {
4951 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004952
4953 // Make sure that we keep track of the linkage type even if there was a
4954 // previous "declare".
Reid Spencerb8f85052007-07-31 03:50:36 +00004955 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4956 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4957;}
4958 break;
4959
Reid Spenceree0142e2007-07-31 06:37:43 +00004960 case 234:
4961#line 2350 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004962 {
4963 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004964 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004965;}
4966 break;
4967
Reid Spenceree0142e2007-07-31 06:37:43 +00004968 case 235:
4969#line 2355 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004970 {
4971 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4972 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4973 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004974 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004975 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004976 ;}
4977 break;
4978
Reid Spenceree0142e2007-07-31 06:37:43 +00004979 case 236:
4980#line 2367 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004981 {
4982 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004983 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004984 ;}
4985 break;
4986
Reid Spenceree0142e2007-07-31 06:37:43 +00004987 case 237:
4988#line 2371 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004989 {
4990 (yyval.BoolVal) = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004991 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004992 ;}
4993 break;
4994
Reid Spenceree0142e2007-07-31 06:37:43 +00004995 case 238:
4996#line 2376 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004997 { // A reference to a direct constant
4998 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004999 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005000 ;}
5001 break;
5002
Reid Spenceree0142e2007-07-31 06:37:43 +00005003 case 239:
5004#line 2380 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005005 {
5006 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005007 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005008 ;}
5009 break;
5010
Reid Spenceree0142e2007-07-31 06:37:43 +00005011 case 240:
5012#line 2384 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005013 { // Perhaps it's an FP constant?
5014 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005015 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005016 ;}
5017 break;
5018
Reid Spenceree0142e2007-07-31 06:37:43 +00005019 case 241:
5020#line 2388 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005021 {
5022 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00005023 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005024 ;}
5025 break;
5026
Reid Spenceree0142e2007-07-31 06:37:43 +00005027 case 242:
5028#line 2392 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005029 {
5030 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005031 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005032 ;}
5033 break;
5034
Reid Spenceree0142e2007-07-31 06:37:43 +00005035 case 243:
5036#line 2396 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005037 {
5038 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00005039 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005040 ;}
5041 break;
5042
Reid Spenceree0142e2007-07-31 06:37:43 +00005043 case 244:
5044#line 2400 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005045 {
5046 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00005047 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005048 ;}
5049 break;
5050
Reid Spenceree0142e2007-07-31 06:37:43 +00005051 case 245:
5052#line 2404 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005053 { // A vector zero constant.
5054 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005055 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005056 ;}
5057 break;
5058
Reid Spenceree0142e2007-07-31 06:37:43 +00005059 case 246:
5060#line 2408 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005061 { // Nonempty unsized packed vector
5062 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
5063 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005064
Reid Spencer9d6565a2007-02-15 02:26:10 +00005065 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005066 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00005067 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00005068 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00005069 ETy,
5070 NumElements)
5071 )
5072 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005073
5074 // Verify all elements are correct type!
Reid Spencerb8f85052007-07-31 03:50:36 +00005075 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
5076 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005077 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005078 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00005079 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005080 }
5081
Reid Spencerb8f85052007-07-31 03:50:36 +00005082 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
5083 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer832254e2007-02-02 02:16:23 +00005084 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005085 ;}
5086 break;
5087
Reid Spenceree0142e2007-07-31 06:37:43 +00005088 case 247:
5089#line 2433 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005090 {
5091 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005092 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005093 ;}
5094 break;
5095
Reid Spenceree0142e2007-07-31 06:37:43 +00005096 case 248:
5097#line 2437 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005098 {
5099 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[-2].StrVal), *(yyvsp[0].StrVal), (yyvsp[-3].BoolVal));
5100 delete (yyvsp[-2].StrVal);
5101 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005102 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005103 ;}
5104 break;
5105
Reid Spenceree0142e2007-07-31 06:37:43 +00005106 case 249:
5107#line 2447 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005108 { // Is it an integer reference...?
5109 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005110 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005111 ;}
5112 break;
5113
Reid Spenceree0142e2007-07-31 06:37:43 +00005114 case 250:
5115#line 2451 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005116 {
5117 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00005118 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005119 ;}
5120 break;
5121
Reid Spenceree0142e2007-07-31 06:37:43 +00005122 case 251:
5123#line 2455 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005124 { // Is it a named reference...?
5125 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[0].StrVal));
5126 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005127 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005128 ;}
5129 break;
5130
Reid Spenceree0142e2007-07-31 06:37:43 +00005131 case 252:
5132#line 2460 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005133 { // Is it a named reference...?
5134 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[0].StrVal));
5135 delete (yyvsp[0].StrVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005136 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005137 ;}
5138 break;
5139
Reid Spenceree0142e2007-07-31 06:37:43 +00005140 case 255:
5141#line 2473 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005142 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005143 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005144 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5145 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
5146 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005147 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005148 ;}
5149 break;
5150
Reid Spenceree0142e2007-07-31 06:37:43 +00005151 case 256:
5152#line 2482 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005153 {
5154 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005155 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005156 ;}
5157 break;
5158
Reid Spenceree0142e2007-07-31 06:37:43 +00005159 case 257:
5160#line 2486 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005161 { // Do not allow functions with 0 basic blocks
5162 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005163 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005164 ;}
5165 break;
5166
Reid Spenceree0142e2007-07-31 06:37:43 +00005167 case 258:
5168#line 2495 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005169 {
5170 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005171 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005172 InsertValue((yyvsp[0].TermInstVal));
5173 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
5174 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005175 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005176 ;}
5177 break;
5178
Reid Spenceree0142e2007-07-31 06:37:43 +00005179 case 259:
5180#line 2504 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005181 {
5182 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005183 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5184 if (CI2->getParent() == 0)
Reid Spencerb8f85052007-07-31 03:50:36 +00005185 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
5186 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
5187 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005188 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005189 ;}
5190 break;
5191
Reid Spenceree0142e2007-07-31 06:37:43 +00005192 case 260:
5193#line 2513 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005194 { // Empty space between instruction lists
5195 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00005196 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005197 ;}
5198 break;
5199
Reid Spenceree0142e2007-07-31 06:37:43 +00005200 case 261:
5201#line 2517 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005202 { // Labelled (named) basic block
5203 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[0].StrVal)));
5204 delete (yyvsp[0].StrVal);
Reid Spencered951ea2007-05-19 07:22:10 +00005205 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005206
Reid Spencerb8f85052007-07-31 03:50:36 +00005207 ;}
5208 break;
Reid Spencered951ea2007-05-19 07:22:10 +00005209
Reid Spenceree0142e2007-07-31 06:37:43 +00005210 case 262:
5211#line 2524 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005212 { // Return with a result...
5213 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
5214 CHECK_FOR_ERROR
5215 ;}
5216 break;
5217
Reid Spenceree0142e2007-07-31 06:37:43 +00005218 case 263:
5219#line 2528 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005220 { // Return with no result...
5221 (yyval.TermInstVal) = new ReturnInst();
5222 CHECK_FOR_ERROR
5223 ;}
5224 break;
5225
Reid Spenceree0142e2007-07-31 06:37:43 +00005226 case 264:
5227#line 2532 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005228 { // Unconditional Branch...
5229 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5230 CHECK_FOR_ERROR
5231 (yyval.TermInstVal) = new BranchInst(tmpBB);
5232 ;}
5233 break;
5234
Reid Spenceree0142e2007-07-31 06:37:43 +00005235 case 265:
5236#line 2537 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005237 {
5238 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5239 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5240 CHECK_FOR_ERROR
5241 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5242 CHECK_FOR_ERROR
5243 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5244 CHECK_FOR_ERROR
5245 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5246 ;}
5247 break;
5248
Reid Spenceree0142e2007-07-31 06:37:43 +00005249 case 266:
5250#line 2547 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005251 {
5252 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5253 CHECK_FOR_ERROR
5254 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5255 CHECK_FOR_ERROR
5256 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5257 (yyval.TermInstVal) = S;
5258
5259 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5260 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005261 for (; I != E; ++I) {
5262 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5263 S->addCase(CI, I->second);
5264 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005265 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005266 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005267 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005268 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005269 ;}
5270 break;
5271
Reid Spenceree0142e2007-07-31 06:37:43 +00005272 case 267:
5273#line 2566 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005274 {
5275 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005276 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005277 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005278 CHECK_FOR_ERROR
5279 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencerb8f85052007-07-31 03:50:36 +00005280 (yyval.TermInstVal) = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005281 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005282 ;}
5283 break;
5284
Reid Spenceree0142e2007-07-31 06:37:43 +00005285 case 268:
5286#line 2576 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005287 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005288
Reid Spencer14310612006-12-31 05:40:51 +00005289 // Handle the short syntax
5290 const PointerType *PFTy = 0;
5291 const FunctionType *Ty = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005292 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005293 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5294 // Pull out the types of all of the arguments...
5295 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005296 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005297 if ((yyvsp[-6].ParamAttrs) != ParamAttr::None) {
5298 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[-6].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005299 Attrs.push_back(PAWI);
5300 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005301 ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005302 unsigned index = 1;
5303 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005304 const Type *Ty = I->Val->getType();
5305 if (Ty == Type::VoidTy)
5306 GEN_ERROR("Short call syntax cannot be used with varargs");
5307 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005308 if (I->Attrs != ParamAttr::None) {
5309 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5310 Attrs.push_back(PAWI);
5311 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005312 }
5313
Christopher Lamb5c104242007-04-22 20:09:11 +00005314 ParamAttrsList *PAL = 0;
5315 if (!Attrs.empty())
5316 PAL = ParamAttrsList::get(Attrs);
Reid Spencerb8f85052007-07-31 03:50:36 +00005317 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005318 PFTy = PointerType::get(Ty);
5319 }
5320
Reid Spencerb8f85052007-07-31 03:50:36 +00005321 delete (yyvsp[-11].TypeVal);
Reid Spencer66728ef2007-03-20 01:13:36 +00005322
Reid Spencerb8f85052007-07-31 03:50:36 +00005323 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005324 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005325 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005326 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005327 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005328 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005329
Reid Spencer14310612006-12-31 05:40:51 +00005330 // Check the arguments
5331 ValueList Args;
Reid Spencerb8f85052007-07-31 03:50:36 +00005332 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005333 // Make sure no arguments is a good thing!
5334 if (Ty->getNumParams() != 0)
5335 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005336 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005337 } else { // Has arguments?
5338 // Loop through FunctionType's arguments and ensure they are specified
5339 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005340 FunctionType::param_iterator I = Ty->param_begin();
5341 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb8f85052007-07-31 03:50:36 +00005342 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005343
Reid Spencer14310612006-12-31 05:40:51 +00005344 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5345 if (ArgI->Val->getType() != *I)
5346 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005347 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005348 Args.push_back(ArgI->Val);
5349 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005350
Reid Spencer14310612006-12-31 05:40:51 +00005351 if (Ty->isVarArg()) {
5352 if (I == E)
5353 for (; ArgI != ArgE; ++ArgI)
5354 Args.push_back(ArgI->Val); // push the remaining varargs
5355 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005356 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005357 }
Reid Spencer14310612006-12-31 05:40:51 +00005358
5359 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005360 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencerb8f85052007-07-31 03:50:36 +00005361 II->setCallingConv((yyvsp[-12].UIntVal));
5362 (yyval.TermInstVal) = II;
5363 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005364 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005365 ;}
5366 break;
5367
Reid Spenceree0142e2007-07-31 06:37:43 +00005368 case 269:
5369#line 2655 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005370 {
5371 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005372 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005373 ;}
5374 break;
5375
Reid Spenceree0142e2007-07-31 06:37:43 +00005376 case 270:
5377#line 2659 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005378 {
5379 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005380 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005381 ;}
5382 break;
5383
Reid Spenceree0142e2007-07-31 06:37:43 +00005384 case 271:
5385#line 2666 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005386 {
5387 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5388 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005389 CHECK_FOR_ERROR
5390 if (V == 0)
5391 GEN_ERROR("May only switch on a constant pool value");
5392
Reid Spencerb8f85052007-07-31 03:50:36 +00005393 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005394 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005395 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5396 ;}
5397 break;
5398
Reid Spenceree0142e2007-07-31 06:37:43 +00005399 case 272:
5400#line 2677 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005401 {
5402 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5403 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005404 CHECK_FOR_ERROR
5405
5406 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005407 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005408
Reid Spencerb8f85052007-07-31 03:50:36 +00005409 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005410 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005411 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5412 ;}
5413 break;
5414
Reid Spenceree0142e2007-07-31 06:37:43 +00005415 case 273:
5416#line 2690 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005417 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005418 // Is this definition named?? if so, assign the name...
Reid Spencerb8f85052007-07-31 03:50:36 +00005419 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005420 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005421 InsertValue((yyvsp[0].InstVal));
5422 (yyval.InstVal) = (yyvsp[0].InstVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005423 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005424 ;}
5425 break;
5426
Reid Spenceree0142e2007-07-31 06:37:43 +00005427 case 274:
5428#line 2700 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005429 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005430 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005431 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5432 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5433 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer6f407902007-01-13 05:00:46 +00005434 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005435 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005436 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005437 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5438 delete (yyvsp[-5].TypeVal);
5439 ;}
5440 break;
5441
Reid Spenceree0142e2007-07-31 06:37:43 +00005442 case 275:
5443#line 2711 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005444 {
5445 (yyval.PHIList) = (yyvsp[-6].PHIList);
5446 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005447 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005448 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005449 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005450 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5451 ;}
5452 break;
5453
Reid Spenceree0142e2007-07-31 06:37:43 +00005454 case 276:
5455#line 2721 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005456 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005457 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005458 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005459 // Used for call and invoke instructions
Reid Spencerb8f85052007-07-31 03:50:36 +00005460 (yyval.ValueRefList) = new ValueRefList();
5461 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5462 (yyval.ValueRefList)->push_back(E);
5463 delete (yyvsp[-2].TypeVal);
5464 ;}
5465 break;
5466
Reid Spenceree0142e2007-07-31 06:37:43 +00005467 case 277:
5468#line 2730 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005469 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005470 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005471 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5472 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5473 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5474 (yyval.ValueRefList)->push_back(E);
5475 delete (yyvsp[-2].TypeVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005476 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005477 ;}
5478 break;
5479
Reid Spencerb8f85052007-07-31 03:50:36 +00005480 case 278:
Reid Spenceree0142e2007-07-31 06:37:43 +00005481#line 2739 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
5482 { (yyval.ValueRefList) = new ValueRefList(); ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00005483 break;
5484
5485 case 279:
5486#line 2742 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spenceree0142e2007-07-31 06:37:43 +00005487 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5488 break;
5489
5490 case 280:
5491#line 2743 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005492 {
5493 (yyval.ValueList) = (yyvsp[-2].ValueList);
5494 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005495 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005496 ;}
5497 break;
5498
Reid Spenceree0142e2007-07-31 06:37:43 +00005499 case 281:
5500#line 2750 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005501 {
5502 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005503 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005504 ;}
5505 break;
5506
Reid Spenceree0142e2007-07-31 06:37:43 +00005507 case 282:
5508#line 2754 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005509 {
5510 (yyval.BoolVal) = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005511 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005512 ;}
5513 break;
5514
Reid Spenceree0142e2007-07-31 06:37:43 +00005515 case 283:
5516#line 2759 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005517 {
Reid Spencer14310612006-12-31 05:40:51 +00005518 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005519 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5520 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5521 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005522 GEN_ERROR(
5523 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005524 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5525 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5526 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5527 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005528 GEN_ERROR("Remainder not supported on vector types");
Reid Spencerb8f85052007-07-31 03:50:36 +00005529 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005530 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005531 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005532 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005533 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5534 if ((yyval.InstVal) == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005535 GEN_ERROR("binary operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005536 delete (yyvsp[-3].TypeVal);
5537 ;}
5538 break;
5539
Reid Spenceree0142e2007-07-31 06:37:43 +00005540 case 284:
5541#line 2780 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005542 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005543 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005544 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5545 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5546 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5547 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005548 GEN_ERROR("Logical operator requires integral operands");
5549 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005550 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005551 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005552 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005553 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005554 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5555 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005556 GEN_ERROR("binary operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005557 delete (yyvsp[-3].TypeVal);
5558 ;}
5559 break;
5560
Reid Spenceree0142e2007-07-31 06:37:43 +00005561 case 285:
5562#line 2797 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005563 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005564 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005565 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5566 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005567 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencerb8f85052007-07-31 03:50:36 +00005568 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005569 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005570 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005571 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005572 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5573 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005574 GEN_ERROR("icmp operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005575 delete (yyvsp[-3].TypeVal);
5576 ;}
5577 break;
5578
Reid Spenceree0142e2007-07-31 06:37:43 +00005579 case 286:
5580#line 2811 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005581 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005582 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005583 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5584 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005585 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencerb8f85052007-07-31 03:50:36 +00005586 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005587 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005588 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005589 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005590 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5591 if ((yyval.InstVal) == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005592 GEN_ERROR("fcmp operator returned null");
Reid Spencerb8f85052007-07-31 03:50:36 +00005593 delete (yyvsp[-3].TypeVal);
5594 ;}
5595 break;
5596
Reid Spenceree0142e2007-07-31 06:37:43 +00005597 case 287:
5598#line 2825 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005599 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005600 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005601 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5602 Value* Val = (yyvsp[-2].ValueVal);
5603 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5604 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005605 GEN_ERROR("invalid cast opcode for cast from '" +
5606 Val->getType()->getDescription() + "' to '" +
5607 DestTy->getDescription() + "'");
Reid Spencerb8f85052007-07-31 03:50:36 +00005608 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5609 delete (yyvsp[0].TypeVal);
5610 ;}
5611 break;
5612
Reid Spenceree0142e2007-07-31 06:37:43 +00005613 case 288:
5614#line 2837 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005615 {
5616 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005617 GEN_ERROR("select condition must be boolean");
Reid Spencerb8f85052007-07-31 03:50:36 +00005618 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005619 GEN_ERROR("select value types should match");
Reid Spencerb8f85052007-07-31 03:50:36 +00005620 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005621 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005622 ;}
5623 break;
5624
Reid Spenceree0142e2007-07-31 06:37:43 +00005625 case 289:
5626#line 2845 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005627 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005628 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005629 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5630 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5631 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005632 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005633 ;}
5634 break;
5635
Reid Spenceree0142e2007-07-31 06:37:43 +00005636 case 290:
5637#line 2852 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005638 {
5639 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005640 GEN_ERROR("Invalid extractelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005641 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005642 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005643 ;}
5644 break;
5645
Reid Spenceree0142e2007-07-31 06:37:43 +00005646 case 291:
5647#line 2858 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005648 {
5649 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005650 GEN_ERROR("Invalid insertelement operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005651 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005652 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005653 ;}
5654 break;
5655
Reid Spenceree0142e2007-07-31 06:37:43 +00005656 case 292:
5657#line 2864 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005658 {
5659 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005660 GEN_ERROR("Invalid shufflevector operands");
Reid Spencerb8f85052007-07-31 03:50:36 +00005661 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005662 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005663 ;}
5664 break;
5665
Reid Spenceree0142e2007-07-31 06:37:43 +00005666 case 293:
5667#line 2870 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005668 {
5669 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005670 if (!Ty->isFirstClassType())
5671 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencerb8f85052007-07-31 03:50:36 +00005672 (yyval.InstVal) = new PHINode(Ty);
5673 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5674 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5675 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005676 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencerb8f85052007-07-31 03:50:36 +00005677 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5678 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005679 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005680 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005681 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005682 ;}
5683 break;
5684
Reid Spenceree0142e2007-07-31 06:37:43 +00005685 case 294:
5686#line 2886 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005687 {
Reid Spencer14310612006-12-31 05:40:51 +00005688
5689 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005690 const PointerType *PFTy = 0;
5691 const FunctionType *Ty = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005692 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005693 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5694 // Pull out the types of all of the arguments...
5695 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005696 ParamAttrsVector Attrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005697 if ((yyvsp[0].ParamAttrs) != ParamAttr::None) {
5698 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[0].ParamAttrs);
Christopher Lamb5c104242007-04-22 20:09:11 +00005699 Attrs.push_back(PAWI);
5700 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005701 unsigned index = 1;
Reid Spencerb8f85052007-07-31 03:50:36 +00005702 ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005703 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005704 const Type *Ty = I->Val->getType();
5705 if (Ty == Type::VoidTy)
5706 GEN_ERROR("Short call syntax cannot be used with varargs");
5707 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005708 if (I->Attrs != ParamAttr::None) {
5709 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5710 Attrs.push_back(PAWI);
5711 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005712 }
5713
Christopher Lamb5c104242007-04-22 20:09:11 +00005714 ParamAttrsList *PAL = 0;
5715 if (!Attrs.empty())
5716 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005717
Reid Spencerb8f85052007-07-31 03:50:36 +00005718 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005719 PFTy = PointerType::get(Ty);
5720 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005721
Reid Spencerb8f85052007-07-31 03:50:36 +00005722 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005723 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005724
Reid Spencer7780acb2007-04-16 06:56:07 +00005725 // Check for call to invalid intrinsic to avoid crashing later.
5726 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005727 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005728 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5729 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005730 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5731 theF->getName() + "'");
5732 }
5733
Reid Spencer14310612006-12-31 05:40:51 +00005734 // Check the arguments
5735 ValueList Args;
Reid Spencerb8f85052007-07-31 03:50:36 +00005736 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005737 // Make sure no arguments is a good thing!
5738 if (Ty->getNumParams() != 0)
5739 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005740 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005741 } else { // Has arguments?
5742 // Loop through FunctionType's arguments and ensure they are specified
5743 // correctly!
5744 //
5745 FunctionType::param_iterator I = Ty->param_begin();
5746 FunctionType::param_iterator E = Ty->param_end();
Reid Spencerb8f85052007-07-31 03:50:36 +00005747 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005748
Reid Spencer14310612006-12-31 05:40:51 +00005749 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5750 if (ArgI->Val->getType() != *I)
5751 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005752 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005753 Args.push_back(ArgI->Val);
5754 }
5755 if (Ty->isVarArg()) {
5756 if (I == E)
5757 for (; ArgI != ArgE; ++ArgI)
5758 Args.push_back(ArgI->Val); // push the remaining varargs
5759 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005760 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005761 }
Reid Spencer14310612006-12-31 05:40:51 +00005762 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005763 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencerb8f85052007-07-31 03:50:36 +00005764 CI->setTailCall((yyvsp[-7].BoolVal));
5765 CI->setCallingConv((yyvsp[-6].UIntVal));
5766 (yyval.InstVal) = CI;
5767 delete (yyvsp[-2].ValueRefList);
5768 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005769 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005770 ;}
5771 break;
5772
Reid Spenceree0142e2007-07-31 06:37:43 +00005773 case 295:
5774#line 2970 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005775 {
5776 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005777 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005778 ;}
5779 break;
5780
Reid Spenceree0142e2007-07-31 06:37:43 +00005781 case 296:
5782#line 2975 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005783 {
5784 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005785 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005786 ;}
5787 break;
5788
Reid Spenceree0142e2007-07-31 06:37:43 +00005789 case 297:
5790#line 2979 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005791 {
5792 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005793 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005794 ;}
5795 break;
5796
Reid Spenceree0142e2007-07-31 06:37:43 +00005797 case 298:
5798#line 2986 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005799 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005800 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005801 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5802 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5803 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005804 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005805 ;}
5806 break;
5807
Reid Spenceree0142e2007-07-31 06:37:43 +00005808 case 299:
5809#line 2993 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005810 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005811 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005812 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5813 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005814 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005815 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5816 delete (yyvsp[-4].TypeVal);
5817 ;}
5818 break;
5819
Reid Spenceree0142e2007-07-31 06:37:43 +00005820 case 300:
5821#line 3001 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005822 {
Reid Spencer14310612006-12-31 05:40:51 +00005823 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005824 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5825 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5826 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005827 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005828 ;}
5829 break;
5830
Reid Spenceree0142e2007-07-31 06:37:43 +00005831 case 301:
5832#line 3008 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005833 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005834 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005835 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5836 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005837 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005838 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5839 delete (yyvsp[-4].TypeVal);
5840 ;}
5841 break;
5842
Reid Spenceree0142e2007-07-31 06:37:43 +00005843 case 302:
5844#line 3016 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005845 {
5846 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005847 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005848 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5849 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005850 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005851 ;}
5852 break;
5853
Reid Spenceree0142e2007-07-31 06:37:43 +00005854 case 303:
5855#line 3024 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005856 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005857 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005858 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5859 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005860 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005861 (*(yyvsp[-2].TypeVal))->getDescription());
5862 if (!cast<PointerType>((yyvsp[-2].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005863 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005864 (*(yyvsp[-2].TypeVal))->getDescription());
5865 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005866 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005867 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-4].BoolVal), (yyvsp[0].UIntVal));
5868 delete (yyvsp[-2].TypeVal);
5869 ;}
5870 break;
5871
Reid Spenceree0142e2007-07-31 06:37:43 +00005872 case 304:
5873#line 3038 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005874 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005875 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005876 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5877 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005878 if (!PT)
5879 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencerb8f85052007-07-31 03:50:36 +00005880 (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005881 const Type *ElTy = PT->getElementType();
Reid Spencerb8f85052007-07-31 03:50:36 +00005882 if (ElTy != (yyvsp[-4].ValueVal)->getType())
5883 GEN_ERROR("Can't store '" + (yyvsp[-4].ValueVal)->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005884 "' into space of type '" + ElTy->getDescription() + "'");
5885
Reid Spencerb8f85052007-07-31 03:50:36 +00005886 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005887 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005888 (yyval.InstVal) = new StoreInst((yyvsp[-4].ValueVal), tmpVal, (yyvsp[-6].BoolVal), (yyvsp[0].UIntVal));
5889 delete (yyvsp[-2].TypeVal);
5890 ;}
5891 break;
5892
Reid Spenceree0142e2007-07-31 06:37:43 +00005893 case 305:
5894#line 3055 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005895 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005896 if (!UpRefs.empty())
Reid Spencerb8f85052007-07-31 03:50:36 +00005897 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5898 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005899 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005900
Reid Spencerb8f85052007-07-31 03:50:36 +00005901 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005902 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencerb8f85052007-07-31 03:50:36 +00005903 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5904 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005905 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005906 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5907 delete (yyvsp[-2].TypeVal);
5908 delete (yyvsp[0].ValueList);
5909 ;}
5910 break;
5911
5912
5913 default: break;
5914 }
5915
5916/* Line 1126 of yacc.c. */
Reid Spenceree0142e2007-07-31 06:37:43 +00005917#line 5918 "llvmAsmParser.tab.c"
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005918
5919 yyvsp -= yylen;
5920 yyssp -= yylen;
Reid Spencer7780acb2007-04-16 06:56:07 +00005921
Reid Spencerb8f85052007-07-31 03:50:36 +00005922
5923 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005924
5925 *++yyvsp = yyval;
5926
5927
Reid Spencerb8f85052007-07-31 03:50:36 +00005928 /* Now `shift' the result of the reduction. Determine what state
5929 that goes to, based on the state we popped back to and the rule
5930 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005931
5932 yyn = yyr1[yyn];
5933
Reid Spencerb8f85052007-07-31 03:50:36 +00005934 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5935 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005936 yystate = yytable[yystate];
5937 else
Reid Spencerb8f85052007-07-31 03:50:36 +00005938 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005939
5940 goto yynewstate;
5941
5942
Reid Spencerb8f85052007-07-31 03:50:36 +00005943/*------------------------------------.
5944| yyerrlab -- here on detecting error |
5945`------------------------------------*/
5946yyerrlab:
5947 /* If not already recovering from an error, report this error. */
5948 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005949 {
5950 ++yynerrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005951#if YYERROR_VERBOSE
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005952 yyn = yypact[yystate];
5953
Reid Spencerb8f85052007-07-31 03:50:36 +00005954 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005955 {
Reid Spencerb8f85052007-07-31 03:50:36 +00005956 int yytype = YYTRANSLATE (yychar);
5957 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5958 YYSIZE_T yysize = yysize0;
5959 YYSIZE_T yysize1;
5960 int yysize_overflow = 0;
5961 char *yymsg = 0;
5962# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5963 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5964 int yyx;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005965
Reid Spencerb8f85052007-07-31 03:50:36 +00005966#if 0
5967 /* This is so xgettext sees the translatable formats that are
5968 constructed on the fly. */
5969 YY_("syntax error, unexpected %s");
5970 YY_("syntax error, unexpected %s, expecting %s");
5971 YY_("syntax error, unexpected %s, expecting %s or %s");
5972 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5973 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5974#endif
5975 char *yyfmt;
5976 char const *yyf;
5977 static char const yyunexpected[] = "syntax error, unexpected %s";
5978 static char const yyexpecting[] = ", expecting %s";
5979 static char const yyor[] = " or %s";
5980 char yyformat[sizeof yyunexpected
5981 + sizeof yyexpecting - 1
5982 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5983 * (sizeof yyor - 1))];
5984 char const *yyprefix = yyexpecting;
5985
5986 /* Start YYX at -YYN if negative to avoid negative indexes in
5987 YYCHECK. */
5988 int yyxbegin = yyn < 0 ? -yyn : 0;
5989
5990 /* Stay within bounds of both yycheck and yytname. */
5991 int yychecklim = YYLAST - yyn;
5992 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5993 int yycount = 1;
5994
5995 yyarg[0] = yytname[yytype];
5996 yyfmt = yystpcpy (yyformat, yyunexpected);
5997
5998 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5999 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
6000 {
6001 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
6002 {
6003 yycount = 1;
6004 yysize = yysize0;
6005 yyformat[sizeof yyunexpected - 1] = '\0';
6006 break;
6007 }
6008 yyarg[yycount++] = yytname[yyx];
6009 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
6010 yysize_overflow |= yysize1 < yysize;
6011 yysize = yysize1;
6012 yyfmt = yystpcpy (yyfmt, yyprefix);
6013 yyprefix = yyor;
6014 }
6015
6016 yyf = YY_(yyformat);
6017 yysize1 = yysize + yystrlen (yyf);
6018 yysize_overflow |= yysize1 < yysize;
6019 yysize = yysize1;
6020
6021 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
6022 yymsg = (char *) YYSTACK_ALLOC (yysize);
6023 if (yymsg)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006024 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006025 /* Avoid sprintf, as that infringes on the user's name space.
6026 Don't have undefined behavior even if the translation
6027 produced a string with the wrong number of "%s"s. */
6028 char *yyp = yymsg;
6029 int yyi = 0;
6030 while ((*yyp = *yyf))
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006031 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006032 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
6033 {
6034 yyp += yytnamerr (yyp, yyarg[yyi++]);
6035 yyf += 2;
6036 }
6037 else
6038 {
6039 yyp++;
6040 yyf++;
6041 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006042 }
Reid Spencerb8f85052007-07-31 03:50:36 +00006043 yyerror (yymsg);
6044 YYSTACK_FREE (yymsg);
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006045 }
6046 else
Reid Spencerb8f85052007-07-31 03:50:36 +00006047 {
6048 yyerror (YY_("syntax error"));
6049 goto yyexhaustedlab;
6050 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00006051 }
6052 else
6053#endif /* YYERROR_VERBOSE */
Reid Spencerb8f85052007-07-31 03:50:36 +00006054 yyerror (YY_("syntax error"));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006055 }
6056
Reid Spencerb8f85052007-07-31 03:50:36 +00006057
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006058
6059 if (yyerrstatus == 3)
6060 {
Reid Spencerb8f85052007-07-31 03:50:36 +00006061 /* If just tried and failed to reuse look-ahead token after an
6062 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006063
Reid Spencerb8f85052007-07-31 03:50:36 +00006064 if (yychar <= YYEOF)
6065 {
6066 /* Return failure if at end of input. */
6067 if (yychar == YYEOF)
6068 YYABORT;
6069 }
6070 else
6071 {
6072 yydestruct ("Error: discarding", yytoken, &yylval);
6073 yychar = YYEMPTY;
6074 }
6075 }
6076
6077 /* Else will try to reuse look-ahead token after shifting the error
6078 token. */
6079 goto yyerrlab1;
6080
6081
6082/*---------------------------------------------------.
6083| yyerrorlab -- error raised explicitly by YYERROR. |
6084`---------------------------------------------------*/
6085yyerrorlab:
6086
6087 /* Pacify compilers like GCC when the user code never invokes
6088 YYERROR and the label yyerrorlab therefore never appears in user
6089 code. */
6090 if (0)
6091 goto yyerrorlab;
6092
6093yyvsp -= yylen;
6094 yyssp -= yylen;
6095 yystate = *yyssp;
6096 goto yyerrlab1;
6097
6098
6099/*-------------------------------------------------------------.
6100| yyerrlab1 -- common code for both syntax error and YYERROR. |
6101`-------------------------------------------------------------*/
6102yyerrlab1:
6103 yyerrstatus = 3; /* Each real token shifted decrements this. */
6104
6105 for (;;)
6106 {
6107 yyn = yypact[yystate];
6108 if (yyn != YYPACT_NINF)
6109 {
6110 yyn += YYTERROR;
6111 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6112 {
6113 yyn = yytable[yyn];
6114 if (0 < yyn)
6115 break;
6116 }
6117 }
6118
6119 /* Pop the current state because it cannot handle the error token. */
6120 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006121 YYABORT;
6122
Reid Spencere4d87aa2006-12-23 06:05:41 +00006123
Reid Spencerb8f85052007-07-31 03:50:36 +00006124 yydestruct ("Error: popping", yystos[yystate], yyvsp);
6125 YYPOPSTACK;
6126 yystate = *yyssp;
6127 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006128 }
6129
6130 if (yyn == YYFINAL)
6131 YYACCEPT;
6132
Reid Spencer68a24bd2005-08-27 18:50:39 +00006133 *++yyvsp = yylval;
Reid Spencerb8f85052007-07-31 03:50:36 +00006134
6135
6136 /* Shift the error token. */
6137 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00006138
Reid Spencer68a24bd2005-08-27 18:50:39 +00006139 yystate = yyn;
6140 goto yynewstate;
6141
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006142
Reid Spencerb8f85052007-07-31 03:50:36 +00006143/*-------------------------------------.
6144| yyacceptlab -- YYACCEPT comes here. |
6145`-------------------------------------*/
6146yyacceptlab:
6147 yyresult = 0;
6148 goto yyreturn;
6149
6150/*-----------------------------------.
6151| yyabortlab -- YYABORT comes here. |
6152`-----------------------------------*/
6153yyabortlab:
6154 yyresult = 1;
6155 goto yyreturn;
6156
6157#ifndef yyoverflow
6158/*-------------------------------------------------.
6159| yyexhaustedlab -- memory exhaustion comes here. |
6160`-------------------------------------------------*/
6161yyexhaustedlab:
6162 yyerror (YY_("memory exhausted"));
6163 yyresult = 2;
6164 /* Fall through. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006165#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00006166
6167yyreturn:
6168 if (yychar != YYEOF && yychar != YYEMPTY)
6169 yydestruct ("Cleanup: discarding lookahead",
6170 yytoken, &yylval);
6171 while (yyssp != yyss)
6172 {
6173 yydestruct ("Cleanup: popping",
6174 yystos[*yyssp], yyvsp);
6175 YYPOPSTACK;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006176 }
Reid Spencerb8f85052007-07-31 03:50:36 +00006177#ifndef yyoverflow
6178 if (yyss != yyssa)
6179 YYSTACK_FREE (yyss);
6180#endif
6181 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006182}
Reid Spencerb8f85052007-07-31 03:50:36 +00006183
6184
Reid Spenceree0142e2007-07-31 06:37:43 +00006185#line 3072 "/proj/llvm/head/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006186
6187
Reid Spencer14310612006-12-31 05:40:51 +00006188// common code from the two 'RunVMAsmParser' functions
6189static Module* RunParser(Module * M) {
6190
6191 llvmAsmlineno = 1; // Reset the current line number...
6192 CurModule.CurrentModule = M;
6193#if YYDEBUG
6194 yydebug = Debug;
6195#endif
6196
6197 // Check to make sure the parser succeeded
6198 if (yyparse()) {
6199 if (ParserResult)
6200 delete ParserResult;
6201 return 0;
6202 }
6203
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006204 // Emit an error if there are any unresolved types left.
6205 if (!CurModule.LateResolveTypes.empty()) {
6206 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6207 if (DID.Type == ValID::LocalName) {
6208 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6209 } else {
6210 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6211 }
6212 if (ParserResult)
6213 delete ParserResult;
6214 return 0;
6215 }
6216
6217 // Emit an error if there are any unresolved values left.
6218 if (!CurModule.LateResolveValues.empty()) {
6219 Value *V = CurModule.LateResolveValues.back();
6220 std::map<Value*, std::pair<ValID, int> >::iterator I =
6221 CurModule.PlaceHolderInfo.find(V);
6222
6223 if (I != CurModule.PlaceHolderInfo.end()) {
6224 ValID &DID = I->second.first;
6225 if (DID.Type == ValID::LocalName) {
6226 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6227 } else {
6228 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6229 }
6230 if (ParserResult)
6231 delete ParserResult;
6232 return 0;
6233 }
6234 }
6235
Reid Spencer14310612006-12-31 05:40:51 +00006236 // Check to make sure that parsing produced a result
6237 if (!ParserResult)
6238 return 0;
6239
6240 // Reset ParserResult variable while saving its value for the result.
6241 Module *Result = ParserResult;
6242 ParserResult = 0;
6243
6244 return Result;
6245}
6246
Reid Spencer61c83e02006-08-18 08:43:06 +00006247void llvm::GenerateError(const std::string &message, int LineNo) {
6248 if (LineNo == -1) LineNo = llvmAsmlineno;
6249 // TODO: column number in exception
6250 if (TheParseError)
6251 TheParseError->setError(CurFilename, message, LineNo);
6252 TriggerError = 1;
6253}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006254
6255int yyerror(const char *ErrorMsg) {
6256 std::string where
6257 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6258 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006259 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6260 if (yychar != YYEMPTY && yychar != 0)
6261 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6262 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006263 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006264 return 0;
6265}
Reid Spencerb8f85052007-07-31 03:50:36 +00006266