blob: 0eddc39522ac9cff3b56e7de884b6dc378830b4e [file] [log] [blame]
David Greene718fda32007-08-01 03:59:32 +00001/* A Bison parser, made by GNU Bison 1.875c. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencerb8f85052007-07-31 03:50:36 +00003/* Skeleton parser for Yacc-like parsing with Bison,
David Greene718fda32007-08-01 03:59:32 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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
David Greene718fda32007-08-01 03:59:32 +000018 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
Reid Spencerb8f85052007-07-31 03:50:36 +000020
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
Reid Spencerb8f85052007-07-31 03:50:36 +000039/* Skeleton name. */
40#define YYSKELETON_NAME "yacc.c"
41
42/* Pure parsers. */
43#define YYPURE 0
44
45/* Using locations. */
46#define YYLSP_NEEDED 0
47
David Greene718fda32007-08-01 03:59:32 +000048/* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000050#define yyparse llvmAsmparse
Reid Spencerb8f85052007-07-31 03:50:36 +000051#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyerror llvmAsmerror
Reid Spencerb8f85052007-07-31 03:50:36 +000053#define yylval llvmAsmlval
54#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000055#define yydebug llvmAsmdebug
56#define yynerrs llvmAsmnerrs
57
Reid Spencerb8f85052007-07-31 03:50:36 +000058
59/* Tokens. */
60#ifndef YYTOKENTYPE
61# define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 ESINT64VAL = 258,
66 EUINT64VAL = 259,
67 ESAPINTVAL = 260,
68 EUAPINTVAL = 261,
69 LOCALVAL_ID = 262,
70 GLOBALVAL_ID = 263,
71 FPVAL = 264,
72 VOID = 265,
73 INTTYPE = 266,
74 FLOAT = 267,
75 DOUBLE = 268,
76 LABEL = 269,
77 TYPE = 270,
78 LOCALVAR = 271,
79 GLOBALVAR = 272,
80 LABELSTR = 273,
81 STRINGCONSTANT = 274,
82 ATSTRINGCONSTANT = 275,
83 PCTSTRINGCONSTANT = 276,
84 ZEROINITIALIZER = 277,
85 TRUETOK = 278,
86 FALSETOK = 279,
87 BEGINTOK = 280,
88 ENDTOK = 281,
89 DECLARE = 282,
90 DEFINE = 283,
91 GLOBAL = 284,
92 CONSTANT = 285,
93 SECTION = 286,
94 ALIAS = 287,
95 VOLATILE = 288,
96 THREAD_LOCAL = 289,
97 TO = 290,
98 DOTDOTDOT = 291,
99 NULL_TOK = 292,
100 UNDEF = 293,
101 INTERNAL = 294,
102 LINKONCE = 295,
103 WEAK = 296,
104 APPENDING = 297,
105 DLLIMPORT = 298,
106 DLLEXPORT = 299,
107 EXTERN_WEAK = 300,
108 OPAQUE = 301,
109 EXTERNAL = 302,
110 TARGET = 303,
111 TRIPLE = 304,
112 ALIGN = 305,
113 DEPLIBS = 306,
114 CALL = 307,
115 TAIL = 308,
116 ASM_TOK = 309,
117 MODULE = 310,
118 SIDEEFFECT = 311,
119 CC_TOK = 312,
120 CCC_TOK = 313,
121 FASTCC_TOK = 314,
122 COLDCC_TOK = 315,
123 X86_STDCALLCC_TOK = 316,
124 X86_FASTCALLCC_TOK = 317,
125 DATALAYOUT = 318,
126 RET = 319,
127 BR = 320,
128 SWITCH = 321,
129 INVOKE = 322,
130 UNWIND = 323,
131 UNREACHABLE = 324,
132 ADD = 325,
133 SUB = 326,
134 MUL = 327,
135 UDIV = 328,
136 SDIV = 329,
137 FDIV = 330,
138 UREM = 331,
139 SREM = 332,
140 FREM = 333,
141 AND = 334,
142 OR = 335,
143 XOR = 336,
144 SHL = 337,
145 LSHR = 338,
146 ASHR = 339,
147 ICMP = 340,
148 FCMP = 341,
149 EQ = 342,
150 NE = 343,
151 SLT = 344,
152 SGT = 345,
153 SLE = 346,
154 SGE = 347,
155 ULT = 348,
156 UGT = 349,
157 ULE = 350,
158 UGE = 351,
159 OEQ = 352,
160 ONE = 353,
161 OLT = 354,
162 OGT = 355,
163 OLE = 356,
164 OGE = 357,
165 ORD = 358,
166 UNO = 359,
167 UEQ = 360,
168 UNE = 361,
169 MALLOC = 362,
170 ALLOCA = 363,
171 FREE = 364,
172 LOAD = 365,
173 STORE = 366,
174 GETELEMENTPTR = 367,
175 TRUNC = 368,
176 ZEXT = 369,
177 SEXT = 370,
178 FPTRUNC = 371,
179 FPEXT = 372,
180 BITCAST = 373,
181 UITOFP = 374,
182 SITOFP = 375,
183 FPTOUI = 376,
184 FPTOSI = 377,
185 INTTOPTR = 378,
186 PTRTOINT = 379,
187 PHI_TOK = 380,
188 SELECT = 381,
189 VAARG = 382,
190 EXTRACTELEMENT = 383,
191 INSERTELEMENT = 384,
192 SHUFFLEVECTOR = 385,
193 SIGNEXT = 386,
194 ZEROEXT = 387,
195 NORETURN = 388,
196 INREG = 389,
197 SRET = 390,
198 NOUNWIND = 391,
199 NOALIAS = 392,
200 BYVAL = 393,
201 NEST = 394,
202 DEFAULT = 395,
203 HIDDEN = 396,
204 PROTECTED = 397
205 };
206#endif
Reid Spencerb8f85052007-07-31 03:50:36 +0000207#define ESINT64VAL 258
208#define EUINT64VAL 259
209#define ESAPINTVAL 260
210#define EUAPINTVAL 261
211#define LOCALVAL_ID 262
212#define GLOBALVAL_ID 263
213#define FPVAL 264
214#define VOID 265
215#define INTTYPE 266
216#define FLOAT 267
217#define DOUBLE 268
218#define LABEL 269
219#define TYPE 270
220#define LOCALVAR 271
221#define GLOBALVAR 272
222#define LABELSTR 273
223#define STRINGCONSTANT 274
224#define ATSTRINGCONSTANT 275
225#define PCTSTRINGCONSTANT 276
226#define ZEROINITIALIZER 277
227#define TRUETOK 278
228#define FALSETOK 279
229#define BEGINTOK 280
230#define ENDTOK 281
231#define DECLARE 282
232#define DEFINE 283
233#define GLOBAL 284
234#define CONSTANT 285
235#define SECTION 286
236#define ALIAS 287
237#define VOLATILE 288
238#define THREAD_LOCAL 289
239#define TO 290
240#define DOTDOTDOT 291
241#define NULL_TOK 292
242#define UNDEF 293
243#define INTERNAL 294
244#define LINKONCE 295
245#define WEAK 296
246#define APPENDING 297
247#define DLLIMPORT 298
248#define DLLEXPORT 299
249#define EXTERN_WEAK 300
250#define OPAQUE 301
251#define EXTERNAL 302
252#define TARGET 303
253#define TRIPLE 304
254#define ALIGN 305
255#define DEPLIBS 306
256#define CALL 307
257#define TAIL 308
258#define ASM_TOK 309
259#define MODULE 310
260#define SIDEEFFECT 311
261#define CC_TOK 312
262#define CCC_TOK 313
263#define FASTCC_TOK 314
264#define COLDCC_TOK 315
265#define X86_STDCALLCC_TOK 316
266#define X86_FASTCALLCC_TOK 317
267#define DATALAYOUT 318
268#define RET 319
269#define BR 320
270#define SWITCH 321
271#define INVOKE 322
272#define UNWIND 323
273#define UNREACHABLE 324
274#define ADD 325
275#define SUB 326
276#define MUL 327
277#define UDIV 328
278#define SDIV 329
279#define FDIV 330
280#define UREM 331
281#define SREM 332
282#define FREM 333
283#define AND 334
284#define OR 335
285#define XOR 336
286#define SHL 337
287#define LSHR 338
288#define ASHR 339
289#define ICMP 340
290#define FCMP 341
291#define EQ 342
292#define NE 343
293#define SLT 344
294#define SGT 345
295#define SLE 346
296#define SGE 347
297#define ULT 348
298#define UGT 349
299#define ULE 350
300#define UGE 351
301#define OEQ 352
302#define ONE 353
303#define OLT 354
304#define OGT 355
305#define OLE 356
306#define OGE 357
307#define ORD 358
308#define UNO 359
309#define UEQ 360
310#define UNE 361
311#define MALLOC 362
312#define ALLOCA 363
313#define FREE 364
314#define LOAD 365
315#define STORE 366
316#define GETELEMENTPTR 367
317#define TRUNC 368
318#define ZEXT 369
319#define SEXT 370
320#define FPTRUNC 371
321#define FPEXT 372
322#define BITCAST 373
323#define UITOFP 374
324#define SITOFP 375
325#define FPTOUI 376
326#define FPTOSI 377
327#define INTTOPTR 378
328#define PTRTOINT 379
329#define PHI_TOK 380
330#define SELECT 381
331#define VAARG 382
332#define EXTRACTELEMENT 383
333#define INSERTELEMENT 384
334#define SHUFFLEVECTOR 385
335#define SIGNEXT 386
336#define ZEROEXT 387
337#define NORETURN 388
338#define INREG 389
339#define SRET 390
340#define NOUNWIND 391
341#define NOALIAS 392
342#define BYVAL 393
343#define NEST 394
344#define DEFAULT 395
345#define HIDDEN 396
346#define PROTECTED 397
347
348
349
350
351/* Copy the first part of user declarations. */
David Greene718fda32007-08-01 03:59:32 +0000352#line 14 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000353
354#include "ParserInternals.h"
355#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000356#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000357#include "llvm/Instructions.h"
358#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000359#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000361#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000362#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000363#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000364#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000365#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000366#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000367#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000368#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000370#ifndef NDEBUG
371#define YYDEBUG 1
372#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000373
Reid Spencere4f47592006-08-18 17:32:55 +0000374// The following is a gross hack. In order to rid the libAsmParser library of
375// exceptions, we have to have a way of getting the yyparse function to go into
376// an error situation. So, whenever we want an error to occur, the GenerateError
377// function (see bottom of file) sets TriggerError. Then, at the end of each
378// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
379// (a goto) to put YACC in error state. Furthermore, several calls to
380// GenerateError are made from inside productions and they must simulate the
381// previous exception behavior by exiting the production immediately. We have
382// replaced these with the GEN_ERROR macro which calls GeneratError and then
383// immediately invokes YYERROR. This would be so much cleaner if it was a
384// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000385static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000386#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000387#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
388
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
390int yylex(); // declaration" of xxx warnings.
391int yyparse();
392
393namespace llvm {
394 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000395#if YYDEBUG
396static cl::opt<bool>
397Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
398 cl::Hidden, cl::init(false));
399#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000400}
401using namespace llvm;
402
403static Module *ParserResult;
404
405// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
406// relating to upreferences in the input stream.
407//
408//#define DEBUG_UPREFS 1
409#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000410#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000411#else
412#define UR_OUT(X)
413#endif
414
415#define YYERROR_VERBOSE 1
416
Chris Lattnerb475c422005-11-12 18:22:38 +0000417static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418
419
420// This contains info used when building the body of a function. It is
421// destroyed when the function is completed.
422//
423typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000424
Reid Spencer68a24bd2005-08-27 18:50:39 +0000425static void
Reid Spencer93c40032007-03-19 18:40:50 +0000426ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000427
428static struct PerModuleInfo {
429 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000430 ValueList Values; // Module level numbered definitions
431 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000432 std::vector<PATypeHolder> Types;
433 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434
435 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000436 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437 /// that we can resolve them later and print error messages as appropriate.
438 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
439
440 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
441 // references to global values. Global values may be referenced before they
442 // are defined, and if so, the temporary object that they represent is held
443 // here. This is used for forward references of GlobalValues.
444 //
445 typedef std::map<std::pair<const PointerType *,
446 ValID>, GlobalValue*> GlobalRefsType;
447 GlobalRefsType GlobalRefs;
448
449 void ModuleDone() {
450 // If we could not resolve some functions at function compilation time
451 // (calls to functions before they are defined), resolve them now... Types
452 // are resolved when the constant pool has been completely parsed.
453 //
454 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000455 if (TriggerError)
456 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457
458 // Check to make sure that all global value forward references have been
459 // resolved!
460 //
461 if (!GlobalRefs.empty()) {
462 std::string UndefinedReferences = "Unresolved global references exist:\n";
463
464 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
465 I != E; ++I) {
466 UndefinedReferences += " " + I->first.first->getDescription() + " " +
467 I->first.second.getName() + "\n";
468 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000469 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000470 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471 }
472
473 Values.clear(); // Clear out function local definitions
474 Types.clear();
475 CurrentModule = 0;
476 }
477
Reid Spencer68a24bd2005-08-27 18:50:39 +0000478 // GetForwardRefForGlobal - Check to see if there is a forward reference
479 // for this global. If so, remove it from the GlobalRefs map and return it.
480 // If not, just return null.
481 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
482 // Check to see if there is a forward reference to this global variable...
483 // if there is, eliminate it and patch the reference to use the new def'n.
484 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
485 GlobalValue *Ret = 0;
486 if (I != GlobalRefs.end()) {
487 Ret = I->second;
488 GlobalRefs.erase(I);
489 }
490 return Ret;
491 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000492
493 bool TypeIsUnresolved(PATypeHolder* PATy) {
494 // If it isn't abstract, its resolved
495 const Type* Ty = PATy->get();
496 if (!Ty->isAbstract())
497 return false;
498 // Traverse the type looking for abstract types. If it isn't abstract then
499 // we don't need to traverse that leg of the type.
500 std::vector<const Type*> WorkList, SeenList;
501 WorkList.push_back(Ty);
502 while (!WorkList.empty()) {
503 const Type* Ty = WorkList.back();
504 SeenList.push_back(Ty);
505 WorkList.pop_back();
506 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
507 // Check to see if this is an unresolved type
508 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
509 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
510 for ( ; I != E; ++I) {
511 if (I->second.get() == OpTy)
512 return true;
513 }
514 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
515 const Type* TheTy = SeqTy->getElementType();
516 if (TheTy->isAbstract() && TheTy != Ty) {
517 std::vector<const Type*>::iterator I = SeenList.begin(),
518 E = SeenList.end();
519 for ( ; I != E; ++I)
520 if (*I == TheTy)
521 break;
522 if (I == E)
523 WorkList.push_back(TheTy);
524 }
525 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
526 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
527 const Type* TheTy = StrTy->getElementType(i);
528 if (TheTy->isAbstract() && TheTy != Ty) {
529 std::vector<const Type*>::iterator I = SeenList.begin(),
530 E = SeenList.end();
531 for ( ; I != E; ++I)
532 if (*I == TheTy)
533 break;
534 if (I == E)
535 WorkList.push_back(TheTy);
536 }
537 }
538 }
539 }
540 return false;
541 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542} CurModule;
543
544static struct PerFunctionInfo {
545 Function *CurrentFunction; // Pointer to current function being created
546
Reid Spencer93c40032007-03-19 18:40:50 +0000547 ValueList Values; // Keep track of #'d definitions
548 unsigned NextValNum;
549 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000550 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000551 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000552 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000553
554 /// BBForwardRefs - When we see forward references to basic blocks, keep
555 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000556 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557
558 inline PerFunctionInfo() {
559 CurrentFunction = 0;
560 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000561 Linkage = GlobalValue::ExternalLinkage;
562 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000563 }
564
565 inline void FunctionStart(Function *M) {
566 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000567 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 }
569
570 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000571 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000572 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000573 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000574 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000575 return;
576 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000577
578 // Resolve all forward references now.
579 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
580
581 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000582 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000583 CurrentFunction = 0;
584 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000585 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000586 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000587 }
588} CurFun; // Info for the current function...
589
590static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
591
592
593//===----------------------------------------------------------------------===//
594// Code to handle definitions of all the types
595//===----------------------------------------------------------------------===//
596
Reid Spencer93c40032007-03-19 18:40:50 +0000597static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
598 // Things that have names or are void typed don't get slot numbers
599 if (V->hasName() || (V->getType() == Type::VoidTy))
600 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601
Reid Spencer93c40032007-03-19 18:40:50 +0000602 // In the case of function values, we have to allow for the forward reference
603 // of basic blocks, which are included in the numbering. Consequently, we keep
604 // track of the next insertion location with NextValNum. When a BB gets
605 // inserted, it could change the size of the CurFun.Values vector.
606 if (&ValueTab == &CurFun.Values) {
607 if (ValueTab.size() <= CurFun.NextValNum)
608 ValueTab.resize(CurFun.NextValNum+1);
609 ValueTab[CurFun.NextValNum++] = V;
610 return;
611 }
612 // For all other lists, its okay to just tack it on the back of the vector.
613 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614}
615
616static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
617 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000618 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000620 if (D.Num < CurModule.Types.size())
621 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000623 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000624 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625 D.destroy(); // Free old strdup'd memory...
626 return N;
627 }
628 break;
629 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000630 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000632 }
633
634 // If we reached here, we referenced either a symbol that we don't know about
635 // or an id number that hasn't been read yet. We may be referencing something
636 // forward, so just create an entry to be resolved later and get to it...
637 //
638 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
639
640
641 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000642 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000643 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 return 0;
645 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000646 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000647 return 0;
648 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 }
650
Reid Spencer861d9d62006-11-28 07:29:44 +0000651 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000653 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654
Reid Spencer861d9d62006-11-28 07:29:44 +0000655 Type *Typ = OpaqueType::get();
656 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
657 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000658 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000659
Reid Spencer93c40032007-03-19 18:40:50 +0000660// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661// the provided ValID. If the value exists and has already been defined, return
662// it. Otherwise return null.
663//
Reid Spencer93c40032007-03-19 18:40:50 +0000664static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000665 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000666 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000668 return 0;
669 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670
671 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000672 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000673 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000674 if (D.Num >= CurFun.Values.size())
675 return 0;
676 Value *Result = CurFun.Values[D.Num];
677 if (Ty != Result->getType()) {
678 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
679 Result->getType()->getDescription() + "' does not match "
680 "expected type, '" + Ty->getDescription() + "'");
681 return 0;
682 }
683 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684 }
685 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000686 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000687 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000688 Value *Result = CurModule.Values[D.Num];
689 if (Ty != Result->getType()) {
690 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
691 Result->getType()->getDescription() + "' does not match "
692 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000693 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000694 }
695 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000697
698 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000699 if (!inFunctionScope())
700 return 0;
701 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000702 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000703 if (N == 0)
704 return 0;
705 if (N->getType() != Ty)
706 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000707
708 D.destroy(); // Free old strdup'd memory...
709 return N;
710 }
711 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000712 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000713 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000714 if (N == 0)
715 return 0;
716 if (N->getType() != Ty)
717 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718
719 D.destroy(); // Free old strdup'd memory...
720 return N;
721 }
722
723 // Check to make sure that "Ty" is an integral type, and that our
724 // value will fit into the specified type...
725 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000726 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000727 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000728 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000729 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000730 return 0;
731 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000732 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000733
734 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000735 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
736 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000737 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000738 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000739 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000740 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000741 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000742 }
743 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000744 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745 }
746
747 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000748 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000749 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000750 return 0;
751 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 return ConstantFP::get(Ty, D.ConstPoolFP);
753
754 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000755 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000756 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 return 0;
758 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759 return ConstantPointerNull::get(cast<PointerType>(Ty));
760
761 case ValID::ConstUndefVal: // Is it an undef value?
762 return UndefValue::get(Ty);
763
Chris Lattner7aa61892005-12-21 17:53:23 +0000764 case ValID::ConstZeroVal: // Is it a zero value?
765 return Constant::getNullValue(Ty);
766
Reid Spencer68a24bd2005-08-27 18:50:39 +0000767 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000768 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000769 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000770 return 0;
771 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772 return D.ConstantValue;
773
Chris Lattner0e9c3762006-01-25 22:27:16 +0000774 case ValID::InlineAsmVal: { // Inline asm expression
775 const PointerType *PTy = dyn_cast<PointerType>(Ty);
776 const FunctionType *FTy =
777 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000778 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000779 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000780 return 0;
781 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000782 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
783 D.IAD->HasSideEffects);
784 D.destroy(); // Free InlineAsmDescriptor.
785 return IA;
786 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000788 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789 return 0;
790 } // End of switch
791
Reid Spencera9720f52007-02-05 17:04:00 +0000792 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793 return 0;
794}
795
Reid Spencer93c40032007-03-19 18:40:50 +0000796// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797// value is not already defined, it "improvises" by creating a placeholder var
798// that looks and acts just like the requested variable. When the value is
799// defined later, all uses of the placeholder variable are replaced with the
800// real thing.
801//
802static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000803 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000804 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000805 return 0;
806 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807
808 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000809 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000810 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000811 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000812
Reid Spencer5b7e7532006-09-28 19:28:24 +0000813 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000814 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000815 return 0;
816 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817
818 // If we reached here, we referenced either a symbol that we don't know about
819 // or an id number that hasn't been read yet. We may be referencing something
820 // forward, so just create an entry to be resolved later and get to it...
821 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000822 switch (ID.Type) {
823 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000824 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000825 const PointerType *PTy = dyn_cast<PointerType>(Ty);
826 if (!PTy) {
827 GenerateError("Invalid type for reference to global" );
828 return 0;
829 }
830 const Type* ElTy = PTy->getElementType();
831 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
832 V = new Function(FTy, GlobalValue::ExternalLinkage);
833 else
834 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
835 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000836 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000837 default:
838 V = new Argument(Ty);
839 }
840
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841 // Remember where this forward reference came from. FIXME, shouldn't we try
842 // to recycle these things??
843 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
844 llvmAsmlineno)));
845
846 if (inFunctionScope())
847 InsertValue(V, CurFun.LateResolveValues);
848 else
849 InsertValue(V, CurModule.LateResolveValues);
850 return V;
851}
852
Reid Spencer93c40032007-03-19 18:40:50 +0000853/// defineBBVal - This is a definition of a new basic block with the specified
854/// identifier which must be the same as CurFun.NextValNum, if its numeric.
855static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000856 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000857
Reid Spencer68a24bd2005-08-27 18:50:39 +0000858 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859
Reid Spencer93c40032007-03-19 18:40:50 +0000860 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000861
Reid Spencer93c40032007-03-19 18:40:50 +0000862 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
863 if (BBI != CurFun.BBForwardRefs.end()) {
864 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000865 // The forward declaration could have been inserted anywhere in the
866 // function: insert it into the correct place now.
867 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
868 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000869
Reid Spencer66728ef2007-03-20 01:13:36 +0000870 // We're about to erase the entry, save the key so we can clean it up.
871 ValID Tmp = BBI->first;
872
Reid Spencer93c40032007-03-19 18:40:50 +0000873 // Erase the forward ref from the map as its no longer "forward"
874 CurFun.BBForwardRefs.erase(ID);
875
Reid Spencer66728ef2007-03-20 01:13:36 +0000876 // The key has been removed from the map but so we don't want to leave
877 // strdup'd memory around so destroy it too.
878 Tmp.destroy();
879
Reid Spencer93c40032007-03-19 18:40:50 +0000880 // If its a numbered definition, bump the number and set the BB value.
881 if (ID.Type == ValID::LocalID) {
882 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
883 InsertValue(BB);
884 }
885
886 ID.destroy();
887 return BB;
888 }
889
890 // We haven't seen this BB before and its first mention is a definition.
891 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000892 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000893 BB = new BasicBlock(Name, CurFun.CurrentFunction);
894 if (ID.Type == ValID::LocalID) {
895 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
896 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897 }
Reid Spencer93c40032007-03-19 18:40:50 +0000898
899 ID.destroy(); // Free strdup'd memory
900 return BB;
901}
902
903/// getBBVal - get an existing BB value or create a forward reference for it.
904///
905static BasicBlock *getBBVal(const ValID &ID) {
906 assert(inFunctionScope() && "Can't get basic block at global scope!");
907
908 BasicBlock *BB = 0;
909
910 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
911 if (BBI != CurFun.BBForwardRefs.end()) {
912 BB = BBI->second;
913 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000914 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000915 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
916 if (N)
917 if (N->getType()->getTypeID() == Type::LabelTyID)
918 BB = cast<BasicBlock>(N);
919 else
920 GenerateError("Reference to label '" + Name + "' is actually of type '"+
921 N->getType()->getDescription() + "'");
922 } else if (ID.Type == ValID::LocalID) {
923 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
924 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
925 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
926 else
927 GenerateError("Reference to label '%" + utostr(ID.Num) +
928 "' is actually of type '"+
929 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
930 }
931 } else {
932 GenerateError("Illegal label reference " + ID.getName());
933 return 0;
934 }
935
936 // If its already been defined, return it now.
937 if (BB) {
938 ID.destroy(); // Free strdup'd memory.
939 return BB;
940 }
941
942 // Otherwise, this block has not been seen before, create it.
943 std::string Name;
944 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000945 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000946 BB = new BasicBlock(Name, CurFun.CurrentFunction);
947
948 // Insert it in the forward refs map.
949 CurFun.BBForwardRefs[ID] = BB;
950
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951 return BB;
952}
953
954
955//===----------------------------------------------------------------------===//
956// Code to handle forward references in instructions
957//===----------------------------------------------------------------------===//
958//
959// This code handles the late binding needed with statements that reference
960// values not defined yet... for example, a forward branch, or the PHI node for
961// a loop body.
962//
963// This keeps a table (CurFun.LateResolveValues) of all such forward references
964// and back patchs after we are done.
965//
966
967// ResolveDefinitions - If we could not resolve some defs at parsing
968// time (forward branches, phi functions for loops, etc...) resolve the
969// defs now...
970//
971static void
Reid Spencer93c40032007-03-19 18:40:50 +0000972ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000973 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000974 while (!LateResolvers.empty()) {
975 Value *V = LateResolvers.back();
976 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000977
Reid Spencer93c40032007-03-19 18:40:50 +0000978 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
979 CurModule.PlaceHolderInfo.find(V);
980 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981
Reid Spencer93c40032007-03-19 18:40:50 +0000982 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000983
Reid Spencer93c40032007-03-19 18:40:50 +0000984 Value *TheRealValue = getExistingVal(V->getType(), DID);
985 if (TriggerError)
986 return;
987 if (TheRealValue) {
988 V->replaceAllUsesWith(TheRealValue);
989 delete V;
990 CurModule.PlaceHolderInfo.erase(PHI);
991 } else if (FutureLateResolvers) {
992 // Functions have their unresolved items forwarded to the module late
993 // resolver table
994 InsertValue(V, *FutureLateResolvers);
995 } else {
996 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
997 GenerateError("Reference to an invalid definition: '" +DID.getName()+
998 "' of type '" + V->getType()->getDescription() + "'",
999 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001000 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001001 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001002 GenerateError("Reference to an invalid definition: #" +
1003 itostr(DID.Num) + " of type '" +
1004 V->getType()->getDescription() + "'",
1005 PHI->second.second);
1006 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001007 }
1008 }
1009 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010 LateResolvers.clear();
1011}
1012
1013// ResolveTypeTo - A brand new type was just declared. This means that (if
1014// name is not null) things referencing Name can be resolved. Otherwise, things
1015// refering to the number can be resolved. Do this now.
1016//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001017static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001019 if (Name)
1020 D = ValID::createLocalName(*Name);
1021 else
1022 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001023
Reid Spencer861d9d62006-11-28 07:29:44 +00001024 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001025 CurModule.LateResolveTypes.find(D);
1026 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001027 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001028 CurModule.LateResolveTypes.erase(I);
1029 }
1030}
1031
1032// setValueName - Set the specified value to the name given. The name may be
1033// null potentially, in which case this is a noop. The string passed in is
1034// assumed to be a malloc'd string buffer, and is free'd by this function.
1035//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001036static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001037 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001038 std::string Name(*NameStr); // Copy string
1039 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040
Reid Spencer41dff5e2007-01-26 08:05:27 +00001041 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001042 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001043 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001044 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001045
Reid Spencera9720f52007-02-05 17:04:00 +00001046 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001047 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1048 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001049 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001050 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001051 return;
1052 }
1053
1054 // Set the name.
1055 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056}
1057
1058/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1059/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001060static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001061ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001062 GlobalValue::LinkageTypes Linkage,
1063 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001064 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001065 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001066 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001067 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001068 return 0;
1069 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001070
1071 const PointerType *PTy = PointerType::get(Ty);
1072
1073 std::string Name;
1074 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001075 Name = *NameStr; // Copy string
1076 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 }
1078
1079 // See if this global value was forward referenced. If so, recycle the
1080 // object.
1081 ValID ID;
1082 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001083 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001085 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086 }
1087
1088 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1089 // Move the global to the end of the list, from whereever it was
1090 // previously inserted.
1091 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1092 CurModule.CurrentModule->getGlobalList().remove(GV);
1093 CurModule.CurrentModule->getGlobalList().push_back(GV);
1094 GV->setInitializer(Initializer);
1095 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001096 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001097 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001098 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001099 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001100 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001101 }
1102
Reid Spenceref9b9a72007-02-05 20:47:22 +00001103 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001104 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001105 // if the global we're parsing has an initializer (is a definition) and
1106 // has external linkage.
1107 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1108 // If there is already a global with external linkage with this name
1109 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1110 // If we allow this GVar to get created, it will be renamed in the
1111 // symbol table because it conflicts with an existing GVar. We can't
1112 // allow redefinition of GVars whose linking indicates that their name
1113 // must stay the same. Issue the error.
1114 GenerateError("Redefinition of global variable named '" + Name +
1115 "' of type '" + Ty->getDescription() + "'");
1116 return 0;
1117 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001118 }
1119
1120 // Otherwise there is no existing GV to use, create one now.
1121 GlobalVariable *GV =
1122 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001123 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001124 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001125 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001126 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001127}
1128
1129// setTypeName - Set the specified type to the name given. The name may be
1130// null potentially, in which case this is a noop. The string passed in is
1131// assumed to be a malloc'd string buffer, and is freed by this function.
1132//
1133// This function returns true if the type has already been defined, but is
1134// allowed to be redefined in the specified context. If the name is a new name
1135// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001136static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001137 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001138 if (NameStr == 0) return false;
1139
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001140 std::string Name(*NameStr); // Copy string
1141 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001142
1143 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001144 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001145 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001146 return false;
1147 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001148
1149 // Set the type name, checking for conflicts as we do so.
1150 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1151
1152 if (AlreadyExists) { // Inserting a name that is already defined???
1153 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001154 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001155
1156 // There is only one case where this is allowed: when we are refining an
1157 // opaque type. In this case, Existing will be an opaque type.
1158 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1159 // We ARE replacing an opaque type!
1160 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1161 return true;
1162 }
1163
1164 // Otherwise, this is an attempt to redefine a type. That's okay if
1165 // the redefinition is identical to the original. This will be so if
1166 // Existing and T point to the same Type object. In this one case we
1167 // allow the equivalent redefinition.
1168 if (Existing == T) return true; // Yes, it's equal.
1169
1170 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001171 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001172 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173 }
1174
1175 return false;
1176}
1177
1178//===----------------------------------------------------------------------===//
1179// Code for handling upreferences in type names...
1180//
1181
1182// TypeContains - Returns true if Ty directly contains E in it.
1183//
1184static bool TypeContains(const Type *Ty, const Type *E) {
1185 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1186 E) != Ty->subtype_end();
1187}
1188
1189namespace {
1190 struct UpRefRecord {
1191 // NestingLevel - The number of nesting levels that need to be popped before
1192 // this type is resolved.
1193 unsigned NestingLevel;
1194
1195 // LastContainedTy - This is the type at the current binding level for the
1196 // type. Every time we reduce the nesting level, this gets updated.
1197 const Type *LastContainedTy;
1198
1199 // UpRefTy - This is the actual opaque type that the upreference is
1200 // represented with.
1201 OpaqueType *UpRefTy;
1202
1203 UpRefRecord(unsigned NL, OpaqueType *URTy)
1204 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1205 };
1206}
1207
1208// UpRefs - A list of the outstanding upreferences that need to be resolved.
1209static std::vector<UpRefRecord> UpRefs;
1210
1211/// HandleUpRefs - Every time we finish a new layer of types, this function is
1212/// called. It loops through the UpRefs vector, which is a list of the
1213/// currently active types. For each type, if the up reference is contained in
1214/// the newly completed type, we decrement the level count. When the level
1215/// count reaches zero, the upreferenced type is the type that is passed in:
1216/// thus we can complete the cycle.
1217///
1218static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001219 // If Ty isn't abstract, or if there are no up-references in it, then there is
1220 // nothing to resolve here.
1221 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1222
Reid Spencer68a24bd2005-08-27 18:50:39 +00001223 PATypeHolder Ty(ty);
1224 UR_OUT("Type '" << Ty->getDescription() <<
1225 "' newly formed. Resolving upreferences.\n" <<
1226 UpRefs.size() << " upreferences active!\n");
1227
1228 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1229 // to zero), we resolve them all together before we resolve them to Ty. At
1230 // the end of the loop, if there is anything to resolve to Ty, it will be in
1231 // this variable.
1232 OpaqueType *TypeToResolve = 0;
1233
1234 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1235 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1236 << UpRefs[i].second->getDescription() << ") = "
1237 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1238 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1239 // Decrement level of upreference
1240 unsigned Level = --UpRefs[i].NestingLevel;
1241 UpRefs[i].LastContainedTy = Ty;
1242 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1243 if (Level == 0) { // Upreference should be resolved!
1244 if (!TypeToResolve) {
1245 TypeToResolve = UpRefs[i].UpRefTy;
1246 } else {
1247 UR_OUT(" * Resolving upreference for "
1248 << UpRefs[i].second->getDescription() << "\n";
1249 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1250 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1251 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1252 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1253 }
1254 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1255 --i; // Do not skip the next element...
1256 }
1257 }
1258 }
1259
1260 if (TypeToResolve) {
1261 UR_OUT(" * Resolving upreference for "
1262 << UpRefs[i].second->getDescription() << "\n";
1263 std::string OldName = TypeToResolve->getDescription());
1264 TypeToResolve->refineAbstractTypeTo(Ty);
1265 }
1266
1267 return Ty;
1268}
1269
Reid Spencer68a24bd2005-08-27 18:50:39 +00001270//===----------------------------------------------------------------------===//
1271// RunVMAsmParser - Define an interface to this parser
1272//===----------------------------------------------------------------------===//
1273//
Reid Spencer14310612006-12-31 05:40:51 +00001274static Module* RunParser(Module * M);
1275
Reid Spencer68a24bd2005-08-27 18:50:39 +00001276Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1277 set_scan_file(F);
1278
1279 CurFilename = Filename;
1280 return RunParser(new Module(CurFilename));
1281}
1282
1283Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1284 set_scan_string(AsmString);
1285
1286 CurFilename = "from_memory";
1287 if (M == NULL) {
1288 return RunParser(new Module (CurFilename));
1289 } else {
1290 return RunParser(M);
1291 }
1292}
1293
1294
Reid Spencerb8f85052007-07-31 03:50:36 +00001295
1296/* Enabling traces. */
1297#ifndef YYDEBUG
1298# define YYDEBUG 0
1299#endif
1300
1301/* Enabling verbose error messages. */
1302#ifdef YYERROR_VERBOSE
1303# undef YYERROR_VERBOSE
1304# define YYERROR_VERBOSE 1
1305#else
1306# define YYERROR_VERBOSE 0
1307#endif
1308
Reid Spencerb8f85052007-07-31 03:50:36 +00001309#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
David Greene718fda32007-08-01 03:59:32 +00001310#line 957 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00001311typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001312 llvm::Module *ModuleVal;
1313 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001314 llvm::BasicBlock *BasicBlockVal;
1315 llvm::TerminatorInst *TermInstVal;
1316 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001317 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001318
Reid Spencera132e042006-12-03 05:46:11 +00001319 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001320 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001321 llvm::PATypeHolder *TypeVal;
1322 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001323 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001324 llvm::ArgListType *ArgList;
1325 llvm::TypeWithAttrs TypeWithAttrs;
1326 llvm::TypeWithAttrsList *TypeWithAttrsList;
1327 llvm::ValueRefList *ValueRefList;
1328
Reid Spencer68a24bd2005-08-27 18:50:39 +00001329 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001330 std::list<std::pair<llvm::Value*,
1331 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001332 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001333 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334
1335 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001336 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001337 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001338 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339 int64_t SInt64Val;
1340 uint64_t UInt64Val;
1341 int SIntVal;
1342 unsigned UIntVal;
1343 double FPVal;
1344 bool BoolVal;
1345
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001346 std::string *StrVal; // This memory must be deleted
1347 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001348
Reid Spencera132e042006-12-03 05:46:11 +00001349 llvm::Instruction::BinaryOps BinaryOpVal;
1350 llvm::Instruction::TermOps TermOpVal;
1351 llvm::Instruction::MemoryOps MemOpVal;
1352 llvm::Instruction::CastOps CastOpVal;
1353 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001354 llvm::ICmpInst::Predicate IPredicate;
1355 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001356} YYSTYPE;
David Greene718fda32007-08-01 03:59:32 +00001357/* Line 191 of yacc.c. */
1358#line 1359 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001359# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1360# define YYSTYPE_IS_DECLARED 1
1361# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001362#endif
1363
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001364
Reid Spencer68a24bd2005-08-27 18:50:39 +00001365
Reid Spencerb8f85052007-07-31 03:50:36 +00001366/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001367
1368
David Greene718fda32007-08-01 03:59:32 +00001369/* Line 214 of yacc.c. */
1370#line 1371 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001371
1372#if ! defined (yyoverflow) || YYERROR_VERBOSE
1373
1374/* The parser invokes alloca or malloc; define the necessary symbols. */
1375
1376# ifdef YYSTACK_USE_ALLOCA
1377# if YYSTACK_USE_ALLOCA
David Greene718fda32007-08-01 03:59:32 +00001378# define YYSTACK_ALLOC alloca
1379# endif
1380# else
1381# if defined (alloca) || defined (_ALLOCA_H)
1382# define YYSTACK_ALLOC alloca
1383# else
Reid Spencerb8f85052007-07-31 03:50:36 +00001384# ifdef __GNUC__
1385# define YYSTACK_ALLOC __builtin_alloca
Reid Spencerb8f85052007-07-31 03:50:36 +00001386# endif
1387# endif
1388# endif
1389
1390# ifdef YYSTACK_ALLOC
1391 /* Pacify GCC's `empty if-body' warning. */
1392# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Reid Spencerb8f85052007-07-31 03:50:36 +00001393# else
David Greene718fda32007-08-01 03:59:32 +00001394# if defined (__STDC__) || defined (__cplusplus)
1395# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1396# define YYSIZE_T size_t
Reid Spencerb8f85052007-07-31 03:50:36 +00001397# endif
David Greene718fda32007-08-01 03:59:32 +00001398# define YYSTACK_ALLOC malloc
1399# define YYSTACK_FREE free
Reid Spencerb8f85052007-07-31 03:50:36 +00001400# endif
1401#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1402
1403
1404#if (! defined (yyoverflow) \
1405 && (! defined (__cplusplus) \
1406 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1407
1408/* A type that is properly aligned for any stack member. */
1409union yyalloc
1410{
David Greene718fda32007-08-01 03:59:32 +00001411 short yyss;
Reid Spencerb8f85052007-07-31 03:50:36 +00001412 YYSTYPE yyvs;
1413 };
1414
1415/* The size of the maximum gap between one aligned stack and the next. */
1416# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1417
1418/* The size of an array large to enough to hold all stacks, each with
1419 N elements. */
1420# define YYSTACK_BYTES(N) \
David Greene718fda32007-08-01 03:59:32 +00001421 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
Reid Spencerb8f85052007-07-31 03:50:36 +00001422 + YYSTACK_GAP_MAXIMUM)
1423
1424/* Copy COUNT objects from FROM to TO. The source and destination do
1425 not overlap. */
1426# ifndef YYCOPY
1427# if defined (__GNUC__) && 1 < __GNUC__
1428# define YYCOPY(To, From, Count) \
1429 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1430# else
1431# define YYCOPY(To, From, Count) \
1432 do \
1433 { \
David Greene718fda32007-08-01 03:59:32 +00001434 register YYSIZE_T yyi; \
Reid Spencerb8f85052007-07-31 03:50:36 +00001435 for (yyi = 0; yyi < (Count); yyi++) \
1436 (To)[yyi] = (From)[yyi]; \
1437 } \
1438 while (0)
1439# endif
1440# endif
1441
1442/* Relocate STACK from its old location to the new one. The
1443 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1444 elements in the stack, and YYPTR gives the new location of the
1445 stack. Advance YYPTR to a properly aligned location for the next
1446 stack. */
1447# define YYSTACK_RELOCATE(Stack) \
1448 do \
1449 { \
1450 YYSIZE_T yynewbytes; \
1451 YYCOPY (&yyptr->Stack, Stack, yysize); \
1452 Stack = &yyptr->Stack; \
1453 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1454 yyptr += yynewbytes / sizeof (*yyptr); \
1455 } \
1456 while (0)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001457
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001458#endif
1459
Reid Spencerb8f85052007-07-31 03:50:36 +00001460#if defined (__STDC__) || defined (__cplusplus)
1461 typedef signed char yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001462#else
David Greene718fda32007-08-01 03:59:32 +00001463 typedef short yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001464#endif
1465
Reid Spencerb8f85052007-07-31 03:50:36 +00001466/* YYFINAL -- State number of the termination state. */
1467#define YYFINAL 43
1468/* YYLAST -- Last index in YYTABLE. */
Reid Spencer1013b4d2007-07-31 14:41:17 +00001469#define YYLAST 1553
Reid Spencerb8f85052007-07-31 03:50:36 +00001470
1471/* YYNTOKENS -- Number of terminals. */
1472#define YYNTOKENS 157
1473/* YYNNTS -- Number of nonterminals. */
1474#define YYNNTS 82
1475/* YYNRULES -- Number of rules. */
Reid Spencer1013b4d2007-07-31 14:41:17 +00001476#define YYNRULES 304
Reid Spencerb8f85052007-07-31 03:50:36 +00001477/* YYNRULES -- Number of states. */
Reid Spencer1013b4d2007-07-31 14:41:17 +00001478#define YYNSTATES 588
Reid Spencerb8f85052007-07-31 03:50:36 +00001479
1480/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1481#define YYUNDEFTOK 2
1482#define YYMAXUTOK 397
1483
David Greene718fda32007-08-01 03:59:32 +00001484#define YYTRANSLATE(YYX) \
Reid Spencerb8f85052007-07-31 03:50:36 +00001485 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1486
1487/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1488static const unsigned char yytranslate[] =
1489{
1490 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1494 147, 148, 145, 2, 144, 2, 2, 2, 2, 2,
1495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1496 152, 143, 153, 2, 2, 2, 2, 2, 2, 2,
1497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1499 2, 149, 146, 151, 2, 2, 2, 2, 2, 156,
1500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1502 150, 2, 2, 154, 2, 155, 2, 2, 2, 2,
1503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1515 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1516 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1517 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1518 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1519 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1520 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1521 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1522 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1523 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1524 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1525 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1526 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1527 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1528 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1529 135, 136, 137, 138, 139, 140, 141, 142
1530};
1531
1532#if YYDEBUG
1533/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1534 YYRHS. */
David Greene718fda32007-08-01 03:59:32 +00001535static const unsigned short yyprhs[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001536{
1537 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1538 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1539 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1540 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1541 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1542 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1543 119, 121, 123, 124, 127, 128, 130, 132, 134, 135,
1544 138, 140, 142, 144, 146, 148, 150, 152, 154, 155,
1545 157, 159, 161, 162, 164, 166, 167, 169, 171, 173,
1546 175, 176, 178, 180, 181, 183, 185, 187, 189, 191,
1547 194, 196, 198, 200, 202, 204, 206, 208, 210, 212,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001548 213, 216, 218, 220, 222, 224, 225, 228, 229, 232,
1549 233, 237, 240, 241, 243, 244, 248, 250, 253, 255,
1550 257, 259, 261, 263, 265, 268, 270, 273, 279, 285,
1551 291, 297, 301, 304, 310, 315, 318, 320, 322, 324,
1552 328, 330, 334, 336, 337, 339, 343, 348, 352, 356,
1553 361, 366, 370, 377, 383, 386, 389, 392, 395, 398,
1554 401, 404, 407, 410, 413, 416, 419, 426, 432, 441,
1555 448, 455, 463, 471, 478, 487, 496, 500, 502, 504,
1556 506, 508, 509, 512, 519, 521, 522, 524, 527, 528,
1557 532, 533, 537, 541, 545, 549, 550, 558, 559, 568,
1558 569, 578, 584, 587, 591, 593, 597, 601, 605, 609,
1559 611, 612, 618, 622, 624, 628, 630, 631, 641, 643,
1560 645, 650, 652, 654, 657, 661, 662, 664, 666, 668,
1561 670, 672, 674, 676, 678, 680, 684, 686, 692, 694,
1562 696, 698, 700, 702, 704, 707, 710, 713, 717, 720,
1563 721, 723, 726, 729, 733, 743, 753, 762, 777, 779,
1564 781, 788, 794, 797, 804, 812, 816, 822, 823, 824,
1565 828, 831, 833, 839, 845, 852, 859, 864, 871, 876,
1566 881, 888, 895, 898, 907, 909, 911, 912, 916, 923,
1567 927, 934, 937, 943, 951
Reid Spencerb8f85052007-07-31 03:50:36 +00001568};
1569
1570/* YYRHS -- A `-1'-separated list of the rules' RHS. */
David Greene718fda32007-08-01 03:59:32 +00001571static const short yyrhs[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001572{
1573 201, 0, -1, 70, -1, 71, -1, 72, -1, 73,
1574 -1, 74, -1, 75, -1, 76, -1, 77, -1, 78,
1575 -1, 82, -1, 83, -1, 84, -1, 79, -1, 80,
1576 -1, 81, -1, 113, -1, 114, -1, 115, -1, 116,
1577 -1, 117, -1, 118, -1, 119, -1, 120, -1, 121,
1578 -1, 122, -1, 123, -1, 124, -1, 87, -1, 88,
1579 -1, 89, -1, 90, -1, 91, -1, 92, -1, 93,
1580 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
1581 -1, 99, -1, 100, -1, 101, -1, 102, -1, 103,
1582 -1, 104, -1, 105, -1, 106, -1, 93, -1, 94,
1583 -1, 95, -1, 96, -1, 23, -1, 24, -1, 11,
1584 -1, 12, -1, 13, -1, 16, -1, 19, -1, 21,
1585 -1, 165, -1, -1, 165, 143, -1, -1, 17, -1,
1586 20, -1, 170, -1, -1, 168, 143, -1, 39, -1,
1587 41, -1, 40, -1, 42, -1, 44, -1, 43, -1,
1588 45, -1, 47, -1, -1, 140, -1, 141, -1, 142,
1589 -1, -1, 43, -1, 45, -1, -1, 39, -1, 40,
1590 -1, 41, -1, 44, -1, -1, 41, -1, 39, -1,
1591 -1, 58, -1, 59, -1, 60, -1, 61, -1, 62,
1592 -1, 57, 4, -1, 132, -1, 114, -1, 131, -1,
1593 115, -1, 134, -1, 135, -1, 137, -1, 138, -1,
1594 139, -1, -1, 179, 178, -1, 133, -1, 136, -1,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001595 132, -1, 131, -1, -1, 181, 180, -1, -1, 50,
1596 4, -1, -1, 144, 50, 4, -1, 31, 19, -1,
1597 -1, 184, -1, -1, 144, 187, 186, -1, 184, -1,
1598 50, 4, -1, 11, -1, 12, -1, 13, -1, 14,
1599 -1, 46, -1, 188, -1, 189, 145, -1, 223, -1,
1600 146, 4, -1, 189, 147, 193, 148, 181, -1, 10,
1601 147, 193, 148, 181, -1, 149, 4, 150, 189, 151,
1602 -1, 152, 4, 150, 189, 153, -1, 154, 194, 155,
1603 -1, 154, 155, -1, 152, 154, 194, 155, 153, -1,
1604 152, 154, 155, 153, -1, 189, 179, -1, 189, -1,
1605 10, -1, 190, -1, 192, 144, 190, -1, 192, -1,
1606 192, 144, 36, -1, 36, -1, -1, 189, -1, 194,
1607 144, 189, -1, 189, 149, 197, 151, -1, 189, 149,
1608 151, -1, 189, 156, 19, -1, 189, 152, 197, 153,
1609 -1, 189, 154, 197, 155, -1, 189, 154, 155, -1,
1610 189, 152, 154, 197, 155, 153, -1, 189, 152, 154,
1611 155, 153, -1, 189, 37, -1, 189, 38, -1, 189,
1612 223, -1, 189, 196, -1, 189, 22, -1, 163, 3,
1613 -1, 163, 5, -1, 163, 4, -1, 163, 6, -1,
1614 11, 23, -1, 11, 24, -1, 164, 9, -1, 160,
1615 147, 195, 35, 189, 148, -1, 112, 147, 195, 234,
1616 148, -1, 126, 147, 195, 144, 195, 144, 195, 148,
1617 -1, 158, 147, 195, 144, 195, 148, -1, 159, 147,
1618 195, 144, 195, 148, -1, 85, 161, 147, 195, 144,
1619 195, 148, -1, 86, 162, 147, 195, 144, 195, 148,
1620 -1, 128, 147, 195, 144, 195, 148, -1, 129, 147,
1621 195, 144, 195, 144, 195, 148, -1, 130, 147, 195,
1622 144, 195, 144, 195, 148, -1, 197, 144, 195, -1,
1623 195, -1, 29, -1, 30, -1, 34, -1, -1, 191,
1624 223, -1, 118, 147, 200, 35, 189, 148, -1, 202,
1625 -1, -1, 203, -1, 202, 203, -1, -1, 28, 204,
1626 219, -1, -1, 27, 205, 220, -1, 55, 54, 209,
1627 -1, 167, 15, 189, -1, 167, 15, 10, -1, -1,
1628 169, 173, 199, 198, 195, 206, 186, -1, -1, 169,
1629 171, 173, 199, 198, 195, 207, 186, -1, -1, 169,
1630 172, 173, 199, 198, 189, 208, 186, -1, 169, 173,
1631 32, 176, 200, -1, 48, 210, -1, 51, 143, 211,
1632 -1, 19, -1, 49, 143, 19, -1, 63, 143, 19,
1633 -1, 149, 212, 151, -1, 212, 144, 19, -1, 19,
1634 -1, -1, 213, 144, 189, 179, 166, -1, 189, 179,
1635 166, -1, 213, -1, 213, 144, 36, -1, 36, -1,
1636 -1, 177, 191, 168, 147, 214, 148, 181, 185, 182,
1637 -1, 25, -1, 154, -1, 175, 173, 215, 216, -1,
1638 26, -1, 155, -1, 226, 218, -1, 174, 173, 215,
1639 -1, -1, 56, -1, 3, -1, 4, -1, 9, -1,
1640 23, -1, 24, -1, 37, -1, 38, -1, 22, -1,
1641 152, 197, 153, -1, 196, -1, 54, 221, 19, 144,
1642 19, -1, 7, -1, 8, -1, 165, -1, 168, -1,
1643 223, -1, 222, -1, 189, 224, -1, 226, 227, -1,
1644 217, 227, -1, 228, 167, 229, -1, 228, 231, -1,
1645 -1, 18, -1, 64, 225, -1, 64, 10, -1, 65,
1646 14, 224, -1, 65, 11, 224, 144, 14, 224, 144,
1647 14, 224, -1, 66, 163, 224, 144, 14, 224, 149,
1648 230, 151, -1, 66, 163, 224, 144, 14, 224, 149,
1649 151, -1, 67, 177, 191, 224, 147, 233, 148, 181,
1650 35, 14, 224, 68, 14, 224, -1, 68, -1, 69,
1651 -1, 230, 163, 222, 144, 14, 224, -1, 163, 222,
1652 144, 14, 224, -1, 167, 236, -1, 189, 149, 224,
1653 144, 224, 151, -1, 232, 144, 149, 224, 144, 224,
1654 151, -1, 189, 224, 179, -1, 233, 144, 189, 224,
1655 179, -1, -1, -1, 234, 144, 225, -1, 53, 52,
1656 -1, 52, -1, 158, 189, 224, 144, 224, -1, 159,
1657 189, 224, 144, 224, -1, 85, 161, 189, 224, 144,
1658 224, -1, 86, 162, 189, 224, 144, 224, -1, 160,
1659 225, 35, 189, -1, 126, 225, 144, 225, 144, 225,
1660 -1, 127, 225, 144, 189, -1, 128, 225, 144, 225,
1661 -1, 129, 225, 144, 225, 144, 225, -1, 130, 225,
1662 144, 225, 144, 225, -1, 125, 232, -1, 235, 177,
1663 191, 224, 147, 233, 148, 181, -1, 238, -1, 33,
1664 -1, -1, 107, 189, 183, -1, 107, 189, 144, 11,
1665 224, 183, -1, 108, 189, 183, -1, 108, 189, 144,
1666 11, 224, 183, -1, 109, 225, -1, 237, 110, 189,
1667 224, 183, -1, 237, 111, 225, 144, 189, 224, 183,
1668 -1, 112, 189, 224, 234, -1
Reid Spencerb8f85052007-07-31 03:50:36 +00001669};
1670
1671/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
David Greene718fda32007-08-01 03:59:32 +00001672static const unsigned short yyrline[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001673{
1674 0, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116,
1675 1116, 1117, 1117, 1117, 1117, 1117, 1117, 1118, 1118, 1118,
1676 1118, 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, 1122,
1677 1122, 1123, 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1130,
1678 1130, 1131, 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135,
1679 1135, 1136, 1136, 1137, 1138, 1143, 1144, 1144, 1146, 1146,
1680 1146, 1147, 1147, 1151, 1155, 1160, 1160, 1162, 1163, 1168,
1681 1174, 1175, 1176, 1177, 1178, 1182, 1183, 1184, 1188, 1189,
1682 1190, 1191, 1195, 1196, 1197, 1201, 1202, 1203, 1204, 1205,
1683 1209, 1210, 1211, 1214, 1215, 1216, 1217, 1218, 1219, 1220,
1684 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1238,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001685 1239, 1244, 1245, 1246, 1247, 1250, 1251, 1258, 1259, 1265,
1686 1266, 1274, 1282, 1283, 1288, 1289, 1290, 1295, 1308, 1308,
1687 1308, 1308, 1311, 1315, 1319, 1326, 1331, 1339, 1369, 1400,
1688 1405, 1417, 1427, 1431, 1441, 1448, 1455, 1462, 1467, 1472,
1689 1479, 1480, 1487, 1494, 1502, 1508, 1520, 1548, 1564, 1591,
1690 1619, 1645, 1665, 1691, 1711, 1723, 1730, 1796, 1806, 1816,
1691 1822, 1832, 1838, 1848, 1853, 1858, 1866, 1878, 1900, 1908,
1692 1914, 1925, 1930, 1935, 1941, 1947, 1956, 1960, 1968, 1968,
1693 1971, 1971, 1974, 1985, 2006, 2011, 2019, 2020, 2024, 2024,
1694 2028, 2028, 2031, 2034, 2058, 2069, 2069, 2080, 2079, 2089,
1695 2088, 2099, 2118, 2121, 2127, 2137, 2141, 2146, 2148, 2153,
1696 2158, 2167, 2177, 2188, 2192, 2201, 2210, 2215, 2336, 2336,
1697 2338, 2347, 2347, 2349, 2354, 2366, 2370, 2375, 2379, 2383,
1698 2387, 2391, 2395, 2399, 2403, 2407, 2432, 2436, 2446, 2450,
1699 2454, 2459, 2466, 2466, 2472, 2481, 2485, 2494, 2503, 2512,
1700 2516, 2523, 2527, 2531, 2536, 2546, 2565, 2574, 2654, 2658,
1701 2665, 2676, 2689, 2699, 2710, 2720, 2729, 2738, 2741, 2742,
1702 2749, 2753, 2758, 2779, 2796, 2810, 2824, 2836, 2844, 2851,
1703 2857, 2863, 2869, 2884, 2969, 2974, 2978, 2985, 2992, 3000,
1704 3007, 3015, 3023, 3037, 3054
Reid Spencerb8f85052007-07-31 03:50:36 +00001705};
1706#endif
1707
David Greene718fda32007-08-01 03:59:32 +00001708#if YYDEBUG || YYERROR_VERBOSE
1709/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencerb8f85052007-07-31 03:50:36 +00001710 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1711static const char *const yytname[] =
1712{
1713 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1714 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1715 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1716 "STRINGCONSTANT", "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT",
1717 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1718 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "ALIAS",
1719 "VOLATILE", "THREAD_LOCAL", "TO", "DOTDOTDOT", "NULL_TOK", "UNDEF",
1720 "INTERNAL", "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT",
1721 "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET", "TRIPLE", "ALIGN",
1722 "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK",
1723 "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK",
1724 "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1725 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1726 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR",
1727 "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT",
1728 "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO",
1729 "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1730 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1731 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1732 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1733 "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
1734 "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "DEFAULT", "HIDDEN", "PROTECTED",
1735 "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'",
1736 "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps",
1737 "CastOps", "IPredicates", "FPredicates", "IntType", "FPType",
1738 "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1739 "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1740 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1741 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1742 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1743 "SectionString", "OptSection", "GlobalVarAttributes",
1744 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1745 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1746 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1747 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1748 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1749 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1750 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1751 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1752 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1753 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1754 "OptVolatile", "MemoryInst", 0
1755};
1756#endif
1757
1758# ifdef YYPRINT
1759/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1760 token YYLEX-NUM. */
David Greene718fda32007-08-01 03:59:32 +00001761static const unsigned short yytoknum[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001762{
1763 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1764 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1765 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1766 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1767 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1768 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1769 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1770 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1771 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1772 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1773 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1774 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1775 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1776 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1777 395, 396, 397, 61, 44, 42, 92, 40, 41, 91,
1778 120, 93, 60, 62, 123, 125, 99
1779};
1780# endif
1781
1782/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1783static const unsigned char yyr1[] =
1784{
1785 0, 157, 158, 158, 158, 158, 158, 158, 158, 158,
1786 158, 159, 159, 159, 159, 159, 159, 160, 160, 160,
1787 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1788 161, 161, 161, 161, 161, 161, 161, 161, 161, 162,
1789 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
1790 162, 162, 162, 162, 162, 163, 164, 164, 165, 165,
1791 165, 166, 166, 167, 167, 168, 168, 169, 169, 170,
1792 171, 171, 171, 171, 171, 172, 172, 172, 173, 173,
1793 173, 173, 174, 174, 174, 175, 175, 175, 175, 175,
1794 176, 176, 176, 177, 177, 177, 177, 177, 177, 177,
1795 178, 178, 178, 178, 178, 178, 178, 178, 178, 179,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001796 179, 180, 180, 180, 180, 181, 181, 182, 182, 183,
1797 183, 184, 185, 185, 186, 186, 187, 187, 188, 188,
1798 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
1799 189, 189, 189, 189, 189, 190, 191, 191, 192, 192,
1800 193, 193, 193, 193, 194, 194, 195, 195, 195, 195,
Reid Spencerb8f85052007-07-31 03:50:36 +00001801 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001802 195, 195, 195, 195, 195, 195, 196, 196, 196, 196,
1803 196, 196, 196, 196, 196, 196, 197, 197, 198, 198,
1804 199, 199, 200, 200, 201, 201, 202, 202, 204, 203,
1805 205, 203, 203, 203, 203, 206, 203, 207, 203, 208,
1806 203, 203, 203, 203, 209, 210, 210, 211, 212, 212,
1807 212, 213, 213, 214, 214, 214, 214, 215, 216, 216,
1808 217, 218, 218, 219, 220, 221, 221, 222, 222, 222,
1809 222, 222, 222, 222, 222, 222, 222, 222, 223, 223,
1810 223, 223, 224, 224, 225, 226, 226, 227, 228, 228,
1811 228, 229, 229, 229, 229, 229, 229, 229, 229, 229,
1812 230, 230, 231, 232, 232, 233, 233, 233, 234, 234,
1813 235, 235, 236, 236, 236, 236, 236, 236, 236, 236,
1814 236, 236, 236, 236, 236, 237, 237, 238, 238, 238,
1815 238, 238, 238, 238, 238
Reid Spencerb8f85052007-07-31 03:50:36 +00001816};
1817
1818/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1819static const unsigned char yyr2[] =
1820{
1821 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1822 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1823 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1824 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1825 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1826 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1827 1, 1, 0, 2, 0, 1, 1, 1, 0, 2,
1828 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1829 1, 1, 0, 1, 1, 0, 1, 1, 1, 1,
1830 0, 1, 1, 0, 1, 1, 1, 1, 1, 2,
1831 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001832 2, 1, 1, 1, 1, 0, 2, 0, 2, 0,
1833 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1834 1, 1, 1, 1, 2, 1, 2, 5, 5, 5,
1835 5, 3, 2, 5, 4, 2, 1, 1, 1, 3,
1836 1, 3, 1, 0, 1, 3, 4, 3, 3, 4,
1837 4, 3, 6, 5, 2, 2, 2, 2, 2, 2,
1838 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1839 6, 7, 7, 6, 8, 8, 3, 1, 1, 1,
1840 1, 0, 2, 6, 1, 0, 1, 2, 0, 3,
1841 0, 3, 3, 3, 3, 0, 7, 0, 8, 0,
1842 8, 5, 2, 3, 1, 3, 3, 3, 3, 1,
1843 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1844 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1845 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1846 1, 1, 1, 1, 2, 2, 2, 3, 2, 0,
1847 1, 2, 2, 3, 9, 9, 8, 14, 1, 1,
1848 6, 5, 2, 6, 7, 3, 5, 0, 0, 3,
1849 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
1850 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
1851 6, 2, 5, 7, 4
Reid Spencerb8f85052007-07-31 03:50:36 +00001852};
1853
1854/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1855 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1856 means the default is an error. */
David Greene718fda32007-08-01 03:59:32 +00001857static const unsigned short yydefact[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001858{
Reid Spencer1013b4d2007-07-31 14:41:17 +00001859 68, 58, 65, 59, 66, 60, 200, 198, 0, 0,
1860 0, 0, 0, 0, 78, 67, 0, 68, 196, 82,
1861 85, 0, 0, 212, 0, 0, 63, 0, 69, 70,
Reid Spencerb8f85052007-07-31 03:50:36 +00001862 72, 71, 73, 75, 74, 76, 77, 79, 80, 81,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001863 78, 78, 191, 1, 197, 83, 84, 78, 201, 86,
1864 87, 88, 89, 78, 259, 199, 259, 0, 0, 220,
1865 213, 214, 202, 248, 249, 204, 128, 129, 130, 131,
1866 132, 0, 0, 0, 0, 250, 251, 133, 203, 135,
1867 191, 191, 90, 190, 0, 93, 93, 260, 256, 64,
1868 231, 232, 233, 255, 215, 216, 219, 0, 153, 136,
1869 0, 0, 0, 0, 142, 154, 0, 134, 153, 0,
1870 0, 92, 91, 0, 188, 189, 0, 0, 94, 95,
1871 96, 97, 98, 0, 234, 0, 296, 258, 0, 217,
1872 152, 109, 148, 150, 0, 0, 0, 0, 0, 0,
1873 141, 0, 0, 0, 147, 0, 146, 0, 211, 128,
1874 129, 130, 0, 0, 0, 205, 99, 0, 228, 229,
1875 230, 295, 281, 0, 0, 0, 0, 93, 268, 269,
Reid Spencerb8f85052007-07-31 03:50:36 +00001876 2, 3, 4, 5, 6, 7, 8, 9, 10, 14,
1877 15, 16, 11, 12, 13, 0, 0, 0, 0, 0,
1878 0, 17, 18, 19, 20, 21, 22, 23, 24, 25,
1879 26, 27, 28, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001880 0, 0, 257, 93, 272, 0, 294, 218, 145, 0,
1881 115, 0, 0, 144, 0, 155, 115, 207, 209, 0,
1882 192, 173, 174, 169, 171, 170, 172, 175, 168, 164,
1883 165, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1884 0, 0, 0, 0, 0, 167, 166, 124, 0, 280,
1885 262, 0, 261, 0, 0, 55, 0, 0, 29, 30,
Reid Spencerb8f85052007-07-31 03:50:36 +00001886 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
1887 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001888 44, 45, 46, 47, 48, 0, 119, 119, 301, 0,
1889 0, 292, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencerb8f85052007-07-31 03:50:36 +00001890 0, 0, 0, 101, 103, 102, 100, 104, 105, 106,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001891 107, 108, 110, 151, 149, 138, 139, 140, 143, 137,
1892 124, 124, 0, 0, 0, 0, 0, 0, 0, 0,
1893 157, 187, 0, 0, 0, 161, 0, 158, 0, 0,
1894 0, 0, 206, 226, 237, 238, 239, 244, 240, 241,
1895 242, 243, 235, 0, 246, 253, 252, 254, 0, 263,
1896 0, 0, 0, 0, 0, 297, 0, 299, 278, 0,
Reid Spencerb8f85052007-07-31 03:50:36 +00001897 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001898 0, 0, 114, 113, 111, 112, 116, 208, 210, 0,
1899 0, 0, 278, 0, 0, 0, 0, 0, 156, 142,
1900 154, 0, 159, 160, 0, 0, 0, 0, 0, 126,
1901 124, 225, 109, 223, 0, 236, 0, 0, 0, 0,
1902 0, 0, 0, 0, 0, 0, 304, 0, 0, 0,
1903 288, 289, 0, 0, 0, 0, 286, 0, 119, 0,
1904 0, 0, 0, 0, 0, 0, 0, 0, 186, 163,
1905 0, 0, 0, 0, 121, 127, 125, 62, 0, 115,
1906 0, 245, 0, 0, 277, 0, 0, 119, 120, 119,
1907 0, 0, 0, 0, 0, 0, 282, 283, 277, 0,
1908 302, 0, 193, 0, 0, 177, 0, 0, 0, 0,
1909 162, 0, 0, 0, 61, 222, 224, 109, 122, 0,
1910 0, 0, 0, 0, 284, 285, 298, 300, 279, 0,
1911 0, 287, 290, 291, 0, 119, 0, 0, 0, 183,
1912 0, 0, 179, 180, 176, 62, 123, 117, 247, 0,
1913 0, 109, 0, 115, 273, 0, 115, 303, 181, 182,
1914 0, 0, 0, 221, 0, 227, 0, 266, 0, 0,
1915 275, 0, 0, 274, 293, 178, 184, 185, 118, 264,
1916 0, 265, 0, 109, 0, 0, 0, 276, 0, 0,
1917 0, 0, 271, 0, 0, 270, 0, 267
Reid Spencerb8f85052007-07-31 03:50:36 +00001918};
1919
1920/* YYDEFGOTO[NTERM-NUM]. */
David Greene718fda32007-08-01 03:59:32 +00001921static const short yydefgoto[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001922{
Reid Spencer1013b4d2007-07-31 14:41:17 +00001923 -1, 252, 253, 254, 278, 295, 152, 153, 75, 505,
Reid Spencerb8f85052007-07-31 03:50:36 +00001924 12, 76, 14, 15, 40, 41, 42, 47, 53, 113,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001925 123, 322, 218, 396, 325, 555, 375, 419, 537, 352,
1926 420, 77, 154, 132, 147, 133, 134, 106, 341, 364,
Reid Spencerb8f85052007-07-31 03:50:36 +00001927 342, 116, 84, 148, 16, 17, 18, 20, 19, 257,
Reid Spencer1013b4d2007-07-31 14:41:17 +00001928 330, 331, 62, 23, 60, 97, 423, 424, 124, 160,
1929 54, 92, 55, 48, 426, 365, 79, 367, 262, 56,
1930 88, 89, 212, 559, 127, 301, 513, 436, 213, 214,
Reid Spencerb8f85052007-07-31 03:50:36 +00001931 215, 216
1932};
1933
1934/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1935 STATE-NUM. */
Reid Spencer1013b4d2007-07-31 14:41:17 +00001936#define YYPACT_NINF -522
David Greene718fda32007-08-01 03:59:32 +00001937static const short yypact[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00001938{
Reid Spencer1013b4d2007-07-31 14:41:17 +00001939 40, -522, -522, -522, -522, -522, -522, -522, -24, -105,
1940 -4, -80, 60, -32, 461, -522, 134, 1386, -522, 153,
1941 150, 1, 15, -522, 16, 130, -522, 1208, -522, -522,
1942 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
1943 126, 126, 239, -522, -522, -522, -522, 126, -522, -522,
1944 -522, -522, -522, 126, 158, -522, -7, 168, 183, 194,
1945 -522, -522, -522, -522, -522, 45, -522, -522, -522, -522,
1946 -522, 212, 226, 6, 198, -522, -522, -522, 127, -522,
1947 204, 204, 248, -522, 218, 113, 113, -522, -522, 135,
1948 -522, -522, -522, -522, -522, -522, -522, -44, 1006, -522,
1949 101, 107, 371, 45, -522, 127, -103, -522, 1006, 218,
1950 218, -522, -522, 1043, -522, -522, 1223, 259, -522, -522,
1951 -522, -522, -522, 1274, -522, -13, 1423, -522, 269, -522,
1952 -522, 127, -522, 162, 146, 1305, 1305, 144, -101, 1305,
1953 -522, 159, 1223, 1305, 45, 161, 127, 85, -522, 41,
1954 301, 302, 250, 304, 782, -522, -522, 79, -522, -522,
1955 -522, -522, -522, 263, 1320, 193, 305, 113, -522, -522,
1956 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
1957 -522, -522, -522, -522, -522, 133, 456, 1305, 1305, 1305,
1958 1305, -522, -522, -522, -522, -522, -522, -522, -522, -522,
1959 -522, -522, -522, 1305, 1305, 1305, 1305, 1305, 1305, 1305,
1960 1305, 1305, -522, 113, -522, 165, -522, -522, 519, 1060,
1961 -522, -18, -33, -522, 166, 127, -522, -522, 127, 1043,
1962 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
1963 -522, 133, 456, 171, 174, 175, 177, 178, 1111, 1371,
1964 579, 307, 181, 182, 184, -522, -522, 186, 187, -522,
1965 45, 623, -522, 757, 757, -522, 757, 1274, -522, -522,
1966 -522, -522, -522, -522, -522, -522, -522, -522, 1305, -522,
1967 -522, -522, -522, -522, -522, -522, -522, -522, -522, -522,
1968 -522, -522, -522, -522, -522, 1305, 98, 114, -522, 623,
1969 -64, 195, 196, 201, 202, 210, 216, 623, 623, 303,
1970 1274, 1305, 1305, -522, -522, -522, -522, -522, -522, -522,
1971 -522, -522, -522, -522, -522, 104, -522, -522, -522, 104,
1972 186, 186, 313, 190, 214, 1223, 1223, 1223, 1223, 1223,
1973 -522, -522, -36, 962, -111, -522, -78, -522, 1223, 1223,
1974 1223, 3, -522, 1126, -522, -522, -522, -522, -522, -522,
1975 -522, -522, 308, 1223, -522, -522, -522, -522, 219, -522,
1976 221, 757, 623, 623, 20, -522, 21, -522, -522, 757,
1977 225, 1305, 1305, 1305, 1305, 1305, 224, 227, 1305, 757,
1978 623, 231, -522, -522, -522, -522, -522, -522, -522, 1305,
1979 1223, 1223, -522, 233, 242, 245, 249, 1223, -522, 217,
1980 782, -65, -522, -522, 256, 257, 359, 386, 402, -522,
1981 186, -522, 127, 265, 264, -522, 394, -75, 400, 401,
1982 271, 275, 276, 757, 418, 757, 282, 285, 757, 289,
1983 127, -522, 290, 296, 757, 757, 127, 294, 300, 1305,
1984 -29, 306, 309, -50, 1223, 1223, 1223, 1223, -522, -522,
1985 292, 1223, 1223, 1305, -522, -522, -522, 293, 1157, -522,
1986 311, -522, 757, 757, 1305, 757, 757, 300, -522, 300,
1987 1305, 757, 312, 1305, 1305, 1305, -522, -522, 1305, 397,
1988 -522, 623, -522, 1223, 1223, -522, 316, 315, 317, 320,
1989 -522, 318, 321, 117, -522, -522, -522, 127, -1, 430,
1990 324, 322, 623, -8, -522, -522, -522, -522, -522, 314,
1991 757, -522, -522, -522, -5, 300, 329, 330, 1223, -522,
1992 1223, 1223, -522, -522, -522, 293, -522, 431, -522, 437,
1993 2, -522, 1305, -522, -522, 332, -522, -522, -522, -522,
1994 336, 337, 338, -522, 448, -522, 757, -522, 917, 4,
1995 519, 623, 14, -522, 104, -522, -522, -522, -522, -522,
1996 343, -522, 917, -522, 474, 475, 346, 519, 757, 757,
1997 477, 426, -522, 757, 481, -522, 757, -522
Reid Spencerb8f85052007-07-31 03:50:36 +00001998};
1999
2000/* YYPGOTO[NTERM-NUM]. */
David Greene718fda32007-08-01 03:59:32 +00002001static const short yypgoto[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00002002{
Reid Spencer1013b4d2007-07-31 14:41:17 +00002003 -522, 370, 372, 373, 266, 255, -164, -522, 0, -25,
2004 420, 9, -522, -522, -522, -522, 33, -522, -522, -522,
2005 -151, -522, -404, -522, -223, -522, -291, 5, -522, -295,
2006 -522, -522, -26, 295, -115, -522, 403, 410, -58, -150,
2007 -221, 173, 222, 286, -522, -522, 501, -522, -522, -522,
2008 -522, -522, -522, -522, -522, -522, -522, -522, 433, -522,
2009 -522, -522, -522, -522, -522, -521, -140, 103, -184, -522,
2010 465, -522, -522, -522, -522, -522, 34, 122, -522, -522,
2011 -522, -522
Reid Spencerb8f85052007-07-31 03:50:36 +00002012};
2013
2014/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2015 positive, shift that token. If negative, reduce the rule which
2016 number is the opposite. If zero, do what YYDEFACT says.
2017 If YYTABLE_NINF, syntax error. */
Reid Spencer1013b4d2007-07-31 14:41:17 +00002018#define YYTABLE_NINF -196
David Greene718fda32007-08-01 03:59:32 +00002019static const short yytable[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00002020{
Reid Spencer1013b4d2007-07-31 14:41:17 +00002021 11, 78, 266, 329, 255, 298, 377, 230, 157, 13,
2022 101, 87, 158, 265, 256, 265, 267, 11, 467, 90,
2023 302, 303, 304, 305, 306, 21, 13, 309, 344, 346,
2024 417, 433, 435, 407, 417, 397, 398, 570, 24, 22,
2025 -195, 139, 412, 139, -55, -55, -55, -55, 105, 574,
2026 25, 576, 140, 418, 224, -64, 1, 2, 155, 3,
2027 4, 5, 310, 26, 231, 232, 407, 6, 7, 407,
2028 434, 434, 131, 80, 81, 27, 105, 413, 471, 407,
2029 85, 107, 131, 108, 227, 379, 86, 146, 8, 11,
2030 460, 9, 63, 64, 480, 10, 2, 146, 495, 4,
2031 128, 1, 2, 535, 3, 4, 5, 129, 407, 221,
2032 222, 28, 107, 225, 108, 408, 107, 228, 108, 492,
2033 327, 366, 411, 366, 366, 466, 366, 107, 391, 108,
2034 392, 393, 394, 326, 43, 395, 542, 560, 261, 542,
2035 543, 159, 427, 546, 57, 392, 393, 394, 91, 61,
2036 395, 1, 371, 557, 3, 571, 5, 490, 58, 366,
2037 102, 296, 297, 261, 299, 59, 258, 366, 366, 577,
2038 117, 118, 119, 120, 121, 122, 87, 300, 261, 261,
2039 261, 261, 261, 307, 308, 261, 516, 94, 517, 49,
2040 50, 51, 98, 131, 52, 389, 45, 439, 46, 441,
2041 442, 443, 95, 146, 263, 63, 64, 264, 103, 66,
2042 67, 68, 69, 96, 1, 2, 99, 3, 4, 5,
2043 268, 269, 270, 271, 272, 273, 274, 275, 276, 277,
2044 100, 366, 366, 366, 547, 392, 393, 394, 83, 366,
2045 395, 146, 374, 107, 70, 108, 508, 114, 115, 366,
2046 366, 135, 372, 233, 234, 235, 236, 136, 376, 107,
2047 255, 108, 107, 156, 108, 534, 37, 38, 39, 373,
2048 256, 82, 107, 83, 108, 311, 312, 402, 403, 404,
2049 405, 406, 142, 143, 146, 390, 261, 111, 217, 112,
2050 414, 415, 416, 366, 220, 366, 518, 223, 366, 521,
2051 522, 523, 109, 110, 366, 366, 219, 226, 229, 1,
2052 -56, -57, 3, 237, 5, 259, 265, 410, 335, 328,
2053 562, 336, 337, 564, 338, 339, 347, 422, 348, 349,
2054 351, 350, 366, 366, 353, 366, 366, 400, 388, 380,
2055 381, 366, 451, 452, 71, 382, 383, 72, 399, 458,
2056 73, 366, 74, 104, 384, 261, 440, 261, 261, 261,
2057 385, 401, 446, 428, 425, 429, 368, 369, 444, 370,
2058 459, 445, 366, 450, 438, 449, 558, 454, 63, 64,
2059 366, 103, 66, 67, 68, 69, 455, 1, 2, 456,
2060 3, 4, 5, 457, 463, 572, 496, 497, 498, 499,
2061 461, 462, 378, 501, 502, 464, 465, 313, 314, 468,
2062 386, 387, 469, 470, 472, 473, 366, 70, 474, 475,
2063 476, 366, 478, 491, 315, 316, 480, 317, 318, 481,
2064 319, 320, 321, 483, 484, 526, 527, 503, 366, 366,
2065 485, 488, 507, 366, 489, 500, 366, 434, 512, 538,
2066 493, 556, 568, 494, 261, 509, 520, 261, 261, 261,
2067 528, 530, 512, 529, 531, 544, 532, 504, 539, 533,
2068 550, 540, 551, 552, 430, 431, 432, 548, 549, 279,
2069 280, 554, 437, 563, 565, 566, 567, 575, 578, 579,
2070 580, 583, 447, 448, 584, 586, 209, 334, 210, 211,
2071 29, 30, 31, 32, 33, 34, 35, 333, 36, 126,
2072 553, 141, 138, 536, 324, 332, 561, 71, 44, 125,
2073 72, 93, 524, 73, 453, 74, 137, 0, 0, 0,
2074 0, 0, 0, 0, 0, 504, 477, 0, 479, 0,
2075 0, 482, 0, 0, 0, 0, 0, 486, 487, 281,
2076 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
2077 292, 293, 294, 0, 0, 0, 0, 0, 0, 0,
2078 0, 0, 0, 0, 0, 510, 511, 0, 514, 515,
2079 0, 0, 0, 0, 519, 0, 63, 64, 0, 103,
2080 149, 150, 151, 69, 525, 1, 2, 0, 3, 4,
2081 5, 37, 38, 39, 0, 0, 0, 0, 0, 0,
2082 0, 0, 0, 0, 0, 541, 0, 0, 0, 0,
2083 0, 0, 0, 545, 0, 70, 354, 355, 0, 0,
2084 63, 64, 356, 313, 314, 0, 0, 0, 0, 1,
2085 2, 0, 3, 4, 5, 357, 358, 359, 0, 0,
2086 315, 316, 0, 317, 318, 0, 319, 320, 321, 569,
2087 360, 361, 0, 0, 573, 0, 0, 0, 0, 0,
2088 0, 0, 0, 0, 0, 0, 0, 362, 0, 0,
2089 0, 581, 582, 0, 0, 0, 585, 0, 0, 587,
2090 0, 0, 0, 170, 171, 172, 173, 174, 175, 176,
2091 177, 178, 179, 180, 181, 182, 183, 184, 241, 242,
2092 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2093 0, 0, 0, 0, 0, 71, 0, 0, 72, 0,
2094 0, 73, 0, 74, 345, 243, 191, 192, 193, 194,
2095 195, 196, 197, 198, 199, 200, 201, 202, 0, 244,
2096 0, 245, 246, 247, 0, 0, 0, 0, 0, 0,
2097 354, 355, 0, 0, 63, 64, 356, 0, 107, 0,
2098 108, 0, 0, 1, 2, 363, 3, 4, 5, 357,
2099 358, 359, 0, 0, 0, 0, 0, 0, 0, 63,
2100 64, 0, 0, 0, 360, 361, 0, 0, 1, 2,
2101 0, 3, 4, 5, 238, 0, 0, 0, 0, 0,
2102 0, 362, 0, 0, 0, 0, 0, 0, 0, 239,
2103 240, 0, 0, 0, 0, 0, 0, 170, 171, 172,
2104 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2105 183, 184, 241, 242, 0, 0, 0, 0, 0, 0,
2106 0, 0, 170, 171, 172, 173, 174, 175, 176, 177,
2107 178, 179, 180, 181, 182, 183, 184, 241, 242, 243,
2108 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2109 201, 202, 0, 244, 0, 245, 246, 247, 0, 0,
2110 0, 0, 0, 0, 243, 191, 192, 193, 194, 195,
2111 196, 197, 198, 199, 200, 201, 202, 0, 244, 363,
2112 245, 246, 247, 0, 0, 0, 0, 0, 0, 0,
2113 354, 355, 0, 0, 0, 0, 356, 107, 0, 108,
2114 0, 248, 0, 0, 249, 0, 250, 0, 251, 357,
2115 358, 359, 0, 0, 0, 0, 0, 0, 0, 0,
2116 0, 0, 0, 0, 360, 361, 0, 0, 0, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
2118 64, 362, 103, 149, 150, 151, 69, 0, 1, 2,
2119 0, 3, 4, 5, 0, 0, 0, 170, 171, 172,
2120 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
2121 183, 184, 241, 242, 0, 0, 0, 0, 70, 0,
2122 0, 0, 0, 63, 64, 0, 103, 66, 67, 68,
2123 69, 0, 1, 2, 0, 3, 4, 5, 0, 243,
2124 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
2125 201, 202, 130, 244, 0, 245, 246, 247, 0, 0,
2126 63, 64, 70, 144, 66, 67, 68, 69, 0, 1,
2127 2, 0, 3, 4, 5, 0, 0, 63, 64, 363,
2128 103, 66, 67, 68, 69, 0, 1, 2, 0, 3,
2129 4, 5, 0, 0, 0, 0, 0, 0, 0, 70,
2130 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
2131 0, 0, 0, 0, 0, 0, 70, 0, 71, 0,
2132 0, 72, 0, 0, 73, 0, 74, 409, 63, 64,
Reid Spencerb8f85052007-07-31 03:50:36 +00002133 0, 103, 149, 150, 151, 69, 0, 1, 2, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002134 3, 4, 5, 63, 64, 0, 103, 66, 67, 68,
Reid Spenceree0142e2007-07-31 06:37:43 +00002135 69, 0, 1, 2, 0, 3, 4, 5, 0, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002136 0, 0, 71, 0, 0, 72, 0, 70, 73, 0,
2137 74, 145, 421, 0, 63, 64, 0, 103, 66, 67,
2138 68, 69, 70, 1, 2, 0, 3, 4, 5, 0,
2139 0, 0, 0, 0, 0, 0, 0, 0, 0, 71,
2140 0, 0, 72, 506, 0, 73, 0, 74, 0, 0,
2141 0, 0, 0, 70, 0, 0, 71, 0, 0, 72,
2142 0, 0, 73, 0, 74, 63, 64, 0, 65, 66,
2143 67, 68, 69, 0, 1, 2, 0, 3, 4, 5,
2144 63, 64, 0, 103, 149, 150, 151, 69, 0, 1,
Reid Spenceree0142e2007-07-31 06:37:43 +00002145 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002146 0, 0, 0, 0, 70, 0, 0, 71, 0, 0,
2147 72, 0, 340, 73, 0, 74, 0, 0, 0, 70,
Reid Spenceree0142e2007-07-31 06:37:43 +00002148 0, 0, 71, 0, 0, 72, 0, 0, 73, 0,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002149 74, 63, 64, 0, 144, 66, 67, 68, 69, 0,
2150 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2151 0, 0, 0, 71, 0, 0, 72, 0, 0, 73,
2152 0, 74, 63, 64, 0, 103, 66, 67, 68, 69,
2153 70, 1, 2, 0, 3, 4, 5, 63, 64, 0,
2154 260, 66, 67, 68, 69, 0, 1, 2, 0, 3,
2155 4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
2156 0, 70, 0, 0, 71, 0, 0, 72, 0, 0,
2157 73, 0, 74, 0, 0, 0, 70, 0, 0, 71,
2158 0, 0, 72, 0, 0, 73, 0, 74, 63, 64,
2159 0, 103, 149, 150, 151, 69, -194, 1, 2, 0,
2160 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2161 0, -64, 1, 2, 0, 3, 4, 5, 0, 0,
2162 0, 0, 0, 6, 7, 0, 0, 70, 0, 0,
2163 71, 0, 0, 72, 0, 0, 73, 0, 74, 0,
2164 0, 0, 0, 0, 8, 0, 0, 9, 0, 0,
2165 0, 10, 0, 0, 0, 0, 0, 0, 0, 0,
2166 0, 71, 0, 0, 72, 0, 161, 73, 0, 74,
2167 0, 0, 0, 0, 0, 0, 71, 0, 0, 72,
2168 0, 0, 73, 0, 74, 162, 163, 0, 0, 0,
2169 0, 0, 0, 0, 0, 0, 0, 164, 165, 166,
2170 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2171 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
2172 0, 0, 0, 0, 0, 0, 0, 71, 0, 0,
2173 72, 0, 0, 73, 0, 343, 0, 0, 0, 0,
2174 187, 188, 189, 0, 0, 190, 191, 192, 193, 194,
2175 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
2176 205, 206, 207, 208
Reid Spencerb8f85052007-07-31 03:50:36 +00002177};
2178
David Greene718fda32007-08-01 03:59:32 +00002179static const short yycheck[] =
Reid Spencerb8f85052007-07-31 03:50:36 +00002180{
Reid Spencer1013b4d2007-07-31 14:41:17 +00002181 0, 27, 166, 226, 154, 189, 297, 147, 123, 0,
2182 4, 18, 25, 11, 154, 11, 167, 17, 422, 26,
2183 204, 205, 206, 207, 208, 49, 17, 211, 249, 250,
2184 31, 11, 11, 144, 31, 330, 331, 558, 143, 63,
2185 0, 144, 153, 144, 3, 4, 5, 6, 74, 35,
2186 54, 572, 155, 50, 155, 15, 16, 17, 116, 19,
2187 20, 21, 213, 143, 23, 24, 144, 27, 28, 144,
2188 50, 50, 98, 40, 41, 15, 102, 155, 153, 144,
2189 47, 145, 108, 147, 142, 149, 53, 113, 48, 89,
2190 155, 51, 7, 8, 144, 55, 17, 123, 148, 20,
2191 144, 16, 17, 507, 19, 20, 21, 151, 144, 135,
2192 136, 143, 145, 139, 147, 151, 145, 143, 147, 148,
2193 153, 261, 343, 263, 264, 420, 266, 145, 312, 147,
2194 131, 132, 133, 151, 0, 136, 144, 541, 164, 144,
2195 148, 154, 363, 148, 143, 131, 132, 133, 155, 19,
2196 136, 16, 267, 151, 19, 151, 21, 448, 143, 299,
2197 154, 187, 188, 189, 190, 149, 157, 307, 308, 573,
2198 57, 58, 59, 60, 61, 62, 18, 203, 204, 205,
2199 206, 207, 208, 209, 210, 211, 477, 19, 479, 39,
2200 40, 41, 147, 219, 44, 310, 43, 381, 45, 383,
2201 384, 385, 19, 229, 11, 7, 8, 14, 10, 11,
2202 12, 13, 14, 19, 16, 17, 4, 19, 20, 21,
2203 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
2204 4, 371, 372, 373, 525, 131, 132, 133, 34, 379,
2205 136, 267, 144, 145, 46, 147, 469, 29, 30, 389,
2206 390, 150, 278, 3, 4, 5, 6, 150, 144, 145,
2207 410, 147, 145, 4, 147, 148, 140, 141, 142, 295,
2208 410, 32, 145, 34, 147, 110, 111, 335, 336, 337,
2209 338, 339, 109, 110, 310, 311, 312, 39, 19, 41,
2210 348, 349, 350, 433, 148, 435, 480, 153, 438, 483,
2211 484, 485, 80, 81, 444, 445, 144, 148, 147, 16,
2212 9, 9, 19, 9, 21, 52, 11, 343, 147, 153,
2213 543, 147, 147, 546, 147, 147, 19, 353, 147, 147,
2214 144, 147, 472, 473, 147, 475, 476, 147, 35, 144,
2215 144, 481, 400, 401, 146, 144, 144, 149, 35, 407,
2216 152, 491, 154, 155, 144, 381, 382, 383, 384, 385,
2217 144, 147, 388, 144, 56, 144, 263, 264, 144, 266,
2218 153, 144, 512, 399, 149, 144, 540, 144, 7, 8,
2219 520, 10, 11, 12, 13, 14, 144, 16, 17, 144,
2220 19, 20, 21, 144, 35, 559, 454, 455, 456, 457,
2221 144, 144, 299, 461, 462, 19, 4, 114, 115, 144,
2222 307, 308, 148, 19, 14, 14, 556, 46, 147, 144,
2223 144, 561, 4, 449, 131, 132, 144, 134, 135, 144,
2224 137, 138, 139, 144, 144, 493, 494, 463, 578, 579,
2225 144, 147, 468, 583, 144, 153, 586, 50, 474, 19,
2226 144, 14, 4, 144, 480, 144, 144, 483, 484, 485,
2227 144, 144, 488, 148, 144, 151, 148, 467, 144, 148,
2228 528, 149, 530, 531, 371, 372, 373, 148, 148, 23,
2229 24, 50, 379, 151, 148, 148, 148, 144, 14, 14,
2230 144, 14, 389, 390, 68, 14, 126, 242, 126, 126,
2231 39, 40, 41, 42, 43, 44, 45, 241, 47, 89,
2232 535, 108, 102, 508, 219, 229, 542, 146, 17, 86,
2233 149, 56, 488, 152, 402, 154, 155, -1, -1, -1,
2234 -1, -1, -1, -1, -1, 535, 433, -1, 435, -1,
2235 -1, 438, -1, -1, -1, -1, -1, 444, 445, 93,
2236 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2237 104, 105, 106, -1, -1, -1, -1, -1, -1, -1,
2238 -1, -1, -1, -1, -1, 472, 473, -1, 475, 476,
2239 -1, -1, -1, -1, 481, -1, 7, 8, -1, 10,
2240 11, 12, 13, 14, 491, 16, 17, -1, 19, 20,
2241 21, 140, 141, 142, -1, -1, -1, -1, -1, -1,
2242 -1, -1, -1, -1, -1, 512, -1, -1, -1, -1,
2243 -1, -1, -1, 520, -1, 46, 3, 4, -1, -1,
2244 7, 8, 9, 114, 115, -1, -1, -1, -1, 16,
2245 17, -1, 19, 20, 21, 22, 23, 24, -1, -1,
2246 131, 132, -1, 134, 135, -1, 137, 138, 139, 556,
2247 37, 38, -1, -1, 561, -1, -1, -1, -1, -1,
2248 -1, -1, -1, -1, -1, -1, -1, 54, -1, -1,
2249 -1, 578, 579, -1, -1, -1, 583, -1, -1, 586,
2250 -1, -1, -1, 70, 71, 72, 73, 74, 75, 76,
2251 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2252 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spenceree0142e2007-07-31 06:37:43 +00002253 -1, -1, -1, -1, -1, 146, -1, -1, 149, -1,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002254 -1, 152, -1, 154, 155, 112, 113, 114, 115, 116,
2255 117, 118, 119, 120, 121, 122, 123, 124, -1, 126,
2256 -1, 128, 129, 130, -1, -1, -1, -1, -1, -1,
2257 3, 4, -1, -1, 7, 8, 9, -1, 145, -1,
2258 147, -1, -1, 16, 17, 152, 19, 20, 21, 22,
2259 23, 24, -1, -1, -1, -1, -1, -1, -1, 7,
2260 8, -1, -1, -1, 37, 38, -1, -1, 16, 17,
2261 -1, 19, 20, 21, 22, -1, -1, -1, -1, -1,
2262 -1, 54, -1, -1, -1, -1, -1, -1, -1, 37,
2263 38, -1, -1, -1, -1, -1, -1, 70, 71, 72,
2264 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2265 83, 84, 85, 86, -1, -1, -1, -1, -1, -1,
2266 -1, -1, 70, 71, 72, 73, 74, 75, 76, 77,
2267 78, 79, 80, 81, 82, 83, 84, 85, 86, 112,
2268 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2269 123, 124, -1, 126, -1, 128, 129, 130, -1, -1,
2270 -1, -1, -1, -1, 112, 113, 114, 115, 116, 117,
2271 118, 119, 120, 121, 122, 123, 124, -1, 126, 152,
2272 128, 129, 130, -1, -1, -1, -1, -1, -1, -1,
2273 3, 4, -1, -1, -1, -1, 9, 145, -1, 147,
2274 -1, 149, -1, -1, 152, -1, 154, -1, 156, 22,
2275 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2276 -1, -1, -1, -1, 37, 38, -1, -1, -1, -1,
2277 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
2278 8, 54, 10, 11, 12, 13, 14, -1, 16, 17,
2279 -1, 19, 20, 21, -1, -1, -1, 70, 71, 72,
2280 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2281 83, 84, 85, 86, -1, -1, -1, -1, 46, -1,
2282 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2283 14, -1, 16, 17, -1, 19, 20, 21, -1, 112,
2284 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
2285 123, 124, 36, 126, -1, 128, 129, 130, -1, -1,
Reid Spenceree0142e2007-07-31 06:37:43 +00002286 7, 8, 46, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002287 17, -1, 19, 20, 21, -1, -1, 7, 8, 152,
2288 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2289 20, 21, -1, -1, -1, -1, -1, -1, -1, 46,
2290 -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
2291 -1, -1, -1, -1, -1, -1, 46, -1, 146, -1,
2292 -1, 149, -1, -1, 152, -1, 154, 155, 7, 8,
2293 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2294 19, 20, 21, 7, 8, -1, 10, 11, 12, 13,
2295 14, -1, 16, 17, -1, 19, 20, 21, -1, -1,
2296 -1, -1, 146, -1, -1, 149, -1, 46, 152, -1,
2297 154, 118, 36, -1, 7, 8, -1, 10, 11, 12,
2298 13, 14, 46, 16, 17, -1, 19, 20, 21, -1,
2299 -1, -1, -1, -1, -1, -1, -1, -1, -1, 146,
2300 -1, -1, 149, 36, -1, 152, -1, 154, -1, -1,
2301 -1, -1, -1, 46, -1, -1, 146, -1, -1, 149,
2302 -1, -1, 152, -1, 154, 7, 8, -1, 10, 11,
2303 12, 13, 14, -1, 16, 17, -1, 19, 20, 21,
2304 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spenceree0142e2007-07-31 06:37:43 +00002305 17, -1, 19, 20, 21, -1, -1, -1, -1, -1,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002306 -1, -1, -1, -1, 46, -1, -1, 146, -1, -1,
2307 149, -1, 151, 152, -1, 154, -1, -1, -1, 46,
Reid Spenceree0142e2007-07-31 06:37:43 +00002308 -1, -1, 146, -1, -1, 149, -1, -1, 152, -1,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002309 154, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2310 16, 17, -1, 19, 20, 21, -1, -1, -1, -1,
2311 -1, -1, -1, 146, -1, -1, 149, -1, -1, 152,
2312 -1, 154, 7, 8, -1, 10, 11, 12, 13, 14,
2313 46, 16, 17, -1, 19, 20, 21, 7, 8, -1,
2314 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2315 20, 21, -1, -1, -1, -1, -1, -1, -1, -1,
2316 -1, 46, -1, -1, 146, -1, -1, 149, -1, -1,
2317 152, -1, 154, -1, -1, -1, 46, -1, -1, 146,
2318 -1, -1, 149, -1, -1, 152, -1, 154, 7, 8,
2319 -1, 10, 11, 12, 13, 14, 0, 16, 17, -1,
2320 19, 20, 21, -1, -1, -1, -1, -1, -1, -1,
2321 -1, 15, 16, 17, -1, 19, 20, 21, -1, -1,
2322 -1, -1, -1, 27, 28, -1, -1, 46, -1, -1,
2323 146, -1, -1, 149, -1, -1, 152, -1, 154, -1,
2324 -1, -1, -1, -1, 48, -1, -1, 51, -1, -1,
2325 -1, 55, -1, -1, -1, -1, -1, -1, -1, -1,
2326 -1, 146, -1, -1, 149, -1, 33, 152, -1, 154,
2327 -1, -1, -1, -1, -1, -1, 146, -1, -1, 149,
2328 -1, -1, 152, -1, 154, 52, 53, -1, -1, -1,
2329 -1, -1, -1, -1, -1, -1, -1, 64, 65, 66,
2330 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2331 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2332 -1, -1, -1, -1, -1, -1, -1, 146, -1, -1,
2333 149, -1, -1, 152, -1, 154, -1, -1, -1, -1,
2334 107, 108, 109, -1, -1, 112, 113, 114, 115, 116,
2335 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2336 127, 128, 129, 130
Reid Spencerb8f85052007-07-31 03:50:36 +00002337};
2338
2339/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2340 symbol of state STATE-NUM. */
2341static const unsigned char yystos[] =
2342{
2343 0, 16, 17, 19, 20, 21, 27, 28, 48, 51,
2344 55, 165, 167, 168, 169, 170, 201, 202, 203, 205,
2345 204, 49, 63, 210, 143, 54, 143, 15, 143, 39,
2346 40, 41, 42, 43, 44, 45, 47, 140, 141, 142,
2347 171, 172, 173, 0, 203, 43, 45, 174, 220, 39,
2348 40, 41, 44, 175, 217, 219, 226, 143, 143, 149,
2349 211, 19, 209, 7, 8, 10, 11, 12, 13, 14,
2350 46, 146, 149, 152, 154, 165, 168, 188, 189, 223,
2351 173, 173, 32, 34, 199, 173, 173, 18, 227, 228,
2352 26, 155, 218, 227, 19, 19, 19, 212, 147, 4,
2353 4, 4, 154, 10, 155, 189, 194, 145, 147, 199,
2354 199, 39, 41, 176, 29, 30, 198, 57, 58, 59,
2355 60, 61, 62, 177, 215, 215, 167, 231, 144, 151,
2356 36, 189, 190, 192, 193, 150, 150, 155, 194, 144,
2357 155, 193, 198, 198, 10, 118, 189, 191, 200, 11,
2358 12, 13, 163, 164, 189, 195, 4, 191, 25, 154,
2359 216, 33, 52, 53, 64, 65, 66, 67, 68, 69,
2360 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2361 80, 81, 82, 83, 84, 85, 86, 107, 108, 109,
2362 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2363 122, 123, 124, 125, 126, 127, 128, 129, 130, 158,
2364 159, 160, 229, 235, 236, 237, 238, 19, 179, 144,
2365 148, 189, 189, 153, 155, 189, 148, 195, 189, 147,
2366 223, 23, 24, 3, 4, 5, 6, 9, 22, 37,
2367 38, 85, 86, 112, 126, 128, 129, 130, 149, 152,
2368 154, 156, 158, 159, 160, 196, 223, 206, 168, 52,
2369 10, 189, 225, 11, 14, 11, 163, 177, 87, 88,
2370 89, 90, 91, 92, 93, 94, 95, 96, 161, 23,
2371 24, 93, 94, 95, 96, 97, 98, 99, 100, 101,
2372 102, 103, 104, 105, 106, 162, 189, 189, 225, 189,
2373 189, 232, 225, 225, 225, 225, 225, 189, 189, 225,
2374 177, 110, 111, 114, 115, 131, 132, 134, 135, 137,
2375 138, 139, 178, 36, 190, 181, 151, 153, 153, 181,
2376 207, 208, 200, 161, 162, 147, 147, 147, 147, 147,
2377 151, 195, 197, 154, 197, 155, 197, 19, 147, 147,
2378 147, 144, 186, 147, 3, 4, 9, 22, 23, 24,
2379 37, 38, 54, 152, 196, 222, 223, 224, 224, 224,
2380 224, 191, 189, 189, 144, 183, 144, 183, 224, 149,
2381 144, 144, 144, 144, 144, 144, 224, 224, 35, 191,
Reid Spencer1013b4d2007-07-31 14:41:17 +00002382 189, 225, 131, 132, 133, 136, 180, 186, 186, 35,
2383 147, 147, 195, 195, 195, 195, 195, 144, 151, 155,
2384 189, 197, 153, 155, 195, 195, 195, 31, 50, 184,
2385 187, 36, 189, 213, 214, 56, 221, 197, 144, 144,
2386 224, 224, 224, 11, 50, 11, 234, 224, 149, 225,
2387 189, 225, 225, 225, 144, 144, 189, 224, 224, 144,
2388 189, 195, 195, 234, 144, 144, 144, 144, 195, 153,
2389 155, 144, 144, 35, 19, 4, 186, 179, 144, 148,
2390 19, 153, 14, 14, 147, 144, 144, 224, 4, 224,
2391 144, 144, 224, 144, 144, 144, 224, 224, 147, 144,
2392 183, 189, 148, 144, 144, 148, 195, 195, 195, 195,
2393 153, 195, 195, 189, 165, 166, 36, 189, 181, 144,
2394 224, 224, 189, 233, 224, 224, 183, 183, 225, 224,
2395 144, 225, 225, 225, 233, 224, 195, 195, 144, 148,
2396 144, 144, 148, 148, 148, 179, 184, 185, 19, 144,
2397 149, 224, 144, 148, 151, 224, 148, 183, 148, 148,
2398 195, 195, 195, 166, 50, 182, 14, 151, 163, 230,
2399 179, 189, 181, 151, 181, 148, 148, 148, 4, 224,
2400 222, 151, 163, 224, 35, 144, 222, 179, 14, 14,
2401 144, 224, 224, 14, 68, 224, 14, 224
Reid Spencerb8f85052007-07-31 03:50:36 +00002402};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403
David Greene718fda32007-08-01 03:59:32 +00002404#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2405# define YYSIZE_T __SIZE_TYPE__
2406#endif
2407#if ! defined (YYSIZE_T) && defined (size_t)
2408# define YYSIZE_T size_t
2409#endif
2410#if ! defined (YYSIZE_T)
2411# if defined (__STDC__) || defined (__cplusplus)
2412# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2413# define YYSIZE_T size_t
2414# endif
2415#endif
2416#if ! defined (YYSIZE_T)
2417# define YYSIZE_T unsigned int
2418#endif
2419
Reid Spencer68a24bd2005-08-27 18:50:39 +00002420#define yyerrok (yyerrstatus = 0)
2421#define yyclearin (yychar = YYEMPTY)
Reid Spencerb8f85052007-07-31 03:50:36 +00002422#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002423#define YYEOF 0
Reid Spencerb8f85052007-07-31 03:50:36 +00002424
Reid Spencer68a24bd2005-08-27 18:50:39 +00002425#define YYACCEPT goto yyacceptlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002426#define YYABORT goto yyabortlab
2427#define YYERROR goto yyerrorlab
2428
2429
2430/* Like YYERROR except do call yyerror. This remains here temporarily
2431 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002432 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002433
Reid Spencer68a24bd2005-08-27 18:50:39 +00002434#define YYFAIL goto yyerrlab
Reid Spencerb8f85052007-07-31 03:50:36 +00002435
Reid Spencer68a24bd2005-08-27 18:50:39 +00002436#define YYRECOVERING() (!!yyerrstatus)
Reid Spencerb8f85052007-07-31 03:50:36 +00002437
2438#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002439do \
2440 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencerb8f85052007-07-31 03:50:36 +00002441 { \
2442 yychar = (Token); \
2443 yylval = (Value); \
2444 yytoken = YYTRANSLATE (yychar); \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002445 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002446 goto yybackup; \
2447 } \
2448 else \
David Greene718fda32007-08-01 03:59:32 +00002449 { \
2450 yyerror ("syntax error: cannot back up");\
Reid Spencerb8f85052007-07-31 03:50:36 +00002451 YYERROR; \
2452 } \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002453while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002454
Reid Spencer68a24bd2005-08-27 18:50:39 +00002455#define YYTERROR 1
2456#define YYERRCODE 256
2457
David Greene718fda32007-08-01 03:59:32 +00002458/* YYLLOC_DEFAULT -- Compute the default location (before the actions
2459 are run). */
Reid Spencerb8f85052007-07-31 03:50:36 +00002460
Reid Spencerb8f85052007-07-31 03:50:36 +00002461#ifndef YYLLOC_DEFAULT
David Greene718fda32007-08-01 03:59:32 +00002462# define YYLLOC_DEFAULT(Current, Rhs, N) \
2463 ((Current).first_line = (Rhs)[1].first_line, \
2464 (Current).first_column = (Rhs)[1].first_column, \
2465 (Current).last_line = (Rhs)[N].last_line, \
2466 (Current).last_column = (Rhs)[N].last_column)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002467#endif
2468
Reid Spencerb8f85052007-07-31 03:50:36 +00002469/* YYLEX -- calling `yylex' with the right arguments. */
2470
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002471#ifdef YYLEX_PARAM
Reid Spencerb8f85052007-07-31 03:50:36 +00002472# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002473#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002474# define YYLEX yylex ()
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002475#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002476
2477/* Enable debugging if requested. */
2478#if YYDEBUG
2479
2480# ifndef YYFPRINTF
2481# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2482# define YYFPRINTF fprintf
2483# endif
2484
2485# define YYDPRINTF(Args) \
2486do { \
2487 if (yydebug) \
2488 YYFPRINTF Args; \
2489} while (0)
2490
David Greene718fda32007-08-01 03:59:32 +00002491# define YYDSYMPRINT(Args) \
2492do { \
2493 if (yydebug) \
2494 yysymprint Args; \
2495} while (0)
2496
2497# define YYDSYMPRINTF(Title, Token, Value, Location) \
Reid Spencerb8f85052007-07-31 03:50:36 +00002498do { \
2499 if (yydebug) \
2500 { \
2501 YYFPRINTF (stderr, "%s ", Title); \
David Greene718fda32007-08-01 03:59:32 +00002502 yysymprint (stderr, \
2503 Token, Value); \
Reid Spencerb8f85052007-07-31 03:50:36 +00002504 YYFPRINTF (stderr, "\n"); \
2505 } \
2506} while (0)
2507
2508/*------------------------------------------------------------------.
2509| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2510| TOP (included). |
2511`------------------------------------------------------------------*/
2512
2513#if defined (__STDC__) || defined (__cplusplus)
2514static void
David Greene718fda32007-08-01 03:59:32 +00002515yy_stack_print (short *bottom, short *top)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002516#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002517static void
2518yy_stack_print (bottom, top)
David Greene718fda32007-08-01 03:59:32 +00002519 short *bottom;
2520 short *top;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002521#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002522{
2523 YYFPRINTF (stderr, "Stack now");
2524 for (/* Nothing. */; bottom <= top; ++bottom)
2525 YYFPRINTF (stderr, " %d", *bottom);
2526 YYFPRINTF (stderr, "\n");
2527}
2528
2529# define YY_STACK_PRINT(Bottom, Top) \
2530do { \
2531 if (yydebug) \
2532 yy_stack_print ((Bottom), (Top)); \
2533} while (0)
2534
2535
2536/*------------------------------------------------.
2537| Report that the YYRULE is going to be reduced. |
2538`------------------------------------------------*/
2539
2540#if defined (__STDC__) || defined (__cplusplus)
2541static void
2542yy_reduce_print (int yyrule)
2543#else
2544static void
2545yy_reduce_print (yyrule)
2546 int yyrule;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002547#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002548{
2549 int yyi;
David Greene718fda32007-08-01 03:59:32 +00002550 unsigned int yylno = yyrline[yyrule];
2551 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
Reid Spencerb8f85052007-07-31 03:50:36 +00002552 yyrule - 1, yylno);
2553 /* Print the symbols being reduced, and their result. */
2554 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
David Greene718fda32007-08-01 03:59:32 +00002555 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
2556 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
Reid Spencerb8f85052007-07-31 03:50:36 +00002557}
Reid Spencered951ea2007-05-19 07:22:10 +00002558
Reid Spencerb8f85052007-07-31 03:50:36 +00002559# define YY_REDUCE_PRINT(Rule) \
2560do { \
2561 if (yydebug) \
2562 yy_reduce_print (Rule); \
2563} while (0)
Reid Spencered951ea2007-05-19 07:22:10 +00002564
Reid Spencerb8f85052007-07-31 03:50:36 +00002565/* Nonzero means print parse trace. It is left uninitialized so that
2566 multiple parsers can coexist. */
2567int yydebug;
2568#else /* !YYDEBUG */
2569# define YYDPRINTF(Args)
David Greene718fda32007-08-01 03:59:32 +00002570# define YYDSYMPRINT(Args)
2571# define YYDSYMPRINTF(Title, Token, Value, Location)
Reid Spencerb8f85052007-07-31 03:50:36 +00002572# define YY_STACK_PRINT(Bottom, Top)
2573# define YY_REDUCE_PRINT(Rule)
2574#endif /* !YYDEBUG */
Reid Spencered951ea2007-05-19 07:22:10 +00002575
Reid Spencered951ea2007-05-19 07:22:10 +00002576
Reid Spencerb8f85052007-07-31 03:50:36 +00002577/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002578#ifndef YYINITDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002579# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002580#endif
2581
Reid Spencerb8f85052007-07-31 03:50:36 +00002582/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2583 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002584
Reid Spencerb8f85052007-07-31 03:50:36 +00002585 Do not make this value too large; the results are undefined if
David Greene718fda32007-08-01 03:59:32 +00002586 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
Reid Spencerb8f85052007-07-31 03:50:36 +00002587 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002588
David Greene718fda32007-08-01 03:59:32 +00002589#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
2590# undef YYMAXDEPTH
2591#endif
2592
Reid Spencer68a24bd2005-08-27 18:50:39 +00002593#ifndef YYMAXDEPTH
Reid Spencerb8f85052007-07-31 03:50:36 +00002594# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002595#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002596
Reid Spencer68a24bd2005-08-27 18:50:39 +00002597
2598
Reid Spencerb8f85052007-07-31 03:50:36 +00002599#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002600
Reid Spencerb8f85052007-07-31 03:50:36 +00002601# ifndef yystrlen
2602# if defined (__GLIBC__) && defined (_STRING_H)
2603# define yystrlen strlen
2604# else
2605/* Return the length of YYSTR. */
2606static YYSIZE_T
2607# if defined (__STDC__) || defined (__cplusplus)
2608yystrlen (const char *yystr)
2609# else
2610yystrlen (yystr)
2611 const char *yystr;
2612# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002613{
David Greene718fda32007-08-01 03:59:32 +00002614 register const char *yys = yystr;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002615
Reid Spencerb8f85052007-07-31 03:50:36 +00002616 while (*yys++ != '\0')
2617 continue;
2618
2619 return yys - yystr - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002620}
Reid Spencerb8f85052007-07-31 03:50:36 +00002621# endif
2622# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002623
Reid Spencerb8f85052007-07-31 03:50:36 +00002624# ifndef yystpcpy
2625# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2626# define yystpcpy stpcpy
2627# else
2628/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2629 YYDEST. */
2630static char *
2631# if defined (__STDC__) || defined (__cplusplus)
2632yystpcpy (char *yydest, const char *yysrc)
2633# else
2634yystpcpy (yydest, yysrc)
2635 char *yydest;
2636 const char *yysrc;
2637# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002638{
David Greene718fda32007-08-01 03:59:32 +00002639 register char *yyd = yydest;
2640 register const char *yys = yysrc;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002641
Reid Spencerb8f85052007-07-31 03:50:36 +00002642 while ((*yyd++ = *yys++) != '\0')
2643 continue;
2644
2645 return yyd - 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002646}
Reid Spencerb8f85052007-07-31 03:50:36 +00002647# endif
2648# endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002649
David Greene718fda32007-08-01 03:59:32 +00002650#endif /* !YYERROR_VERBOSE */
Reid Spencerb8f85052007-07-31 03:50:36 +00002651
Reid Spencered951ea2007-05-19 07:22:10 +00002652
2653
Reid Spencerb8f85052007-07-31 03:50:36 +00002654#if YYDEBUG
2655/*--------------------------------.
2656| Print this symbol on YYOUTPUT. |
2657`--------------------------------*/
Reid Spencered951ea2007-05-19 07:22:10 +00002658
Reid Spencerb8f85052007-07-31 03:50:36 +00002659#if defined (__STDC__) || defined (__cplusplus)
2660static void
2661yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002662#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002663static void
2664yysymprint (yyoutput, yytype, yyvaluep)
2665 FILE *yyoutput;
2666 int yytype;
2667 YYSTYPE *yyvaluep;
2668#endif
2669{
2670 /* Pacify ``unused variable'' warnings. */
2671 (void) yyvaluep;
2672
2673 if (yytype < YYNTOKENS)
David Greene718fda32007-08-01 03:59:32 +00002674 {
2675 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2676# ifdef YYPRINT
2677 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2678# endif
2679 }
Reid Spencerb8f85052007-07-31 03:50:36 +00002680 else
2681 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2682
Reid Spencerb8f85052007-07-31 03:50:36 +00002683 switch (yytype)
2684 {
2685 default:
2686 break;
2687 }
2688 YYFPRINTF (yyoutput, ")");
2689}
2690
2691#endif /* ! YYDEBUG */
2692/*-----------------------------------------------.
2693| Release the memory associated to this symbol. |
2694`-----------------------------------------------*/
2695
2696#if defined (__STDC__) || defined (__cplusplus)
2697static void
David Greene718fda32007-08-01 03:59:32 +00002698yydestruct (int yytype, YYSTYPE *yyvaluep)
Reid Spencerb8f85052007-07-31 03:50:36 +00002699#else
2700static void
David Greene718fda32007-08-01 03:59:32 +00002701yydestruct (yytype, yyvaluep)
Reid Spencerb8f85052007-07-31 03:50:36 +00002702 int yytype;
2703 YYSTYPE *yyvaluep;
2704#endif
2705{
2706 /* Pacify ``unused variable'' warnings. */
2707 (void) yyvaluep;
2708
Reid Spencerb8f85052007-07-31 03:50:36 +00002709 switch (yytype)
2710 {
2711
2712 default:
2713 break;
2714 }
2715}
2716
2717
2718/* Prevent warnings from -Wmissing-prototypes. */
2719
2720#ifdef YYPARSE_PARAM
2721# if defined (__STDC__) || defined (__cplusplus)
2722int yyparse (void *YYPARSE_PARAM);
2723# else
2724int yyparse ();
2725# endif
2726#else /* ! YYPARSE_PARAM */
2727#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002728int yyparse (void);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002729#else
Reid Spencerb8f85052007-07-31 03:50:36 +00002730int yyparse ();
2731#endif
2732#endif /* ! YYPARSE_PARAM */
2733
2734
2735
David Greene718fda32007-08-01 03:59:32 +00002736/* The lookahead symbol. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002737int yychar;
2738
David Greene718fda32007-08-01 03:59:32 +00002739/* The semantic value of the lookahead symbol. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002740YYSTYPE yylval;
2741
2742/* Number of syntax errors so far. */
2743int yynerrs;
2744
2745
2746
2747/*----------.
2748| yyparse. |
2749`----------*/
2750
2751#ifdef YYPARSE_PARAM
2752# if defined (__STDC__) || defined (__cplusplus)
2753int yyparse (void *YYPARSE_PARAM)
2754# else
2755int yyparse (YYPARSE_PARAM)
2756 void *YYPARSE_PARAM;
2757# endif
2758#else /* ! YYPARSE_PARAM */
2759#if defined (__STDC__) || defined (__cplusplus)
2760int
2761yyparse (void)
2762#else
2763int
2764yyparse ()
2765
2766#endif
2767#endif
2768{
2769
David Greene718fda32007-08-01 03:59:32 +00002770 register int yystate;
2771 register int yyn;
Reid Spencerb8f85052007-07-31 03:50:36 +00002772 int yyresult;
2773 /* Number of tokens to shift before error messages enabled. */
2774 int yyerrstatus;
David Greene718fda32007-08-01 03:59:32 +00002775 /* Lookahead token as an internal (translated) token number. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002776 int yytoken = 0;
2777
2778 /* Three stacks and their tools:
2779 `yyss': related to states,
2780 `yyvs': related to semantic values,
2781 `yyls': related to locations.
2782
2783 Refer to the stacks thru separate pointers, to allow yyoverflow
2784 to reallocate them elsewhere. */
2785
2786 /* The state stack. */
David Greene718fda32007-08-01 03:59:32 +00002787 short yyssa[YYINITDEPTH];
2788 short *yyss = yyssa;
2789 register short *yyssp;
Reid Spencerb8f85052007-07-31 03:50:36 +00002790
2791 /* The semantic value stack. */
2792 YYSTYPE yyvsa[YYINITDEPTH];
2793 YYSTYPE *yyvs = yyvsa;
David Greene718fda32007-08-01 03:59:32 +00002794 register YYSTYPE *yyvsp;
Reid Spencerb8f85052007-07-31 03:50:36 +00002795
2796
2797
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002798#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002799
Reid Spencerb8f85052007-07-31 03:50:36 +00002800 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002801
Reid Spencerb8f85052007-07-31 03:50:36 +00002802 /* The variables used to return semantic value and location from the
2803 action routines. */
2804 YYSTYPE yyval;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002805
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002806
Reid Spencerb8f85052007-07-31 03:50:36 +00002807 /* When reducing, the number of symbols on the RHS of the reduced
2808 rule. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002809 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002810
Reid Spencerb8f85052007-07-31 03:50:36 +00002811 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002812
Reid Spencer68a24bd2005-08-27 18:50:39 +00002813 yystate = 0;
2814 yyerrstatus = 0;
2815 yynerrs = 0;
2816 yychar = YYEMPTY; /* Cause a token to be read. */
2817
2818 /* Initialize stack pointers.
2819 Waste one element of value and location stack
2820 so that they stay on the same level as the state stack.
2821 The wasted elements are never initialized. */
2822
Reid Spencerb8f85052007-07-31 03:50:36 +00002823 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002824 yyvsp = yyvs;
2825
Reid Spencerb8f85052007-07-31 03:50:36 +00002826 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002827
Reid Spencerb8f85052007-07-31 03:50:36 +00002828/*------------------------------------------------------------.
2829| yynewstate -- Push a new state, which is found in yystate. |
2830`------------------------------------------------------------*/
2831 yynewstate:
2832 /* In all cases, when you get here, the value and location stacks
2833 have just been pushed. so pushing a state here evens the stacks.
2834 */
2835 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002836
Reid Spencerb8f85052007-07-31 03:50:36 +00002837 yysetstate:
2838 *yyssp = yystate;
2839
2840 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002841 {
2842 /* Get the current used size of the three stacks, in elements. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002843 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002844
2845#ifdef yyoverflow
Reid Spencerb8f85052007-07-31 03:50:36 +00002846 {
2847 /* Give user a chance to reallocate the stack. Use copies of
2848 these so that the &'s don't force the real ones into
2849 memory. */
2850 YYSTYPE *yyvs1 = yyvs;
David Greene718fda32007-08-01 03:59:32 +00002851 short *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852
Reid Spencerb8f85052007-07-31 03:50:36 +00002853
2854 /* Each stack pointer address is followed by the size of the
2855 data in use in that stack, in bytes. This used to be a
2856 conditional around just the two extra args, but that might
2857 be undefined if yyoverflow is a macro. */
David Greene718fda32007-08-01 03:59:32 +00002858 yyoverflow ("parser stack overflow",
Reid Spencerb8f85052007-07-31 03:50:36 +00002859 &yyss1, yysize * sizeof (*yyssp),
2860 &yyvs1, yysize * sizeof (*yyvsp),
2861
2862 &yystacksize);
2863
2864 yyss = yyss1;
2865 yyvs = yyvs1;
2866 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002867#else /* no yyoverflow */
Reid Spencerb8f85052007-07-31 03:50:36 +00002868# ifndef YYSTACK_RELOCATE
David Greene718fda32007-08-01 03:59:32 +00002869 goto yyoverflowlab;
Reid Spencerb8f85052007-07-31 03:50:36 +00002870# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871 /* Extend the stack our own way. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002872 if (YYMAXDEPTH <= yystacksize)
David Greene718fda32007-08-01 03:59:32 +00002873 goto yyoverflowlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874 yystacksize *= 2;
Reid Spencerb8f85052007-07-31 03:50:36 +00002875 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876 yystacksize = YYMAXDEPTH;
Reid Spencerb8f85052007-07-31 03:50:36 +00002877
2878 {
David Greene718fda32007-08-01 03:59:32 +00002879 short *yyss1 = yyss;
Reid Spencerb8f85052007-07-31 03:50:36 +00002880 union yyalloc *yyptr =
2881 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2882 if (! yyptr)
David Greene718fda32007-08-01 03:59:32 +00002883 goto yyoverflowlab;
Reid Spencerb8f85052007-07-31 03:50:36 +00002884 YYSTACK_RELOCATE (yyss);
2885 YYSTACK_RELOCATE (yyvs);
2886
2887# undef YYSTACK_RELOCATE
2888 if (yyss1 != yyssa)
2889 YYSTACK_FREE (yyss1);
2890 }
2891# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002892#endif /* no yyoverflow */
2893
Reid Spencerb8f85052007-07-31 03:50:36 +00002894 yyssp = yyss + yysize - 1;
2895 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002896
2897
Reid Spencerb8f85052007-07-31 03:50:36 +00002898 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2899 (unsigned long int) yystacksize));
2900
2901 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002902 YYABORT;
2903 }
2904
Reid Spencerb8f85052007-07-31 03:50:36 +00002905 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906
2907 goto yybackup;
Reid Spencerb8f85052007-07-31 03:50:36 +00002908
2909/*-----------.
2910| yybackup. |
2911`-----------*/
2912yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002913
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002914/* Do appropriate processing given the current state. */
David Greene718fda32007-08-01 03:59:32 +00002915/* Read a lookahead token if we need one and don't already have one. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002916/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002917
David Greene718fda32007-08-01 03:59:32 +00002918 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002919
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 yyn = yypact[yystate];
Reid Spencerb8f85052007-07-31 03:50:36 +00002921 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002922 goto yydefault;
2923
David Greene718fda32007-08-01 03:59:32 +00002924 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925
David Greene718fda32007-08-01 03:59:32 +00002926 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002927 if (yychar == YYEMPTY)
2928 {
Reid Spencerb8f85052007-07-31 03:50:36 +00002929 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002930 yychar = YYLEX;
2931 }
2932
Reid Spencerb8f85052007-07-31 03:50:36 +00002933 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934 {
Reid Spencerb8f85052007-07-31 03:50:36 +00002935 yychar = yytoken = YYEOF;
2936 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002937 }
2938 else
2939 {
Reid Spencerb8f85052007-07-31 03:50:36 +00002940 yytoken = YYTRANSLATE (yychar);
David Greene718fda32007-08-01 03:59:32 +00002941 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 }
2943
Reid Spencerb8f85052007-07-31 03:50:36 +00002944 /* If the proper action on seeing token YYTOKEN is to reduce or to
2945 detect an error, take that action. */
2946 yyn += yytoken;
2947 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 goto yydefault;
2949 yyn = yytable[yyn];
Reid Spencerb8f85052007-07-31 03:50:36 +00002950 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002951 {
Reid Spencerb8f85052007-07-31 03:50:36 +00002952 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953 goto yyerrlab;
2954 yyn = -yyn;
2955 goto yyreduce;
2956 }
2957
2958 if (yyn == YYFINAL)
2959 YYACCEPT;
2960
David Greene718fda32007-08-01 03:59:32 +00002961 /* Shift the lookahead token. */
2962 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002963
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002964 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002965 if (yychar != YYEOF)
2966 yychar = YYEMPTY;
2967
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002968 *++yyvsp = yylval;
2969
Reid Spencerb8f85052007-07-31 03:50:36 +00002970
2971 /* Count tokens shifted since error; after three, turn off error
2972 status. */
2973 if (yyerrstatus)
2974 yyerrstatus--;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002975
2976 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002977 goto yynewstate;
2978
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002979
Reid Spencerb8f85052007-07-31 03:50:36 +00002980/*-----------------------------------------------------------.
2981| yydefault -- do the default action for the current state. |
2982`-----------------------------------------------------------*/
2983yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002984 yyn = yydefact[yystate];
2985 if (yyn == 0)
2986 goto yyerrlab;
Reid Spencerb8f85052007-07-31 03:50:36 +00002987 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002988
Reid Spencerb8f85052007-07-31 03:50:36 +00002989
2990/*-----------------------------.
2991| yyreduce -- Do a reduction. |
2992`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993yyreduce:
Reid Spencerb8f85052007-07-31 03:50:36 +00002994 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 yylen = yyr2[yyn];
2996
Reid Spencerb8f85052007-07-31 03:50:36 +00002997 /* If YYLEN is nonzero, implement the default value of the action:
2998 `$$ = $1'.
2999
3000 Otherwise, the following line sets YYVAL to garbage.
3001 This behavior is undocumented and Bison
3002 users should not rely upon it. Assigning to YYVAL
3003 unconditionally makes the parser a bit smaller, and it avoids a
3004 GCC warning that YYVAL may be used uninitialized. */
3005 yyval = yyvsp[1-yylen];
3006
3007
3008 YY_REDUCE_PRINT (yyn);
3009 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003010 {
Reid Spencerb8f85052007-07-31 03:50:36 +00003011 case 29:
David Greene718fda32007-08-01 03:59:32 +00003012#line 1122 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3013 { yyval.IPredicate = ICmpInst::ICMP_EQ; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003014 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003015
Reid Spencerb8f85052007-07-31 03:50:36 +00003016 case 30:
David Greene718fda32007-08-01 03:59:32 +00003017#line 1122 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3018 { yyval.IPredicate = ICmpInst::ICMP_NE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003019 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003020
Reid Spencerb8f85052007-07-31 03:50:36 +00003021 case 31:
David Greene718fda32007-08-01 03:59:32 +00003022#line 1123 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3023 { yyval.IPredicate = ICmpInst::ICMP_SLT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003024 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003025
Reid Spencerb8f85052007-07-31 03:50:36 +00003026 case 32:
David Greene718fda32007-08-01 03:59:32 +00003027#line 1123 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3028 { yyval.IPredicate = ICmpInst::ICMP_SGT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003029 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003030
Reid Spencerb8f85052007-07-31 03:50:36 +00003031 case 33:
David Greene718fda32007-08-01 03:59:32 +00003032#line 1124 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3033 { yyval.IPredicate = ICmpInst::ICMP_SLE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003034 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003035
Reid Spencerb8f85052007-07-31 03:50:36 +00003036 case 34:
David Greene718fda32007-08-01 03:59:32 +00003037#line 1124 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3038 { yyval.IPredicate = ICmpInst::ICMP_SGE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003039 break;
3040
3041 case 35:
David Greene718fda32007-08-01 03:59:32 +00003042#line 1125 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3043 { yyval.IPredicate = ICmpInst::ICMP_ULT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003044 break;
3045
3046 case 36:
David Greene718fda32007-08-01 03:59:32 +00003047#line 1125 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3048 { yyval.IPredicate = ICmpInst::ICMP_UGT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003049 break;
3050
3051 case 37:
David Greene718fda32007-08-01 03:59:32 +00003052#line 1126 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3053 { yyval.IPredicate = ICmpInst::ICMP_ULE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003054 break;
3055
3056 case 38:
David Greene718fda32007-08-01 03:59:32 +00003057#line 1126 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3058 { yyval.IPredicate = ICmpInst::ICMP_UGE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003059 break;
3060
3061 case 39:
David Greene718fda32007-08-01 03:59:32 +00003062#line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3063 { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003064 break;
3065
3066 case 40:
David Greene718fda32007-08-01 03:59:32 +00003067#line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3068 { yyval.FPredicate = FCmpInst::FCMP_ONE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003069 break;
3070
3071 case 41:
David Greene718fda32007-08-01 03:59:32 +00003072#line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3073 { yyval.FPredicate = FCmpInst::FCMP_OLT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003074 break;
3075
3076 case 42:
David Greene718fda32007-08-01 03:59:32 +00003077#line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3078 { yyval.FPredicate = FCmpInst::FCMP_OGT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003079 break;
3080
3081 case 43:
David Greene718fda32007-08-01 03:59:32 +00003082#line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3083 { yyval.FPredicate = FCmpInst::FCMP_OLE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003084 break;
3085
3086 case 44:
David Greene718fda32007-08-01 03:59:32 +00003087#line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3088 { yyval.FPredicate = FCmpInst::FCMP_OGE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003089 break;
3090
3091 case 45:
David Greene718fda32007-08-01 03:59:32 +00003092#line 1133 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3093 { yyval.FPredicate = FCmpInst::FCMP_ORD; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003094 break;
3095
3096 case 46:
David Greene718fda32007-08-01 03:59:32 +00003097#line 1133 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3098 { yyval.FPredicate = FCmpInst::FCMP_UNO; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003099 break;
3100
3101 case 47:
David Greene718fda32007-08-01 03:59:32 +00003102#line 1134 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3103 { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003104 break;
3105
3106 case 48:
David Greene718fda32007-08-01 03:59:32 +00003107#line 1134 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3108 { yyval.FPredicate = FCmpInst::FCMP_UNE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003109 break;
3110
3111 case 49:
David Greene718fda32007-08-01 03:59:32 +00003112#line 1135 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3113 { yyval.FPredicate = FCmpInst::FCMP_ULT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003114 break;
3115
3116 case 50:
David Greene718fda32007-08-01 03:59:32 +00003117#line 1135 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3118 { yyval.FPredicate = FCmpInst::FCMP_UGT; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003119 break;
3120
3121 case 51:
David Greene718fda32007-08-01 03:59:32 +00003122#line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3123 { yyval.FPredicate = FCmpInst::FCMP_ULE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003124 break;
3125
3126 case 52:
David Greene718fda32007-08-01 03:59:32 +00003127#line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3128 { yyval.FPredicate = FCmpInst::FCMP_UGE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003129 break;
3130
3131 case 53:
David Greene718fda32007-08-01 03:59:32 +00003132#line 1137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3133 { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003134 break;
3135
3136 case 54:
David Greene718fda32007-08-01 03:59:32 +00003137#line 1138 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3138 { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003139 break;
3140
3141 case 62:
David Greene718fda32007-08-01 03:59:32 +00003142#line 1147 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3143 { yyval.StrVal = 0; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003144 break;
3145
3146 case 63:
David Greene718fda32007-08-01 03:59:32 +00003147#line 1151 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003148 {
David Greene718fda32007-08-01 03:59:32 +00003149 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003150 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003151 ;}
3152 break;
3153
3154 case 64:
David Greene718fda32007-08-01 03:59:32 +00003155#line 1155 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003156 {
David Greene718fda32007-08-01 03:59:32 +00003157 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003158 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003159 ;}
3160 break;
3161
3162 case 68:
David Greene718fda32007-08-01 03:59:32 +00003163#line 1163 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003164 {
David Greene718fda32007-08-01 03:59:32 +00003165 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003166 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003167 ;}
3168 break;
3169
3170 case 69:
David Greene718fda32007-08-01 03:59:32 +00003171#line 1168 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003172 {
David Greene718fda32007-08-01 03:59:32 +00003173 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003174 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003175 ;}
3176 break;
3177
3178 case 70:
David Greene718fda32007-08-01 03:59:32 +00003179#line 1174 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3180 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003181 break;
3182
3183 case 71:
David Greene718fda32007-08-01 03:59:32 +00003184#line 1175 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3185 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003186 break;
3187
3188 case 72:
David Greene718fda32007-08-01 03:59:32 +00003189#line 1176 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3190 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003191 break;
3192
3193 case 73:
David Greene718fda32007-08-01 03:59:32 +00003194#line 1177 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3195 { yyval.Linkage = GlobalValue::AppendingLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003196 break;
3197
3198 case 74:
David Greene718fda32007-08-01 03:59:32 +00003199#line 1178 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3200 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003201 break;
3202
3203 case 75:
David Greene718fda32007-08-01 03:59:32 +00003204#line 1182 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3205 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003206 break;
3207
3208 case 76:
David Greene718fda32007-08-01 03:59:32 +00003209#line 1183 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3210 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003211 break;
3212
3213 case 77:
David Greene718fda32007-08-01 03:59:32 +00003214#line 1184 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3215 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003216 break;
3217
3218 case 78:
David Greene718fda32007-08-01 03:59:32 +00003219#line 1188 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3220 { yyval.Visibility = GlobalValue::DefaultVisibility; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003221 break;
3222
3223 case 79:
David Greene718fda32007-08-01 03:59:32 +00003224#line 1189 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3225 { yyval.Visibility = GlobalValue::DefaultVisibility; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003226 break;
3227
3228 case 80:
David Greene718fda32007-08-01 03:59:32 +00003229#line 1190 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3230 { yyval.Visibility = GlobalValue::HiddenVisibility; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003231 break;
3232
3233 case 81:
David Greene718fda32007-08-01 03:59:32 +00003234#line 1191 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3235 { yyval.Visibility = GlobalValue::ProtectedVisibility; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003236 break;
3237
3238 case 82:
David Greene718fda32007-08-01 03:59:32 +00003239#line 1195 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3240 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003241 break;
3242
3243 case 83:
David Greene718fda32007-08-01 03:59:32 +00003244#line 1196 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3245 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003246 break;
3247
3248 case 84:
David Greene718fda32007-08-01 03:59:32 +00003249#line 1197 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3250 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003251 break;
3252
3253 case 85:
David Greene718fda32007-08-01 03:59:32 +00003254#line 1201 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3255 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003256 break;
3257
3258 case 86:
David Greene718fda32007-08-01 03:59:32 +00003259#line 1202 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3260 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003261 break;
3262
3263 case 87:
David Greene718fda32007-08-01 03:59:32 +00003264#line 1203 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3265 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003266 break;
3267
3268 case 88:
David Greene718fda32007-08-01 03:59:32 +00003269#line 1204 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3270 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003271 break;
3272
3273 case 89:
David Greene718fda32007-08-01 03:59:32 +00003274#line 1205 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3275 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003276 break;
3277
3278 case 90:
David Greene718fda32007-08-01 03:59:32 +00003279#line 1209 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3280 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003281 break;
3282
3283 case 91:
David Greene718fda32007-08-01 03:59:32 +00003284#line 1210 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3285 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003286 break;
3287
3288 case 92:
David Greene718fda32007-08-01 03:59:32 +00003289#line 1211 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3290 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003291 break;
3292
3293 case 93:
David Greene718fda32007-08-01 03:59:32 +00003294#line 1214 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3295 { yyval.UIntVal = CallingConv::C; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003296 break;
3297
3298 case 94:
David Greene718fda32007-08-01 03:59:32 +00003299#line 1215 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3300 { yyval.UIntVal = CallingConv::C; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003301 break;
3302
3303 case 95:
David Greene718fda32007-08-01 03:59:32 +00003304#line 1216 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3305 { yyval.UIntVal = CallingConv::Fast; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003306 break;
3307
3308 case 96:
David Greene718fda32007-08-01 03:59:32 +00003309#line 1217 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3310 { yyval.UIntVal = CallingConv::Cold; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003311 break;
3312
3313 case 97:
David Greene718fda32007-08-01 03:59:32 +00003314#line 1218 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3315 { yyval.UIntVal = CallingConv::X86_StdCall; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003316 break;
3317
3318 case 98:
David Greene718fda32007-08-01 03:59:32 +00003319#line 1219 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3320 { yyval.UIntVal = CallingConv::X86_FastCall; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003321 break;
3322
3323 case 99:
David Greene718fda32007-08-01 03:59:32 +00003324#line 1220 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003325 {
David Greene718fda32007-08-01 03:59:32 +00003326 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003327 GEN_ERROR("Calling conv too large");
David Greene718fda32007-08-01 03:59:32 +00003328 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003329 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003330 ;}
3331 break;
3332
3333 case 100:
David Greene718fda32007-08-01 03:59:32 +00003334#line 1227 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3335 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003336 break;
3337
3338 case 101:
David Greene718fda32007-08-01 03:59:32 +00003339#line 1228 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3340 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003341 break;
3342
3343 case 102:
David Greene718fda32007-08-01 03:59:32 +00003344#line 1229 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3345 { yyval.ParamAttrs = ParamAttr::SExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003346 break;
3347
3348 case 103:
David Greene718fda32007-08-01 03:59:32 +00003349#line 1230 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3350 { yyval.ParamAttrs = ParamAttr::SExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003351 break;
3352
3353 case 104:
David Greene718fda32007-08-01 03:59:32 +00003354#line 1231 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3355 { yyval.ParamAttrs = ParamAttr::InReg; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003356 break;
3357
3358 case 105:
David Greene718fda32007-08-01 03:59:32 +00003359#line 1232 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3360 { yyval.ParamAttrs = ParamAttr::StructRet; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003361 break;
3362
3363 case 106:
David Greene718fda32007-08-01 03:59:32 +00003364#line 1233 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3365 { yyval.ParamAttrs = ParamAttr::NoAlias; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003366 break;
3367
3368 case 107:
David Greene718fda32007-08-01 03:59:32 +00003369#line 1234 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3370 { yyval.ParamAttrs = ParamAttr::ByVal; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003371 break;
3372
3373 case 108:
David Greene718fda32007-08-01 03:59:32 +00003374#line 1235 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3375 { yyval.ParamAttrs = ParamAttr::Nest; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003376 break;
3377
3378 case 109:
David Greene718fda32007-08-01 03:59:32 +00003379#line 1238 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3380 { yyval.ParamAttrs = ParamAttr::None; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003381 break;
3382
3383 case 110:
David Greene718fda32007-08-01 03:59:32 +00003384#line 1239 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003385 {
David Greene718fda32007-08-01 03:59:32 +00003386 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003387 ;}
3388 break;
3389
3390 case 111:
David Greene718fda32007-08-01 03:59:32 +00003391#line 1244 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3392 { yyval.ParamAttrs = ParamAttr::NoReturn; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003393 break;
3394
3395 case 112:
David Greene718fda32007-08-01 03:59:32 +00003396#line 1245 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3397 { yyval.ParamAttrs = ParamAttr::NoUnwind; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003398 break;
3399
3400 case 113:
David Greene718fda32007-08-01 03:59:32 +00003401#line 1246 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3402 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003403 break;
3404
3405 case 114:
David Greene718fda32007-08-01 03:59:32 +00003406#line 1247 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3407 { yyval.ParamAttrs = ParamAttr::SExt; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003408 break;
3409
3410 case 115:
David Greene718fda32007-08-01 03:59:32 +00003411#line 1250 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3412 { yyval.ParamAttrs = ParamAttr::None; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003413 break;
3414
3415 case 116:
David Greene718fda32007-08-01 03:59:32 +00003416#line 1251 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003417 {
David Greene718fda32007-08-01 03:59:32 +00003418 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003419 ;}
3420 break;
3421
Reid Spencer1013b4d2007-07-31 14:41:17 +00003422 case 117:
David Greene718fda32007-08-01 03:59:32 +00003423#line 1258 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3424 { yyval.UIntVal = 0; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003425 break;
3426
Reid Spencer1013b4d2007-07-31 14:41:17 +00003427 case 118:
David Greene718fda32007-08-01 03:59:32 +00003428#line 1259 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003429 {
David Greene718fda32007-08-01 03:59:32 +00003430 yyval.UIntVal = yyvsp[0].UInt64Val;
3431 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003432 GEN_ERROR("Alignment must be a power of two");
3433 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003434;}
3435 break;
3436
Reid Spencer1013b4d2007-07-31 14:41:17 +00003437 case 119:
David Greene718fda32007-08-01 03:59:32 +00003438#line 1265 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3439 { yyval.UIntVal = 0; ;}
Reid Spencer1013b4d2007-07-31 14:41:17 +00003440 break;
3441
Reid Spencerb8f85052007-07-31 03:50:36 +00003442 case 120:
David Greene718fda32007-08-01 03:59:32 +00003443#line 1266 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003444 {
David Greene718fda32007-08-01 03:59:32 +00003445 yyval.UIntVal = yyvsp[0].UInt64Val;
3446 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003447 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003448 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003449;}
3450 break;
3451
Reid Spencer1013b4d2007-07-31 14:41:17 +00003452 case 121:
David Greene718fda32007-08-01 03:59:32 +00003453#line 1274 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003454 {
David Greene718fda32007-08-01 03:59:32 +00003455 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
3456 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003457 GEN_ERROR("Invalid character in section name");
David Greene718fda32007-08-01 03:59:32 +00003458 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003459 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003460;}
3461 break;
3462
Reid Spencer1013b4d2007-07-31 14:41:17 +00003463 case 122:
David Greene718fda32007-08-01 03:59:32 +00003464#line 1282 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3465 { yyval.StrVal = 0; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003466 break;
3467
Reid Spencer1013b4d2007-07-31 14:41:17 +00003468 case 123:
David Greene718fda32007-08-01 03:59:32 +00003469#line 1283 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3470 { yyval.StrVal = yyvsp[0].StrVal; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00003471 break;
3472
Reid Spencer1013b4d2007-07-31 14:41:17 +00003473 case 124:
David Greene718fda32007-08-01 03:59:32 +00003474#line 1288 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1013b4d2007-07-31 14:41:17 +00003475 {;}
3476 break;
3477
Reid Spencerb8f85052007-07-31 03:50:36 +00003478 case 125:
David Greene718fda32007-08-01 03:59:32 +00003479#line 1289 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003480 {;}
3481 break;
3482
3483 case 126:
David Greene718fda32007-08-01 03:59:32 +00003484#line 1290 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003485 {
David Greene718fda32007-08-01 03:59:32 +00003486 CurGV->setSection(*yyvsp[0].StrVal);
3487 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003488 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003489 ;}
3490 break;
3491
Reid Spencer1013b4d2007-07-31 14:41:17 +00003492 case 127:
David Greene718fda32007-08-01 03:59:32 +00003493#line 1295 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003494 {
David Greene718fda32007-08-01 03:59:32 +00003495 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003496 GEN_ERROR("Alignment must be a power of two");
David Greene718fda32007-08-01 03:59:32 +00003497 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003498 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003499 ;}
3500 break;
3501
Reid Spencer1013b4d2007-07-31 14:41:17 +00003502 case 132:
David Greene718fda32007-08-01 03:59:32 +00003503#line 1311 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003504 {
David Greene718fda32007-08-01 03:59:32 +00003505 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003506 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003507 ;}
3508 break;
3509
Reid Spencer1013b4d2007-07-31 14:41:17 +00003510 case 133:
David Greene718fda32007-08-01 03:59:32 +00003511#line 1315 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003512 {
David Greene718fda32007-08-01 03:59:32 +00003513 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003514 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003515 ;}
3516 break;
3517
Reid Spencer1013b4d2007-07-31 14:41:17 +00003518 case 134:
David Greene718fda32007-08-01 03:59:32 +00003519#line 1319 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003520 { // Pointer type?
David Greene718fda32007-08-01 03:59:32 +00003521 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003522 GEN_ERROR("Cannot form a pointer to a basic block");
David Greene718fda32007-08-01 03:59:32 +00003523 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
3524 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003525 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003526 ;}
3527 break;
3528
Reid Spencer1013b4d2007-07-31 14:41:17 +00003529 case 135:
David Greene718fda32007-08-01 03:59:32 +00003530#line 1326 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003531 { // Named types are also simple types...
David Greene718fda32007-08-01 03:59:32 +00003532 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003533 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00003534 yyval.TypeVal = new PATypeHolder(tmp);
Reid Spencerb8f85052007-07-31 03:50:36 +00003535 ;}
3536 break;
3537
Reid Spencer1013b4d2007-07-31 14:41:17 +00003538 case 136:
David Greene718fda32007-08-01 03:59:32 +00003539#line 1331 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003540 { // Type UpReference
David Greene718fda32007-08-01 03:59:32 +00003541 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003542 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
David Greene718fda32007-08-01 03:59:32 +00003543 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3544 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003545 UR_OUT("New Upreference!\n");
3546 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003547 ;}
3548 break;
3549
Reid Spencer1013b4d2007-07-31 14:41:17 +00003550 case 137:
David Greene718fda32007-08-01 03:59:32 +00003551#line 1339 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003552 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003553 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003554 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00003555 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3556 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003557 Attrs.push_back(X);
3558 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003559 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00003560 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003561 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003562 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003563 Params.push_back(Ty);
3564 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003565 if (I->Attrs != ParamAttr::None) {
3566 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3567 Attrs.push_back(X);
3568 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003569 }
3570 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3571 if (isVarArg) Params.pop_back();
3572
Reid Spencer7b5d4662007-04-09 06:16:21 +00003573 ParamAttrsList *ActualAttrs = 0;
3574 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003575 ActualAttrs = ParamAttrsList::get(Attrs);
David Greene718fda32007-08-01 03:59:32 +00003576 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3577 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3578 delete yyvsp[-4].TypeVal; // Delete the return type handle
3579 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003580 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003581 ;}
3582 break;
3583
Reid Spencer1013b4d2007-07-31 14:41:17 +00003584 case 138:
David Greene718fda32007-08-01 03:59:32 +00003585#line 1369 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003586 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003587 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003588 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00003589 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3590 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003591 Attrs.push_back(X);
3592 }
David Greene718fda32007-08-01 03:59:32 +00003593 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003594 unsigned index = 1;
3595 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003596 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003597 Params.push_back(Ty);
3598 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003599 if (I->Attrs != ParamAttr::None) {
3600 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3601 Attrs.push_back(X);
3602 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003603 }
3604 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3605 if (isVarArg) Params.pop_back();
3606
Reid Spencer7b5d4662007-04-09 06:16:21 +00003607 ParamAttrsList *ActualAttrs = 0;
3608 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003609 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003610
David Greene718fda32007-08-01 03:59:32 +00003611 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3612 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3613 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003614 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003615 ;}
3616 break;
3617
Reid Spencer1013b4d2007-07-31 14:41:17 +00003618 case 139:
David Greene718fda32007-08-01 03:59:32 +00003619#line 1400 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003620 { // Sized array type?
David Greene718fda32007-08-01 03:59:32 +00003621 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3622 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003623 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003624 ;}
3625 break;
3626
Reid Spencer1013b4d2007-07-31 14:41:17 +00003627 case 140:
David Greene718fda32007-08-01 03:59:32 +00003628#line 1405 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003629 { // Vector type?
David Greene718fda32007-08-01 03:59:32 +00003630 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3631 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003632 GEN_ERROR("Unsigned result not equal to signed result");
3633 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3634 GEN_ERROR("Element type of a VectorType must be primitive");
David Greene718fda32007-08-01 03:59:32 +00003635 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003636 GEN_ERROR("Vector length should be a power of 2");
David Greene718fda32007-08-01 03:59:32 +00003637 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3638 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003639 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003640 ;}
3641 break;
3642
Reid Spencer1013b4d2007-07-31 14:41:17 +00003643 case 141:
David Greene718fda32007-08-01 03:59:32 +00003644#line 1417 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003645 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003646 std::vector<const Type*> Elements;
David Greene718fda32007-08-01 03:59:32 +00003647 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3648 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003649 Elements.push_back(*I);
3650
David Greene718fda32007-08-01 03:59:32 +00003651 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3652 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003653 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003654 ;}
3655 break;
3656
Reid Spencer1013b4d2007-07-31 14:41:17 +00003657 case 142:
David Greene718fda32007-08-01 03:59:32 +00003658#line 1427 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003659 { // Empty structure type?
David Greene718fda32007-08-01 03:59:32 +00003660 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003661 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003662 ;}
3663 break;
3664
Reid Spencer1013b4d2007-07-31 14:41:17 +00003665 case 143:
David Greene718fda32007-08-01 03:59:32 +00003666#line 1431 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003667 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003668 std::vector<const Type*> Elements;
David Greene718fda32007-08-01 03:59:32 +00003669 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3670 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003671 Elements.push_back(*I);
3672
David Greene718fda32007-08-01 03:59:32 +00003673 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3674 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003675 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003676 ;}
3677 break;
3678
Reid Spencer1013b4d2007-07-31 14:41:17 +00003679 case 144:
David Greene718fda32007-08-01 03:59:32 +00003680#line 1441 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003681 { // Empty structure type?
David Greene718fda32007-08-01 03:59:32 +00003682 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003683 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003684 ;}
3685 break;
3686
Reid Spencer1013b4d2007-07-31 14:41:17 +00003687 case 145:
David Greene718fda32007-08-01 03:59:32 +00003688#line 1448 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003689 {
David Greene718fda32007-08-01 03:59:32 +00003690 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3691 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00003692 ;}
3693 break;
3694
Reid Spencer1013b4d2007-07-31 14:41:17 +00003695 case 146:
David Greene718fda32007-08-01 03:59:32 +00003696#line 1455 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003697 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003698 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003699 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3700 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003701 GEN_ERROR("LLVM functions cannot return aggregate types");
David Greene718fda32007-08-01 03:59:32 +00003702 yyval.TypeVal = yyvsp[0].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00003703 ;}
3704 break;
3705
Reid Spencer1013b4d2007-07-31 14:41:17 +00003706 case 147:
David Greene718fda32007-08-01 03:59:32 +00003707#line 1462 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003708 {
David Greene718fda32007-08-01 03:59:32 +00003709 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
Reid Spencerb8f85052007-07-31 03:50:36 +00003710 ;}
3711 break;
3712
Reid Spencer1013b4d2007-07-31 14:41:17 +00003713 case 148:
David Greene718fda32007-08-01 03:59:32 +00003714#line 1467 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003715 {
David Greene718fda32007-08-01 03:59:32 +00003716 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3717 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003718 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003719 ;}
3720 break;
3721
Reid Spencer1013b4d2007-07-31 14:41:17 +00003722 case 149:
David Greene718fda32007-08-01 03:59:32 +00003723#line 1472 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003724 {
David Greene718fda32007-08-01 03:59:32 +00003725 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003726 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003727 ;}
3728 break;
3729
Reid Spencer1013b4d2007-07-31 14:41:17 +00003730 case 151:
David Greene718fda32007-08-01 03:59:32 +00003731#line 1480 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003732 {
David Greene718fda32007-08-01 03:59:32 +00003733 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003734 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003735 TWA.Ty = new PATypeHolder(Type::VoidTy);
David Greene718fda32007-08-01 03:59:32 +00003736 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003737 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003738 ;}
3739 break;
3740
Reid Spencer1013b4d2007-07-31 14:41:17 +00003741 case 152:
David Greene718fda32007-08-01 03:59:32 +00003742#line 1487 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003743 {
David Greene718fda32007-08-01 03:59:32 +00003744 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003745 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3746 TWA.Ty = new PATypeHolder(Type::VoidTy);
David Greene718fda32007-08-01 03:59:32 +00003747 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003748 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003749 ;}
3750 break;
3751
Reid Spencer1013b4d2007-07-31 14:41:17 +00003752 case 153:
David Greene718fda32007-08-01 03:59:32 +00003753#line 1494 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003754 {
David Greene718fda32007-08-01 03:59:32 +00003755 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003756 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003757 ;}
3758 break;
3759
Reid Spencer1013b4d2007-07-31 14:41:17 +00003760 case 154:
David Greene718fda32007-08-01 03:59:32 +00003761#line 1502 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003762 {
David Greene718fda32007-08-01 03:59:32 +00003763 yyval.TypeList = new std::list<PATypeHolder>();
3764 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3765 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003766 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003767 ;}
3768 break;
3769
Reid Spencer1013b4d2007-07-31 14:41:17 +00003770 case 155:
David Greene718fda32007-08-01 03:59:32 +00003771#line 1508 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003772 {
David Greene718fda32007-08-01 03:59:32 +00003773 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3774 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003775 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003776 ;}
3777 break;
3778
Reid Spencer1013b4d2007-07-31 14:41:17 +00003779 case 156:
David Greene718fda32007-08-01 03:59:32 +00003780#line 1520 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003781 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003782 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003783 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3784 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003786 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003787 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003788 const Type *ETy = ATy->getElementType();
3789 int NumElements = ATy->getNumElements();
3790
3791 // Verify that we have the correct size...
David Greene718fda32007-08-01 03:59:32 +00003792 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003793 GEN_ERROR("Type mismatch: constant sized array initialized with " +
David Greene718fda32007-08-01 03:59:32 +00003794 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003795 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003796
3797 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00003798 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3799 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003800 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3801 ETy->getDescription() +"' as required!\nIt is of type '"+
David Greene718fda32007-08-01 03:59:32 +00003802 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003803 }
3804
David Greene718fda32007-08-01 03:59:32 +00003805 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3806 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003807 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003808 ;}
3809 break;
3810
Reid Spencer1013b4d2007-07-31 14:41:17 +00003811 case 157:
David Greene718fda32007-08-01 03:59:32 +00003812#line 1548 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003813 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003814 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003815 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3816 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003817 if (ATy == 0)
3818 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003819 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003820
Andrew Lenharth6353e052006-12-08 18:07:09 +00003821 int NumElements = ATy->getNumElements();
3822 if (NumElements != -1 && NumElements != 0)
3823 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003824 " arguments, but has size of " + itostr(NumElements) +"");
David Greene718fda32007-08-01 03:59:32 +00003825 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3826 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003827 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003828 ;}
3829 break;
3830
Reid Spencer1013b4d2007-07-31 14:41:17 +00003831 case 158:
David Greene718fda32007-08-01 03:59:32 +00003832#line 1564 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003833 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003834 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003835 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3836 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003837 if (ATy == 0)
3838 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003839 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003840
3841 int NumElements = ATy->getNumElements();
3842 const Type *ETy = ATy->getElementType();
David Greene718fda32007-08-01 03:59:32 +00003843 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003844 GEN_ERROR("Can't build string constant of size " +
David Greene718fda32007-08-01 03:59:32 +00003845 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003846 " when array has size " + itostr(NumElements) + "");
3847 std::vector<Constant*> Vals;
3848 if (ETy == Type::Int8Ty) {
David Greene718fda32007-08-01 03:59:32 +00003849 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3850 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003851 } else {
David Greene718fda32007-08-01 03:59:32 +00003852 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003853 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3854 }
David Greene718fda32007-08-01 03:59:32 +00003855 delete yyvsp[0].StrVal;
3856 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3857 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003858 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003859 ;}
3860 break;
3861
Reid Spencer1013b4d2007-07-31 14:41:17 +00003862 case 159:
David Greene718fda32007-08-01 03:59:32 +00003863#line 1591 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003864 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003865 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003866 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3867 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003868 if (PTy == 0)
3869 GEN_ERROR("Cannot make packed constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003870 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003871 const Type *ETy = PTy->getElementType();
3872 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003873
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003874 // Verify that we have the correct size...
David Greene718fda32007-08-01 03:59:32 +00003875 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003876 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
David Greene718fda32007-08-01 03:59:32 +00003877 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003878 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003879
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003880 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00003881 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3882 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003883 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3884 ETy->getDescription() +"' as required!\nIt is of type '"+
David Greene718fda32007-08-01 03:59:32 +00003885 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003886 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003887
David Greene718fda32007-08-01 03:59:32 +00003888 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3889 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003890 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003891 ;}
3892 break;
3893
Reid Spencer1013b4d2007-07-31 14:41:17 +00003894 case 160:
David Greene718fda32007-08-01 03:59:32 +00003895#line 1619 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003896 {
David Greene718fda32007-08-01 03:59:32 +00003897 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003898 if (STy == 0)
3899 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003900 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003901
David Greene718fda32007-08-01 03:59:32 +00003902 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003903 GEN_ERROR("Illegal number of initializers for structure type");
3904
3905 // Check to ensure that constants are compatible with the type initializer!
David Greene718fda32007-08-01 03:59:32 +00003906 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3907 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003908 GEN_ERROR("Expected type '" +
3909 STy->getElementType(i)->getDescription() +
3910 "' for element #" + utostr(i) +
3911 " of structure initializer");
3912
3913 // Check to ensure that Type is not packed
3914 if (STy->isPacked())
3915 GEN_ERROR("Unpacked Initializer to vector type '" +
3916 STy->getDescription() + "'");
3917
David Greene718fda32007-08-01 03:59:32 +00003918 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3919 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003920 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003921 ;}
3922 break;
3923
Reid Spencer1013b4d2007-07-31 14:41:17 +00003924 case 161:
David Greene718fda32007-08-01 03:59:32 +00003925#line 1645 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003926 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003927 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003928 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3929 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003930 if (STy == 0)
3931 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003932 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003933
3934 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003935 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003936
3937 // Check to ensure that Type is not packed
3938 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003939 GEN_ERROR("Unpacked Initializer to vector type '" +
3940 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003941
David Greene718fda32007-08-01 03:59:32 +00003942 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3943 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003944 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003945 ;}
3946 break;
3947
Reid Spencer1013b4d2007-07-31 14:41:17 +00003948 case 162:
David Greene718fda32007-08-01 03:59:32 +00003949#line 1665 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003950 {
David Greene718fda32007-08-01 03:59:32 +00003951 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003952 if (STy == 0)
3953 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003954 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003955
David Greene718fda32007-08-01 03:59:32 +00003956 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003957 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003958
3959 // Check to ensure that constants are compatible with the type initializer!
David Greene718fda32007-08-01 03:59:32 +00003960 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3961 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003962 GEN_ERROR("Expected type '" +
3963 STy->getElementType(i)->getDescription() +
3964 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003965 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003966
3967 // Check to ensure that Type is packed
3968 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003969 GEN_ERROR("Vector initializer to non-vector type '" +
3970 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003971
David Greene718fda32007-08-01 03:59:32 +00003972 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3973 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003974 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003975 ;}
3976 break;
3977
Reid Spencer1013b4d2007-07-31 14:41:17 +00003978 case 163:
David Greene718fda32007-08-01 03:59:32 +00003979#line 1691 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00003980 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003981 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003982 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3983 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003984 if (STy == 0)
3985 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003986 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003987
3988 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003989 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003990
3991 // Check to ensure that Type is packed
3992 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003993 GEN_ERROR("Vector initializer to non-vector type '" +
3994 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003995
David Greene718fda32007-08-01 03:59:32 +00003996 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3997 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003998 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00003999 ;}
4000 break;
4001
Reid Spencer1013b4d2007-07-31 14:41:17 +00004002 case 164:
David Greene718fda32007-08-01 03:59:32 +00004003#line 1711 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004004 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004005 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004006 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4007 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004008 if (PTy == 0)
4009 GEN_ERROR("Cannot make null pointer constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00004010 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004011
David Greene718fda32007-08-01 03:59:32 +00004012 yyval.ConstVal = ConstantPointerNull::get(PTy);
4013 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004014 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004015 ;}
4016 break;
4017
Reid Spencer1013b4d2007-07-31 14:41:17 +00004018 case 165:
David Greene718fda32007-08-01 03:59:32 +00004019#line 1723 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004020 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004021 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004022 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4023 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
4024 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004025 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004026 ;}
4027 break;
4028
Reid Spencer1013b4d2007-07-31 14:41:17 +00004029 case 166:
David Greene718fda32007-08-01 03:59:32 +00004030#line 1730 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004031 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004032 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004033 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4034 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004035 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004036 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004037
4038 // ConstExprs can exist in the body of a function, thus creating
4039 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004040 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004041 // symbol table instead of the module symbol table for the global symbol,
4042 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004043 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004044 //
4045 Function *SavedCurFn = CurFun.CurrentFunction;
4046 CurFun.CurrentFunction = 0;
4047
David Greene718fda32007-08-01 03:59:32 +00004048 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004049 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004050
4051 CurFun.CurrentFunction = SavedCurFn;
4052
4053 // If this is an initializer for a constant pointer, which is referencing a
4054 // (currently) undefined variable, create a stub now that shall be replaced
4055 // in the future with the right type of variable.
4056 //
4057 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004058 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004059 const PointerType *PT = cast<PointerType>(Ty);
4060
4061 // First check to see if the forward references value is already created!
4062 PerModuleInfo::GlobalRefsType::iterator I =
David Greene718fda32007-08-01 03:59:32 +00004063 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004064
4065 if (I != CurModule.GlobalRefs.end()) {
4066 V = I->second; // Placeholder already exists, use it...
David Greene718fda32007-08-01 03:59:32 +00004067 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004068 } else {
4069 std::string Name;
David Greene718fda32007-08-01 03:59:32 +00004070 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
4071 Name = yyvsp[0].ValIDVal.getName();
4072 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004073 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004074
4075 // Create the forward referenced global.
4076 GlobalValue *GV;
4077 if (const FunctionType *FTy =
4078 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004079 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004080 CurModule.CurrentModule);
4081 } else {
4082 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004083 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004084 Name, CurModule.CurrentModule);
4085 }
4086
4087 // Keep track of the fact that we have a forward ref to recycle it
David Greene718fda32007-08-01 03:59:32 +00004088 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004089 V = GV;
4090 }
4091 }
4092
David Greene718fda32007-08-01 03:59:32 +00004093 yyval.ConstVal = cast<GlobalValue>(V);
4094 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004095 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004096 ;}
4097 break;
4098
Reid Spencer1013b4d2007-07-31 14:41:17 +00004099 case 167:
David Greene718fda32007-08-01 03:59:32 +00004100#line 1796 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004101 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004102 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004103 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4104 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004105 GEN_ERROR("Mismatched types for constant expression: " +
David Greene718fda32007-08-01 03:59:32 +00004106 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
4107 yyval.ConstVal = yyvsp[0].ConstVal;
4108 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004109 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004110 ;}
4111 break;
4112
Reid Spencer1013b4d2007-07-31 14:41:17 +00004113 case 168:
David Greene718fda32007-08-01 03:59:32 +00004114#line 1806 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004115 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004116 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004117 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4118 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004119 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4120 GEN_ERROR("Cannot create a null initialized value of this type");
David Greene718fda32007-08-01 03:59:32 +00004121 yyval.ConstVal = Constant::getNullValue(Ty);
4122 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004123 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004124 ;}
4125 break;
4126
Reid Spencer1013b4d2007-07-31 14:41:17 +00004127 case 169:
David Greene718fda32007-08-01 03:59:32 +00004128#line 1816 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004129 { // integral constants
David Greene718fda32007-08-01 03:59:32 +00004130 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004131 GEN_ERROR("Constant value doesn't fit in type");
David Greene718fda32007-08-01 03:59:32 +00004132 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004133 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004134 ;}
4135 break;
4136
Reid Spencer1013b4d2007-07-31 14:41:17 +00004137 case 170:
David Greene718fda32007-08-01 03:59:32 +00004138#line 1822 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004139 { // arbitrary precision integer constants
David Greene718fda32007-08-01 03:59:32 +00004140 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
4141 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004142 GEN_ERROR("Constant value does not fit in type");
4143 }
David Greene718fda32007-08-01 03:59:32 +00004144 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
4145 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
4146 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004147 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004148 ;}
4149 break;
4150
Reid Spencer1013b4d2007-07-31 14:41:17 +00004151 case 171:
David Greene718fda32007-08-01 03:59:32 +00004152#line 1832 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004153 { // integral constants
David Greene718fda32007-08-01 03:59:32 +00004154 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004155 GEN_ERROR("Constant value doesn't fit in type");
David Greene718fda32007-08-01 03:59:32 +00004156 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004157 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004158 ;}
4159 break;
4160
Reid Spencer1013b4d2007-07-31 14:41:17 +00004161 case 172:
David Greene718fda32007-08-01 03:59:32 +00004162#line 1838 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004163 { // arbitrary precision integer constants
David Greene718fda32007-08-01 03:59:32 +00004164 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
4165 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004166 GEN_ERROR("Constant value does not fit in type");
4167 }
David Greene718fda32007-08-01 03:59:32 +00004168 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
4169 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
4170 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004171 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004172 ;}
4173 break;
4174
Reid Spencer1013b4d2007-07-31 14:41:17 +00004175 case 173:
David Greene718fda32007-08-01 03:59:32 +00004176#line 1848 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004177 { // Boolean constants
David Greene718fda32007-08-01 03:59:32 +00004178 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
4179 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004180 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004181 ;}
4182 break;
4183
Reid Spencer1013b4d2007-07-31 14:41:17 +00004184 case 174:
David Greene718fda32007-08-01 03:59:32 +00004185#line 1853 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004186 { // Boolean constants
David Greene718fda32007-08-01 03:59:32 +00004187 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
4188 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004189 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004190 ;}
4191 break;
4192
Reid Spencer1013b4d2007-07-31 14:41:17 +00004193 case 175:
David Greene718fda32007-08-01 03:59:32 +00004194#line 1858 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004195 { // Float & Double constants
David Greene718fda32007-08-01 03:59:32 +00004196 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004197 GEN_ERROR("Floating point constant invalid for type");
David Greene718fda32007-08-01 03:59:32 +00004198 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004199 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004200 ;}
4201 break;
4202
Reid Spencer1013b4d2007-07-31 14:41:17 +00004203 case 176:
David Greene718fda32007-08-01 03:59:32 +00004204#line 1866 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004205 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004206 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004207 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4208 Constant *Val = yyvsp[-3].ConstVal;
4209 const Type *DestTy = yyvsp[-1].TypeVal->get();
4210 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004211 GEN_ERROR("invalid cast opcode for cast from '" +
4212 Val->getType()->getDescription() + "' to '" +
4213 DestTy->getDescription() + "'");
David Greene718fda32007-08-01 03:59:32 +00004214 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
4215 delete yyvsp[-1].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004216 ;}
4217 break;
4218
Reid Spencer1013b4d2007-07-31 14:41:17 +00004219 case 177:
David Greene718fda32007-08-01 03:59:32 +00004220#line 1878 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004221 {
David Greene718fda32007-08-01 03:59:32 +00004222 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004223 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004224
4225 const Type *IdxTy =
David Greene718fda32007-08-01 03:59:32 +00004226 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004227 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004228 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004229 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004230
Chris Lattnerf7469af2007-01-31 04:44:08 +00004231 SmallVector<Constant*, 8> IdxVec;
David Greene718fda32007-08-01 03:59:32 +00004232 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
4233 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004234 IdxVec.push_back(C);
4235 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004236 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004237
David Greene718fda32007-08-01 03:59:32 +00004238 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004239
David Greene718fda32007-08-01 03:59:32 +00004240 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004241 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004242 ;}
4243 break;
4244
Reid Spencer1013b4d2007-07-31 14:41:17 +00004245 case 178:
David Greene718fda32007-08-01 03:59:32 +00004246#line 1900 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004247 {
David Greene718fda32007-08-01 03:59:32 +00004248 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004249 GEN_ERROR("Select condition must be of boolean type");
David Greene718fda32007-08-01 03:59:32 +00004250 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004251 GEN_ERROR("Select operand types must match");
David Greene718fda32007-08-01 03:59:32 +00004252 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004253 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004254 ;}
4255 break;
4256
Reid Spencer1013b4d2007-07-31 14:41:17 +00004257 case 179:
David Greene718fda32007-08-01 03:59:32 +00004258#line 1908 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004259 {
David Greene718fda32007-08-01 03:59:32 +00004260 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004261 GEN_ERROR("Binary operator types must match");
4262 CHECK_FOR_ERROR;
David Greene718fda32007-08-01 03:59:32 +00004263 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004264 ;}
4265 break;
4266
Reid Spencer1013b4d2007-07-31 14:41:17 +00004267 case 180:
David Greene718fda32007-08-01 03:59:32 +00004268#line 1914 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004269 {
David Greene718fda32007-08-01 03:59:32 +00004270 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004271 GEN_ERROR("Logical operator types must match");
David Greene718fda32007-08-01 03:59:32 +00004272 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
4273 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
4274 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004275 GEN_ERROR("Logical operator requires integral operands");
4276 }
David Greene718fda32007-08-01 03:59:32 +00004277 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004278 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004279 ;}
4280 break;
4281
Reid Spencer1013b4d2007-07-31 14:41:17 +00004282 case 181:
David Greene718fda32007-08-01 03:59:32 +00004283#line 1925 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004284 {
David Greene718fda32007-08-01 03:59:32 +00004285 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004286 GEN_ERROR("icmp operand types must match");
David Greene718fda32007-08-01 03:59:32 +00004287 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004288 ;}
4289 break;
4290
Reid Spencer1013b4d2007-07-31 14:41:17 +00004291 case 182:
David Greene718fda32007-08-01 03:59:32 +00004292#line 1930 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004293 {
David Greene718fda32007-08-01 03:59:32 +00004294 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004295 GEN_ERROR("fcmp operand types must match");
David Greene718fda32007-08-01 03:59:32 +00004296 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004297 ;}
4298 break;
4299
Reid Spencer1013b4d2007-07-31 14:41:17 +00004300 case 183:
David Greene718fda32007-08-01 03:59:32 +00004301#line 1935 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004302 {
David Greene718fda32007-08-01 03:59:32 +00004303 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004304 GEN_ERROR("Invalid extractelement operands");
David Greene718fda32007-08-01 03:59:32 +00004305 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004306 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004307 ;}
4308 break;
4309
Reid Spencer1013b4d2007-07-31 14:41:17 +00004310 case 184:
David Greene718fda32007-08-01 03:59:32 +00004311#line 1941 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004312 {
David Greene718fda32007-08-01 03:59:32 +00004313 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004314 GEN_ERROR("Invalid insertelement operands");
David Greene718fda32007-08-01 03:59:32 +00004315 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004316 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004317 ;}
4318 break;
4319
Reid Spencer1013b4d2007-07-31 14:41:17 +00004320 case 185:
David Greene718fda32007-08-01 03:59:32 +00004321#line 1947 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004322 {
David Greene718fda32007-08-01 03:59:32 +00004323 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004324 GEN_ERROR("Invalid shufflevector operands");
David Greene718fda32007-08-01 03:59:32 +00004325 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004326 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004327 ;}
4328 break;
4329
Reid Spencer1013b4d2007-07-31 14:41:17 +00004330 case 186:
David Greene718fda32007-08-01 03:59:32 +00004331#line 1956 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004332 {
David Greene718fda32007-08-01 03:59:32 +00004333 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004334 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004335 ;}
4336 break;
4337
Reid Spencer1013b4d2007-07-31 14:41:17 +00004338 case 187:
David Greene718fda32007-08-01 03:59:32 +00004339#line 1960 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004340 {
David Greene718fda32007-08-01 03:59:32 +00004341 yyval.ConstVector = new std::vector<Constant*>();
4342 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004343 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004344 ;}
4345 break;
4346
Reid Spencer1013b4d2007-07-31 14:41:17 +00004347 case 188:
David Greene718fda32007-08-01 03:59:32 +00004348#line 1968 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4349 { yyval.BoolVal = false; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00004350 break;
4351
Reid Spencer1013b4d2007-07-31 14:41:17 +00004352 case 189:
David Greene718fda32007-08-01 03:59:32 +00004353#line 1968 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4354 { yyval.BoolVal = true; ;}
Reid Spencer1013b4d2007-07-31 14:41:17 +00004355 break;
4356
Reid Spencerb8f85052007-07-31 03:50:36 +00004357 case 190:
David Greene718fda32007-08-01 03:59:32 +00004358#line 1971 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4359 { yyval.BoolVal = true; ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00004360 break;
4361
4362 case 191:
David Greene718fda32007-08-01 03:59:32 +00004363#line 1971 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4364 { yyval.BoolVal = false; ;}
Reid Spenceree0142e2007-07-31 06:37:43 +00004365 break;
4366
Reid Spencer1013b4d2007-07-31 14:41:17 +00004367 case 192:
David Greene718fda32007-08-01 03:59:32 +00004368#line 1974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004369 {
David Greene718fda32007-08-01 03:59:32 +00004370 const Type* VTy = yyvsp[-1].TypeVal->get();
4371 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004372 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4373 if (!Aliasee)
4374 GEN_ERROR("Aliases can be created only to global values");
4375
David Greene718fda32007-08-01 03:59:32 +00004376 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004377 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004378 delete yyvsp[-1].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004379 ;}
4380 break;
4381
Reid Spencer1013b4d2007-07-31 14:41:17 +00004382 case 193:
David Greene718fda32007-08-01 03:59:32 +00004383#line 1985 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004384 {
David Greene718fda32007-08-01 03:59:32 +00004385 Constant *Val = yyvsp[-3].ConstVal;
4386 const Type *DestTy = yyvsp[-1].TypeVal->get();
4387 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004388 GEN_ERROR("invalid cast opcode for cast from '" +
4389 Val->getType()->getDescription() + "' to '" +
4390 DestTy->getDescription() + "'");
4391
David Greene718fda32007-08-01 03:59:32 +00004392 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004393 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004394 delete yyvsp[-1].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004395 ;}
4396 break;
4397
Reid Spencer1013b4d2007-07-31 14:41:17 +00004398 case 194:
David Greene718fda32007-08-01 03:59:32 +00004399#line 2006 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1013b4d2007-07-31 14:41:17 +00004400 {
David Greene718fda32007-08-01 03:59:32 +00004401 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004402 CurModule.ModuleDone();
4403 CHECK_FOR_ERROR;
4404 ;}
4405 break;
4406
Reid Spencerb8f85052007-07-31 03:50:36 +00004407 case 195:
David Greene718fda32007-08-01 03:59:32 +00004408#line 2011 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004409 {
David Greene718fda32007-08-01 03:59:32 +00004410 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004411 CurModule.ModuleDone();
4412 CHECK_FOR_ERROR;
Reid Spencerb8f85052007-07-31 03:50:36 +00004413 ;}
4414 break;
4415
Reid Spencer1013b4d2007-07-31 14:41:17 +00004416 case 198:
David Greene718fda32007-08-01 03:59:32 +00004417#line 2024 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spenceree0142e2007-07-31 06:37:43 +00004418 { CurFun.isDeclare = false; ;}
4419 break;
4420
Reid Spencer1013b4d2007-07-31 14:41:17 +00004421 case 199:
David Greene718fda32007-08-01 03:59:32 +00004422#line 2024 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004423 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004424 CurFun.FunctionDone();
4425 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004426 ;}
4427 break;
4428
Reid Spencer1013b4d2007-07-31 14:41:17 +00004429 case 200:
David Greene718fda32007-08-01 03:59:32 +00004430#line 2028 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004431 { CurFun.isDeclare = true; ;}
4432 break;
4433
Reid Spencer1013b4d2007-07-31 14:41:17 +00004434 case 201:
David Greene718fda32007-08-01 03:59:32 +00004435#line 2028 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1013b4d2007-07-31 14:41:17 +00004436 {
4437 CHECK_FOR_ERROR
4438 ;}
4439 break;
4440
Reid Spencerb8f85052007-07-31 03:50:36 +00004441 case 202:
David Greene718fda32007-08-01 03:59:32 +00004442#line 2031 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004443 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004444 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004445 ;}
4446 break;
4447
4448 case 203:
David Greene718fda32007-08-01 03:59:32 +00004449#line 2034 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004450 {
Reid Spencer14310612006-12-31 05:40:51 +00004451 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004452 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004453 // Eagerly resolve types. This is not an optimization, this is a
4454 // requirement that is due to the fact that we could have this:
4455 //
4456 // %list = type { %list * }
4457 // %list = type { %list * } ; repeated type decl
4458 //
4459 // If types are not resolved eagerly, then the two types will not be
4460 // determined to be the same type!
4461 //
David Greene718fda32007-08-01 03:59:32 +00004462 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004463
David Greene718fda32007-08-01 03:59:32 +00004464 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004465 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004466 // If this is a named type that is not a redefinition, add it to the slot
4467 // table.
David Greene718fda32007-08-01 03:59:32 +00004468 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004469 }
Reid Spencera132e042006-12-03 05:46:11 +00004470
David Greene718fda32007-08-01 03:59:32 +00004471 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004472 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004473 ;}
4474 break;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004475
Reid Spencer1013b4d2007-07-31 14:41:17 +00004476 case 204:
David Greene718fda32007-08-01 03:59:32 +00004477#line 2058 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004478 {
David Greene718fda32007-08-01 03:59:32 +00004479 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00004480
David Greene718fda32007-08-01 03:59:32 +00004481 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004482 CHECK_FOR_ERROR
4483 // If this is a named type that is not a redefinition, add it to the slot
4484 // table.
David Greene718fda32007-08-01 03:59:32 +00004485 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004486 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004487 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004488 ;}
4489 break;
4490
Reid Spencer1013b4d2007-07-31 14:41:17 +00004491 case 205:
David Greene718fda32007-08-01 03:59:32 +00004492#line 2069 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004493 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004494 /* "Externally Visible" Linkage */
David Greene718fda32007-08-01 03:59:32 +00004495 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004496 GEN_ERROR("Global value initializer is not a constant");
David Greene718fda32007-08-01 03:59:32 +00004497 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
4498 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004499 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004500 ;}
4501 break;
4502
Reid Spencer1013b4d2007-07-31 14:41:17 +00004503 case 206:
David Greene718fda32007-08-01 03:59:32 +00004504#line 2076 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004505 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004506 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004507 ;}
4508 break;
4509
Reid Spencer1013b4d2007-07-31 14:41:17 +00004510 case 207:
David Greene718fda32007-08-01 03:59:32 +00004511#line 2080 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004512 {
David Greene718fda32007-08-01 03:59:32 +00004513 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004514 GEN_ERROR("Global value initializer is not a constant");
David Greene718fda32007-08-01 03:59:32 +00004515 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 +00004516 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004517 ;}
4518 break;
4519
Reid Spencer1013b4d2007-07-31 14:41:17 +00004520 case 208:
David Greene718fda32007-08-01 03:59:32 +00004521#line 2085 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004522 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004523 CurGV = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00004524 ;}
4525 break;
4526
Reid Spencer1013b4d2007-07-31 14:41:17 +00004527 case 209:
David Greene718fda32007-08-01 03:59:32 +00004528#line 2089 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004529 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004530 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004531 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4532 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 +00004533 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004534 delete yyvsp[0].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004535 ;}
4536 break;
4537
Reid Spencer1013b4d2007-07-31 14:41:17 +00004538 case 210:
David Greene718fda32007-08-01 03:59:32 +00004539#line 2095 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004540 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004541 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004542 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004543 ;}
4544 break;
4545
Reid Spencer1013b4d2007-07-31 14:41:17 +00004546 case 211:
David Greene718fda32007-08-01 03:59:32 +00004547#line 2099 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004548 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004549 std::string Name;
David Greene718fda32007-08-01 03:59:32 +00004550 if (yyvsp[-4].StrVal) {
4551 Name = *yyvsp[-4].StrVal;
4552 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004553 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004554 if (Name.empty())
4555 GEN_ERROR("Alias name cannot be empty");
4556
David Greene718fda32007-08-01 03:59:32 +00004557 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004558 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004559 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004560
David Greene718fda32007-08-01 03:59:32 +00004561 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004562 CurModule.CurrentModule);
David Greene718fda32007-08-01 03:59:32 +00004563 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004564 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004565 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004566 ;}
4567 break;
4568
Reid Spencer1013b4d2007-07-31 14:41:17 +00004569 case 212:
David Greene718fda32007-08-01 03:59:32 +00004570#line 2118 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004571 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004572 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004573 ;}
4574 break;
4575
Reid Spencer1013b4d2007-07-31 14:41:17 +00004576 case 213:
David Greene718fda32007-08-01 03:59:32 +00004577#line 2121 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004578 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004579 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004580 ;}
4581 break;
4582
Reid Spencer1013b4d2007-07-31 14:41:17 +00004583 case 214:
David Greene718fda32007-08-01 03:59:32 +00004584#line 2127 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004585 {
Chris Lattner66316012006-01-24 04:14:29 +00004586 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00004587 if (AsmSoFar.empty())
David Greene718fda32007-08-01 03:59:32 +00004588 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00004589 else
David Greene718fda32007-08-01 03:59:32 +00004590 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
4591 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004592 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004593;}
4594 break;
4595
Reid Spencer1013b4d2007-07-31 14:41:17 +00004596 case 215:
David Greene718fda32007-08-01 03:59:32 +00004597#line 2137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004598 {
David Greene718fda32007-08-01 03:59:32 +00004599 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
4600 delete yyvsp[0].StrVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004601 ;}
4602 break;
4603
Reid Spencer1013b4d2007-07-31 14:41:17 +00004604 case 216:
David Greene718fda32007-08-01 03:59:32 +00004605#line 2141 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004606 {
David Greene718fda32007-08-01 03:59:32 +00004607 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
4608 delete yyvsp[0].StrVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00004609 ;}
4610 break;
4611
Reid Spencer1013b4d2007-07-31 14:41:17 +00004612 case 218:
David Greene718fda32007-08-01 03:59:32 +00004613#line 2148 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1013b4d2007-07-31 14:41:17 +00004614 {
David Greene718fda32007-08-01 03:59:32 +00004615 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4616 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004617 CHECK_FOR_ERROR
4618 ;}
4619 break;
4620
Reid Spencerb8f85052007-07-31 03:50:36 +00004621 case 219:
David Greene718fda32007-08-01 03:59:32 +00004622#line 2153 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004623 {
David Greene718fda32007-08-01 03:59:32 +00004624 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4625 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004626 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004627 ;}
4628 break;
4629
4630 case 220:
David Greene718fda32007-08-01 03:59:32 +00004631#line 2158 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004632 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004633 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004634 ;}
4635 break;
4636
4637 case 221:
David Greene718fda32007-08-01 03:59:32 +00004638#line 2167 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004639 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004640 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004641 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4642 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004643 GEN_ERROR("void typed arguments are invalid");
David Greene718fda32007-08-01 03:59:32 +00004644 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4645 yyval.ArgList = yyvsp[-4].ArgList;
4646 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004647 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004648 ;}
4649 break;
4650
Reid Spencer1013b4d2007-07-31 14:41:17 +00004651 case 222:
David Greene718fda32007-08-01 03:59:32 +00004652#line 2177 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004653 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004654 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004655 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4656 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004657 GEN_ERROR("void typed arguments are invalid");
David Greene718fda32007-08-01 03:59:32 +00004658 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4659 yyval.ArgList = new ArgListType;
4660 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004661 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004662 ;}
4663 break;
4664
Reid Spencer1013b4d2007-07-31 14:41:17 +00004665 case 223:
David Greene718fda32007-08-01 03:59:32 +00004666#line 2188 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004667 {
David Greene718fda32007-08-01 03:59:32 +00004668 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004669 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004670 ;}
4671 break;
4672
Reid Spencer1013b4d2007-07-31 14:41:17 +00004673 case 224:
David Greene718fda32007-08-01 03:59:32 +00004674#line 2192 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004675 {
David Greene718fda32007-08-01 03:59:32 +00004676 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004677 struct ArgListEntry E;
4678 E.Ty = new PATypeHolder(Type::VoidTy);
4679 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004680 E.Attrs = ParamAttr::None;
David Greene718fda32007-08-01 03:59:32 +00004681 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004682 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004683 ;}
4684 break;
4685
Reid Spencer1013b4d2007-07-31 14:41:17 +00004686 case 225:
David Greene718fda32007-08-01 03:59:32 +00004687#line 2201 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004688 {
David Greene718fda32007-08-01 03:59:32 +00004689 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004690 struct ArgListEntry E;
4691 E.Ty = new PATypeHolder(Type::VoidTy);
4692 E.Name = 0;
4693 E.Attrs = ParamAttr::None;
David Greene718fda32007-08-01 03:59:32 +00004694 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004695 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004696 ;}
4697 break;
4698
Reid Spencer1013b4d2007-07-31 14:41:17 +00004699 case 226:
David Greene718fda32007-08-01 03:59:32 +00004700#line 2210 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004701 {
David Greene718fda32007-08-01 03:59:32 +00004702 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004703 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004704 ;}
4705 break;
4706
Reid Spencer1013b4d2007-07-31 14:41:17 +00004707 case 227:
David Greene718fda32007-08-01 03:59:32 +00004708#line 2216 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004709 {
David Greene718fda32007-08-01 03:59:32 +00004710 std::string FunctionName(*yyvsp[-6].StrVal);
4711 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004712
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004713 // Check the function result for abstractness if this is a define. We should
4714 // have no abstract types at this point
David Greene718fda32007-08-01 03:59:32 +00004715 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4716 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004717
Reid Spencer68a24bd2005-08-27 18:50:39 +00004718 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004719 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00004720 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4721 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004722 Attrs.push_back(PAWI);
4723 }
David Greene718fda32007-08-01 03:59:32 +00004724 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004725 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00004726 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004727 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004728 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4729 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004730 ParamTypeList.push_back(Ty);
4731 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004732 if (I->Attrs != ParamAttr::None) {
4733 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4734 Attrs.push_back(PAWI);
4735 }
Reid Spencer14310612006-12-31 05:40:51 +00004736 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004737 }
4738
4739 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4740 if (isVarArg) ParamTypeList.pop_back();
4741
Christopher Lamb5c104242007-04-22 20:09:11 +00004742 ParamAttrsList *PAL = 0;
4743 if (!Attrs.empty())
4744 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004745
David Greene718fda32007-08-01 03:59:32 +00004746 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004747 const PointerType *PFT = PointerType::get(FT);
David Greene718fda32007-08-01 03:59:32 +00004748 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004749
4750 ValID ID;
4751 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004752 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004753 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004754 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004755 }
4756
4757 Function *Fn = 0;
4758 // See if this function was forward referenced. If so, recycle the object.
4759 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4760 // Move the function to the end of the list, from whereever it was
4761 // previously inserted.
4762 Fn = cast<Function>(FWRef);
4763 CurModule.CurrentModule->getFunctionList().remove(Fn);
4764 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4765 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004766 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004767 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004768 // The existing function doesn't have the same type. This is an overload
4769 // error.
4770 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4771 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004772 // Neither the existing or the current function is a declaration and they
4773 // have the same name and same type. Clearly this is a redefinition.
4774 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004775 } if (Fn->isDeclaration()) {
4776 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004777 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4778 AI != AE; ++AI)
4779 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004780 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004781 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004782 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004783 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004784
Reid Spencer68a24bd2005-08-27 18:50:39 +00004785 InsertValue(Fn, CurModule.Values);
4786 }
4787
4788 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004789
4790 if (CurFun.isDeclare) {
4791 // If we have declaration, always overwrite linkage. This will allow us to
4792 // correctly handle cases, when pointer to function is passed as argument to
4793 // another function.
4794 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004795 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004796 }
David Greene718fda32007-08-01 03:59:32 +00004797 Fn->setCallingConv(yyvsp[-8].UIntVal);
4798 Fn->setAlignment(yyvsp[0].UIntVal);
4799 if (yyvsp[-1].StrVal) {
4800 Fn->setSection(*yyvsp[-1].StrVal);
4801 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004802 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004803
4804 // Add all of the arguments we parsed to the function...
David Greene718fda32007-08-01 03:59:32 +00004805 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004806 if (isVarArg) { // Nuke the last entry
David Greene718fda32007-08-01 03:59:32 +00004807 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004808 "Not a varargs marker!");
David Greene718fda32007-08-01 03:59:32 +00004809 delete yyvsp[-4].ArgList->back().Ty;
4810 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004811 }
4812 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004813 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004814 unsigned Idx = 1;
David Greene718fda32007-08-01 03:59:32 +00004815 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4816 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004817 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004818 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004819 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004820 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004821 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004822 }
Reid Spencera132e042006-12-03 05:46:11 +00004823
David Greene718fda32007-08-01 03:59:32 +00004824 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004826 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004827;}
4828 break;
4829
Reid Spencer1013b4d2007-07-31 14:41:17 +00004830 case 230:
David Greene718fda32007-08-01 03:59:32 +00004831#line 2338 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004832 {
David Greene718fda32007-08-01 03:59:32 +00004833 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004834
4835 // Make sure that we keep track of the linkage type even if there was a
4836 // previous "declare".
David Greene718fda32007-08-01 03:59:32 +00004837 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4838 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
Reid Spencerb8f85052007-07-31 03:50:36 +00004839;}
4840 break;
4841
Reid Spencer1013b4d2007-07-31 14:41:17 +00004842 case 233:
David Greene718fda32007-08-01 03:59:32 +00004843#line 2349 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004844 {
David Greene718fda32007-08-01 03:59:32 +00004845 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004846 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004847;}
4848 break;
4849
Reid Spencer1013b4d2007-07-31 14:41:17 +00004850 case 234:
David Greene718fda32007-08-01 03:59:32 +00004851#line 2354 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004852 {
David Greene718fda32007-08-01 03:59:32 +00004853 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4854 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4855 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004856 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004857 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004858 ;}
4859 break;
4860
Reid Spencer1013b4d2007-07-31 14:41:17 +00004861 case 235:
David Greene718fda32007-08-01 03:59:32 +00004862#line 2366 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004863 {
David Greene718fda32007-08-01 03:59:32 +00004864 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004865 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004866 ;}
4867 break;
4868
Reid Spencer1013b4d2007-07-31 14:41:17 +00004869 case 236:
David Greene718fda32007-08-01 03:59:32 +00004870#line 2370 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004871 {
David Greene718fda32007-08-01 03:59:32 +00004872 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004873 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004874 ;}
4875 break;
4876
Reid Spencer1013b4d2007-07-31 14:41:17 +00004877 case 237:
David Greene718fda32007-08-01 03:59:32 +00004878#line 2375 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004879 { // A reference to a direct constant
David Greene718fda32007-08-01 03:59:32 +00004880 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004881 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004882 ;}
4883 break;
4884
Reid Spencer1013b4d2007-07-31 14:41:17 +00004885 case 238:
David Greene718fda32007-08-01 03:59:32 +00004886#line 2379 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004887 {
David Greene718fda32007-08-01 03:59:32 +00004888 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004889 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004890 ;}
4891 break;
4892
Reid Spencer1013b4d2007-07-31 14:41:17 +00004893 case 239:
David Greene718fda32007-08-01 03:59:32 +00004894#line 2383 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004895 { // Perhaps it's an FP constant?
David Greene718fda32007-08-01 03:59:32 +00004896 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004897 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004898 ;}
4899 break;
4900
Reid Spencer1013b4d2007-07-31 14:41:17 +00004901 case 240:
David Greene718fda32007-08-01 03:59:32 +00004902#line 2387 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004903 {
David Greene718fda32007-08-01 03:59:32 +00004904 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004905 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004906 ;}
4907 break;
4908
Reid Spencer1013b4d2007-07-31 14:41:17 +00004909 case 241:
David Greene718fda32007-08-01 03:59:32 +00004910#line 2391 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004911 {
David Greene718fda32007-08-01 03:59:32 +00004912 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004913 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004914 ;}
4915 break;
4916
Reid Spencer1013b4d2007-07-31 14:41:17 +00004917 case 242:
David Greene718fda32007-08-01 03:59:32 +00004918#line 2395 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004919 {
David Greene718fda32007-08-01 03:59:32 +00004920 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004921 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004922 ;}
4923 break;
4924
Reid Spencer1013b4d2007-07-31 14:41:17 +00004925 case 243:
David Greene718fda32007-08-01 03:59:32 +00004926#line 2399 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004927 {
David Greene718fda32007-08-01 03:59:32 +00004928 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004929 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004930 ;}
4931 break;
4932
Reid Spencer1013b4d2007-07-31 14:41:17 +00004933 case 244:
David Greene718fda32007-08-01 03:59:32 +00004934#line 2403 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004935 { // A vector zero constant.
David Greene718fda32007-08-01 03:59:32 +00004936 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004937 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004938 ;}
4939 break;
4940
Reid Spencer1013b4d2007-07-31 14:41:17 +00004941 case 245:
David Greene718fda32007-08-01 03:59:32 +00004942#line 2407 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004943 { // Nonempty unsized packed vector
David Greene718fda32007-08-01 03:59:32 +00004944 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4945 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004946
Reid Spencer9d6565a2007-02-15 02:26:10 +00004947 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004948 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004949 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004950 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004951 ETy,
4952 NumElements)
4953 )
4954 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004955
4956 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00004957 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4958 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004959 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004960 ETy->getDescription() +"' as required!\nIt is of type '" +
David Greene718fda32007-08-01 03:59:32 +00004961 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004962 }
4963
David Greene718fda32007-08-01 03:59:32 +00004964 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4965 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004966 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004967 ;}
4968 break;
4969
Reid Spencer1013b4d2007-07-31 14:41:17 +00004970 case 246:
David Greene718fda32007-08-01 03:59:32 +00004971#line 2432 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004972 {
David Greene718fda32007-08-01 03:59:32 +00004973 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004974 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004975 ;}
4976 break;
4977
Reid Spencer1013b4d2007-07-31 14:41:17 +00004978 case 247:
David Greene718fda32007-08-01 03:59:32 +00004979#line 2436 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004980 {
David Greene718fda32007-08-01 03:59:32 +00004981 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4982 delete yyvsp[-2].StrVal;
4983 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004984 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004985 ;}
4986 break;
4987
Reid Spencer1013b4d2007-07-31 14:41:17 +00004988 case 248:
David Greene718fda32007-08-01 03:59:32 +00004989#line 2446 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004990 { // Is it an integer reference...?
David Greene718fda32007-08-01 03:59:32 +00004991 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004992 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00004993 ;}
4994 break;
4995
Reid Spencer1013b4d2007-07-31 14:41:17 +00004996 case 249:
David Greene718fda32007-08-01 03:59:32 +00004997#line 2450 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00004998 {
David Greene718fda32007-08-01 03:59:32 +00004999 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005000 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005001 ;}
5002 break;
5003
Reid Spencer1013b4d2007-07-31 14:41:17 +00005004 case 250:
David Greene718fda32007-08-01 03:59:32 +00005005#line 2454 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005006 { // Is it a named reference...?
David Greene718fda32007-08-01 03:59:32 +00005007 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
5008 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005009 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005010 ;}
5011 break;
5012
Reid Spencer1013b4d2007-07-31 14:41:17 +00005013 case 251:
David Greene718fda32007-08-01 03:59:32 +00005014#line 2459 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005015 { // Is it a named reference...?
David Greene718fda32007-08-01 03:59:32 +00005016 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
5017 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005018 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005019 ;}
5020 break;
5021
Reid Spencer1013b4d2007-07-31 14:41:17 +00005022 case 254:
David Greene718fda32007-08-01 03:59:32 +00005023#line 2472 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005024 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005025 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005026 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5027 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
5028 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005029 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005030 ;}
5031 break;
5032
Reid Spencer1013b4d2007-07-31 14:41:17 +00005033 case 255:
David Greene718fda32007-08-01 03:59:32 +00005034#line 2481 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005035 {
David Greene718fda32007-08-01 03:59:32 +00005036 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005037 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005038 ;}
5039 break;
5040
Reid Spencer1013b4d2007-07-31 14:41:17 +00005041 case 256:
David Greene718fda32007-08-01 03:59:32 +00005042#line 2485 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005043 { // Do not allow functions with 0 basic blocks
David Greene718fda32007-08-01 03:59:32 +00005044 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005045 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005046 ;}
5047 break;
5048
Reid Spencer1013b4d2007-07-31 14:41:17 +00005049 case 257:
David Greene718fda32007-08-01 03:59:32 +00005050#line 2494 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005051 {
David Greene718fda32007-08-01 03:59:32 +00005052 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005053 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005054 InsertValue(yyvsp[0].TermInstVal);
5055 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
5056 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005057 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005058 ;}
5059 break;
5060
Reid Spencer1013b4d2007-07-31 14:41:17 +00005061 case 258:
David Greene718fda32007-08-01 03:59:32 +00005062#line 2503 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005063 {
David Greene718fda32007-08-01 03:59:32 +00005064 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005065 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5066 if (CI2->getParent() == 0)
David Greene718fda32007-08-01 03:59:32 +00005067 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
5068 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
5069 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005070 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005071 ;}
5072 break;
5073
Reid Spencer1013b4d2007-07-31 14:41:17 +00005074 case 259:
David Greene718fda32007-08-01 03:59:32 +00005075#line 2512 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005076 { // Empty space between instruction lists
David Greene718fda32007-08-01 03:59:32 +00005077 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00005078 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005079 ;}
5080 break;
5081
Reid Spencer1013b4d2007-07-31 14:41:17 +00005082 case 260:
David Greene718fda32007-08-01 03:59:32 +00005083#line 2516 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005084 { // Labelled (named) basic block
David Greene718fda32007-08-01 03:59:32 +00005085 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
5086 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00005087 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005088
Reid Spencerb8f85052007-07-31 03:50:36 +00005089 ;}
5090 break;
Reid Spencered951ea2007-05-19 07:22:10 +00005091
Reid Spencer1013b4d2007-07-31 14:41:17 +00005092 case 261:
David Greene718fda32007-08-01 03:59:32 +00005093#line 2523 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005094 { // Return with a result...
David Greene718fda32007-08-01 03:59:32 +00005095 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005096 CHECK_FOR_ERROR
5097 ;}
5098 break;
5099
Reid Spencer1013b4d2007-07-31 14:41:17 +00005100 case 262:
David Greene718fda32007-08-01 03:59:32 +00005101#line 2527 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005102 { // Return with no result...
David Greene718fda32007-08-01 03:59:32 +00005103 yyval.TermInstVal = new ReturnInst();
Reid Spencerb8f85052007-07-31 03:50:36 +00005104 CHECK_FOR_ERROR
5105 ;}
5106 break;
5107
Reid Spencer1013b4d2007-07-31 14:41:17 +00005108 case 263:
David Greene718fda32007-08-01 03:59:32 +00005109#line 2531 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005110 { // Unconditional Branch...
David Greene718fda32007-08-01 03:59:32 +00005111 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005112 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005113 yyval.TermInstVal = new BranchInst(tmpBB);
Reid Spencerb8f85052007-07-31 03:50:36 +00005114 ;}
5115 break;
5116
Reid Spencer1013b4d2007-07-31 14:41:17 +00005117 case 264:
David Greene718fda32007-08-01 03:59:32 +00005118#line 2536 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005119 {
David Greene718fda32007-08-01 03:59:32 +00005120 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
5121 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005122 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005123 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005124 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005125 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005126 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005127 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005128 ;}
5129 break;
5130
Reid Spencer1013b4d2007-07-31 14:41:17 +00005131 case 265:
David Greene718fda32007-08-01 03:59:32 +00005132#line 2546 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005133 {
David Greene718fda32007-08-01 03:59:32 +00005134 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005135 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005136 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00005137 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005138 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
5139 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00005140
David Greene718fda32007-08-01 03:59:32 +00005141 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
5142 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005143 for (; I != E; ++I) {
5144 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5145 S->addCase(CI, I->second);
5146 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005147 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005148 }
David Greene718fda32007-08-01 03:59:32 +00005149 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00005150 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005151 ;}
5152 break;
5153
Reid Spencer1013b4d2007-07-31 14:41:17 +00005154 case 266:
David Greene718fda32007-08-01 03:59:32 +00005155#line 2565 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005156 {
David Greene718fda32007-08-01 03:59:32 +00005157 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005158 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005159 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005160 CHECK_FOR_ERROR
5161 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
David Greene718fda32007-08-01 03:59:32 +00005162 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005163 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005164 ;}
5165 break;
5166
Reid Spencer1013b4d2007-07-31 14:41:17 +00005167 case 267:
David Greene718fda32007-08-01 03:59:32 +00005168#line 2575 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005169 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005170
Reid Spencer14310612006-12-31 05:40:51 +00005171 // Handle the short syntax
5172 const PointerType *PFTy = 0;
5173 const FunctionType *Ty = 0;
David Greene718fda32007-08-01 03:59:32 +00005174 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005175 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5176 // Pull out the types of all of the arguments...
5177 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005178 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00005179 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
5180 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00005181 Attrs.push_back(PAWI);
5182 }
David Greene718fda32007-08-01 03:59:32 +00005183 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005184 unsigned index = 1;
5185 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005186 const Type *Ty = I->Val->getType();
5187 if (Ty == Type::VoidTy)
5188 GEN_ERROR("Short call syntax cannot be used with varargs");
5189 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005190 if (I->Attrs != ParamAttr::None) {
5191 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5192 Attrs.push_back(PAWI);
5193 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005194 }
5195
Christopher Lamb5c104242007-04-22 20:09:11 +00005196 ParamAttrsList *PAL = 0;
5197 if (!Attrs.empty())
5198 PAL = ParamAttrsList::get(Attrs);
David Greene718fda32007-08-01 03:59:32 +00005199 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005200 PFTy = PointerType::get(Ty);
5201 }
5202
David Greene718fda32007-08-01 03:59:32 +00005203 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00005204
David Greene718fda32007-08-01 03:59:32 +00005205 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005206 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005207 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005208 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005209 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005210 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005211
Reid Spencer14310612006-12-31 05:40:51 +00005212 // Check the arguments
5213 ValueList Args;
David Greene718fda32007-08-01 03:59:32 +00005214 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005215 // Make sure no arguments is a good thing!
5216 if (Ty->getNumParams() != 0)
5217 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005218 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005219 } else { // Has arguments?
5220 // Loop through FunctionType's arguments and ensure they are specified
5221 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005222 FunctionType::param_iterator I = Ty->param_begin();
5223 FunctionType::param_iterator E = Ty->param_end();
David Greene718fda32007-08-01 03:59:32 +00005224 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005225
Reid Spencer14310612006-12-31 05:40:51 +00005226 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5227 if (ArgI->Val->getType() != *I)
5228 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005229 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005230 Args.push_back(ArgI->Val);
5231 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005232
Reid Spencer14310612006-12-31 05:40:51 +00005233 if (Ty->isVarArg()) {
5234 if (I == E)
5235 for (; ArgI != ArgE; ++ArgI)
5236 Args.push_back(ArgI->Val); // push the remaining varargs
5237 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005238 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005239 }
Reid Spencer14310612006-12-31 05:40:51 +00005240
5241 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005242 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
David Greene718fda32007-08-01 03:59:32 +00005243 II->setCallingConv(yyvsp[-12].UIntVal);
5244 yyval.TermInstVal = II;
5245 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005246 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005247 ;}
5248 break;
5249
Reid Spencer1013b4d2007-07-31 14:41:17 +00005250 case 268:
David Greene718fda32007-08-01 03:59:32 +00005251#line 2654 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005252 {
David Greene718fda32007-08-01 03:59:32 +00005253 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005254 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005255 ;}
5256 break;
5257
Reid Spencer1013b4d2007-07-31 14:41:17 +00005258 case 269:
David Greene718fda32007-08-01 03:59:32 +00005259#line 2658 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005260 {
David Greene718fda32007-08-01 03:59:32 +00005261 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005262 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005263 ;}
5264 break;
5265
Reid Spencer1013b4d2007-07-31 14:41:17 +00005266 case 270:
David Greene718fda32007-08-01 03:59:32 +00005267#line 2665 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005268 {
David Greene718fda32007-08-01 03:59:32 +00005269 yyval.JumpTable = yyvsp[-5].JumpTable;
5270 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005271 CHECK_FOR_ERROR
5272 if (V == 0)
5273 GEN_ERROR("May only switch on a constant pool value");
5274
David Greene718fda32007-08-01 03:59:32 +00005275 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005276 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005277 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Reid Spencerb8f85052007-07-31 03:50:36 +00005278 ;}
5279 break;
5280
Reid Spencer1013b4d2007-07-31 14:41:17 +00005281 case 271:
David Greene718fda32007-08-01 03:59:32 +00005282#line 2676 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005283 {
David Greene718fda32007-08-01 03:59:32 +00005284 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
5285 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005286 CHECK_FOR_ERROR
5287
5288 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005289 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005290
David Greene718fda32007-08-01 03:59:32 +00005291 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005292 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005293 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Reid Spencerb8f85052007-07-31 03:50:36 +00005294 ;}
5295 break;
5296
Reid Spencer1013b4d2007-07-31 14:41:17 +00005297 case 272:
David Greene718fda32007-08-01 03:59:32 +00005298#line 2689 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005299 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005300 // Is this definition named?? if so, assign the name...
David Greene718fda32007-08-01 03:59:32 +00005301 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005302 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005303 InsertValue(yyvsp[0].InstVal);
5304 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005305 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005306 ;}
5307 break;
5308
Reid Spencer1013b4d2007-07-31 14:41:17 +00005309 case 273:
David Greene718fda32007-08-01 03:59:32 +00005310#line 2699 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005311 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005312 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005313 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
5314 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
5315 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005316 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005317 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005318 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005319 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
5320 delete yyvsp[-5].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005321 ;}
5322 break;
5323
Reid Spencer1013b4d2007-07-31 14:41:17 +00005324 case 274:
David Greene718fda32007-08-01 03:59:32 +00005325#line 2710 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005326 {
David Greene718fda32007-08-01 03:59:32 +00005327 yyval.PHIList = yyvsp[-6].PHIList;
5328 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005329 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005330 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005331 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005332 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencerb8f85052007-07-31 03:50:36 +00005333 ;}
5334 break;
5335
Reid Spencer1013b4d2007-07-31 14:41:17 +00005336 case 275:
David Greene718fda32007-08-01 03:59:32 +00005337#line 2720 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005338 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005339 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005340 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005341 // Used for call and invoke instructions
David Greene718fda32007-08-01 03:59:32 +00005342 yyval.ValueRefList = new ValueRefList();
5343 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
5344 yyval.ValueRefList->push_back(E);
5345 delete yyvsp[-2].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005346 ;}
5347 break;
5348
Reid Spencer1013b4d2007-07-31 14:41:17 +00005349 case 276:
David Greene718fda32007-08-01 03:59:32 +00005350#line 2729 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005351 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005352 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005353 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5354 yyval.ValueRefList = yyvsp[-4].ValueRefList;
5355 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
5356 yyval.ValueRefList->push_back(E);
5357 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005358 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005359 ;}
5360 break;
5361
Reid Spencer1013b4d2007-07-31 14:41:17 +00005362 case 277:
David Greene718fda32007-08-01 03:59:32 +00005363#line 2738 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5364 { yyval.ValueRefList = new ValueRefList(); ;}
Reid Spencerb8f85052007-07-31 03:50:36 +00005365 break;
5366
Reid Spencer1013b4d2007-07-31 14:41:17 +00005367 case 278:
David Greene718fda32007-08-01 03:59:32 +00005368#line 2741 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5369 { yyval.ValueList = new std::vector<Value*>(); ;}
Reid Spencer1013b4d2007-07-31 14:41:17 +00005370 break;
5371
Reid Spencerb8f85052007-07-31 03:50:36 +00005372 case 279:
David Greene718fda32007-08-01 03:59:32 +00005373#line 2742 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005374 {
David Greene718fda32007-08-01 03:59:32 +00005375 yyval.ValueList = yyvsp[-2].ValueList;
5376 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005377 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005378 ;}
5379 break;
5380
Reid Spencer1013b4d2007-07-31 14:41:17 +00005381 case 280:
David Greene718fda32007-08-01 03:59:32 +00005382#line 2749 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005383 {
David Greene718fda32007-08-01 03:59:32 +00005384 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005385 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005386 ;}
5387 break;
5388
Reid Spencer1013b4d2007-07-31 14:41:17 +00005389 case 281:
David Greene718fda32007-08-01 03:59:32 +00005390#line 2753 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005391 {
David Greene718fda32007-08-01 03:59:32 +00005392 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005393 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005394 ;}
5395 break;
5396
Reid Spencer1013b4d2007-07-31 14:41:17 +00005397 case 282:
David Greene718fda32007-08-01 03:59:32 +00005398#line 2758 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005399 {
Reid Spencer14310612006-12-31 05:40:51 +00005400 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005401 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5402 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
5403 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005404 GEN_ERROR(
5405 "Arithmetic operator requires integer, FP, or packed operands");
David Greene718fda32007-08-01 03:59:32 +00005406 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
5407 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
5408 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
5409 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005410 GEN_ERROR("Remainder not supported on vector types");
David Greene718fda32007-08-01 03:59:32 +00005411 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005412 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005413 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005414 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005415 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
5416 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005417 GEN_ERROR("binary operator returned null");
David Greene718fda32007-08-01 03:59:32 +00005418 delete yyvsp[-3].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005419 ;}
5420 break;
5421
Reid Spencer1013b4d2007-07-31 14:41:17 +00005422 case 283:
David Greene718fda32007-08-01 03:59:32 +00005423#line 2779 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005424 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005425 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005426 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5427 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
5428 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
5429 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005430 GEN_ERROR("Logical operator requires integral operands");
5431 }
David Greene718fda32007-08-01 03:59:32 +00005432 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005433 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005434 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005435 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005436 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
5437 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005438 GEN_ERROR("binary operator returned null");
David Greene718fda32007-08-01 03:59:32 +00005439 delete yyvsp[-3].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005440 ;}
5441 break;
5442
Reid Spencer1013b4d2007-07-31 14:41:17 +00005443 case 284:
David Greene718fda32007-08-01 03:59:32 +00005444#line 2796 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005445 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005446 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005447 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5448 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005449 GEN_ERROR("Vector types not supported by icmp instruction");
David Greene718fda32007-08-01 03:59:32 +00005450 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005451 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005452 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005453 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005454 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
5455 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005456 GEN_ERROR("icmp operator returned null");
David Greene718fda32007-08-01 03:59:32 +00005457 delete yyvsp[-3].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005458 ;}
5459 break;
5460
Reid Spencer1013b4d2007-07-31 14:41:17 +00005461 case 285:
David Greene718fda32007-08-01 03:59:32 +00005462#line 2810 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005463 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005464 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005465 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5466 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005467 GEN_ERROR("Vector types not supported by fcmp instruction");
David Greene718fda32007-08-01 03:59:32 +00005468 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005469 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005470 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005471 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005472 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
5473 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005474 GEN_ERROR("fcmp operator returned null");
David Greene718fda32007-08-01 03:59:32 +00005475 delete yyvsp[-3].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005476 ;}
5477 break;
5478
Reid Spencer1013b4d2007-07-31 14:41:17 +00005479 case 286:
David Greene718fda32007-08-01 03:59:32 +00005480#line 2824 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005481 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005482 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005483 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5484 Value* Val = yyvsp[-2].ValueVal;
5485 const Type* DestTy = yyvsp[0].TypeVal->get();
5486 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005487 GEN_ERROR("invalid cast opcode for cast from '" +
5488 Val->getType()->getDescription() + "' to '" +
5489 DestTy->getDescription() + "'");
David Greene718fda32007-08-01 03:59:32 +00005490 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
5491 delete yyvsp[0].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005492 ;}
5493 break;
5494
Reid Spencer1013b4d2007-07-31 14:41:17 +00005495 case 287:
David Greene718fda32007-08-01 03:59:32 +00005496#line 2836 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005497 {
David Greene718fda32007-08-01 03:59:32 +00005498 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005499 GEN_ERROR("select condition must be boolean");
David Greene718fda32007-08-01 03:59:32 +00005500 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005501 GEN_ERROR("select value types should match");
David Greene718fda32007-08-01 03:59:32 +00005502 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005503 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005504 ;}
5505 break;
5506
Reid Spencer1013b4d2007-07-31 14:41:17 +00005507 case 288:
David Greene718fda32007-08-01 03:59:32 +00005508#line 2844 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005509 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005510 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005511 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5512 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
5513 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005514 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005515 ;}
5516 break;
5517
Reid Spencer1013b4d2007-07-31 14:41:17 +00005518 case 289:
David Greene718fda32007-08-01 03:59:32 +00005519#line 2851 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005520 {
David Greene718fda32007-08-01 03:59:32 +00005521 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005522 GEN_ERROR("Invalid extractelement operands");
David Greene718fda32007-08-01 03:59:32 +00005523 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005524 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005525 ;}
5526 break;
5527
Reid Spencer1013b4d2007-07-31 14:41:17 +00005528 case 290:
David Greene718fda32007-08-01 03:59:32 +00005529#line 2857 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005530 {
David Greene718fda32007-08-01 03:59:32 +00005531 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005532 GEN_ERROR("Invalid insertelement operands");
David Greene718fda32007-08-01 03:59:32 +00005533 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005534 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005535 ;}
5536 break;
5537
Reid Spencer1013b4d2007-07-31 14:41:17 +00005538 case 291:
David Greene718fda32007-08-01 03:59:32 +00005539#line 2863 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005540 {
David Greene718fda32007-08-01 03:59:32 +00005541 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005542 GEN_ERROR("Invalid shufflevector operands");
David Greene718fda32007-08-01 03:59:32 +00005543 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005544 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005545 ;}
5546 break;
5547
Reid Spencer1013b4d2007-07-31 14:41:17 +00005548 case 292:
David Greene718fda32007-08-01 03:59:32 +00005549#line 2869 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005550 {
David Greene718fda32007-08-01 03:59:32 +00005551 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005552 if (!Ty->isFirstClassType())
5553 GEN_ERROR("PHI node operands must be of first class type");
David Greene718fda32007-08-01 03:59:32 +00005554 yyval.InstVal = new PHINode(Ty);
5555 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
5556 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
5557 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005558 GEN_ERROR("All elements of a PHI node must be of the same type");
David Greene718fda32007-08-01 03:59:32 +00005559 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
5560 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005561 }
David Greene718fda32007-08-01 03:59:32 +00005562 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005563 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005564 ;}
5565 break;
5566
Reid Spencer1013b4d2007-07-31 14:41:17 +00005567 case 293:
David Greene718fda32007-08-01 03:59:32 +00005568#line 2885 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005569 {
Reid Spencer14310612006-12-31 05:40:51 +00005570
5571 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005572 const PointerType *PFTy = 0;
5573 const FunctionType *Ty = 0;
David Greene718fda32007-08-01 03:59:32 +00005574 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005575 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5576 // Pull out the types of all of the arguments...
5577 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005578 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00005579 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
5580 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00005581 Attrs.push_back(PAWI);
5582 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005583 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00005584 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005585 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005586 const Type *Ty = I->Val->getType();
5587 if (Ty == Type::VoidTy)
5588 GEN_ERROR("Short call syntax cannot be used with varargs");
5589 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005590 if (I->Attrs != ParamAttr::None) {
5591 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5592 Attrs.push_back(PAWI);
5593 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005594 }
5595
Christopher Lamb5c104242007-04-22 20:09:11 +00005596 ParamAttrsList *PAL = 0;
5597 if (!Attrs.empty())
5598 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005599
David Greene718fda32007-08-01 03:59:32 +00005600 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005601 PFTy = PointerType::get(Ty);
5602 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005603
David Greene718fda32007-08-01 03:59:32 +00005604 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005605 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005606
Reid Spencer7780acb2007-04-16 06:56:07 +00005607 // Check for call to invalid intrinsic to avoid crashing later.
5608 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005609 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005610 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5611 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005612 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5613 theF->getName() + "'");
5614 }
5615
Reid Spencer14310612006-12-31 05:40:51 +00005616 // Check the arguments
5617 ValueList Args;
David Greene718fda32007-08-01 03:59:32 +00005618 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005619 // Make sure no arguments is a good thing!
5620 if (Ty->getNumParams() != 0)
5621 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005622 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005623 } else { // Has arguments?
5624 // Loop through FunctionType's arguments and ensure they are specified
5625 // correctly!
5626 //
5627 FunctionType::param_iterator I = Ty->param_begin();
5628 FunctionType::param_iterator E = Ty->param_end();
David Greene718fda32007-08-01 03:59:32 +00005629 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005630
Reid Spencer14310612006-12-31 05:40:51 +00005631 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5632 if (ArgI->Val->getType() != *I)
5633 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005634 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005635 Args.push_back(ArgI->Val);
5636 }
5637 if (Ty->isVarArg()) {
5638 if (I == E)
5639 for (; ArgI != ArgE; ++ArgI)
5640 Args.push_back(ArgI->Val); // push the remaining varargs
5641 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005642 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005643 }
Reid Spencer14310612006-12-31 05:40:51 +00005644 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00005645 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
5646 CI->setTailCall(yyvsp[-7].BoolVal);
5647 CI->setCallingConv(yyvsp[-6].UIntVal);
5648 yyval.InstVal = CI;
5649 delete yyvsp[-2].ValueRefList;
5650 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005651 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005652 ;}
5653 break;
5654
Reid Spencer1013b4d2007-07-31 14:41:17 +00005655 case 294:
David Greene718fda32007-08-01 03:59:32 +00005656#line 2969 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005657 {
David Greene718fda32007-08-01 03:59:32 +00005658 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005659 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005660 ;}
5661 break;
5662
Reid Spencer1013b4d2007-07-31 14:41:17 +00005663 case 295:
David Greene718fda32007-08-01 03:59:32 +00005664#line 2974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005665 {
David Greene718fda32007-08-01 03:59:32 +00005666 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005667 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005668 ;}
5669 break;
5670
Reid Spencer1013b4d2007-07-31 14:41:17 +00005671 case 296:
David Greene718fda32007-08-01 03:59:32 +00005672#line 2978 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005673 {
David Greene718fda32007-08-01 03:59:32 +00005674 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005675 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005676 ;}
5677 break;
5678
Reid Spencer1013b4d2007-07-31 14:41:17 +00005679 case 297:
David Greene718fda32007-08-01 03:59:32 +00005680#line 2985 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005681 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005682 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005683 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5684 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5685 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005686 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005687 ;}
5688 break;
5689
Reid Spencer1013b4d2007-07-31 14:41:17 +00005690 case 298:
David Greene718fda32007-08-01 03:59:32 +00005691#line 2992 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005692 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005693 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005694 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5695 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005696 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005697 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5698 delete yyvsp[-4].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005699 ;}
5700 break;
5701
Reid Spencer1013b4d2007-07-31 14:41:17 +00005702 case 299:
David Greene718fda32007-08-01 03:59:32 +00005703#line 3000 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005704 {
Reid Spencer14310612006-12-31 05:40:51 +00005705 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005706 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5707 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5708 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005709 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005710 ;}
5711 break;
5712
Reid Spencer1013b4d2007-07-31 14:41:17 +00005713 case 300:
David Greene718fda32007-08-01 03:59:32 +00005714#line 3007 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005715 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005716 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005717 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5718 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005719 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005720 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5721 delete yyvsp[-4].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005722 ;}
5723 break;
5724
Reid Spencer1013b4d2007-07-31 14:41:17 +00005725 case 301:
David Greene718fda32007-08-01 03:59:32 +00005726#line 3015 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005727 {
David Greene718fda32007-08-01 03:59:32 +00005728 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005729 GEN_ERROR("Trying to free nonpointer type " +
David Greene718fda32007-08-01 03:59:32 +00005730 yyvsp[0].ValueVal->getType()->getDescription() + "");
5731 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005732 CHECK_FOR_ERROR
Reid Spencerb8f85052007-07-31 03:50:36 +00005733 ;}
5734 break;
5735
Reid Spencer1013b4d2007-07-31 14:41:17 +00005736 case 302:
David Greene718fda32007-08-01 03:59:32 +00005737#line 3023 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005738 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005739 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005740 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5741 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005742 GEN_ERROR("Can't load from nonpointer type: " +
David Greene718fda32007-08-01 03:59:32 +00005743 (*yyvsp[-2].TypeVal)->getDescription());
5744 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005745 GEN_ERROR("Can't load from pointer of non-first-class type: " +
David Greene718fda32007-08-01 03:59:32 +00005746 (*yyvsp[-2].TypeVal)->getDescription());
5747 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005748 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005749 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5750 delete yyvsp[-2].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005751 ;}
5752 break;
5753
Reid Spencer1013b4d2007-07-31 14:41:17 +00005754 case 303:
David Greene718fda32007-08-01 03:59:32 +00005755#line 3037 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005756 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005757 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005758 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5759 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005760 if (!PT)
5761 GEN_ERROR("Can't store to a nonpointer type: " +
David Greene718fda32007-08-01 03:59:32 +00005762 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005763 const Type *ElTy = PT->getElementType();
David Greene718fda32007-08-01 03:59:32 +00005764 if (ElTy != yyvsp[-4].ValueVal->getType())
5765 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005766 "' into space of type '" + ElTy->getDescription() + "'");
5767
David Greene718fda32007-08-01 03:59:32 +00005768 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005769 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005770 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5771 delete yyvsp[-2].TypeVal;
Reid Spencerb8f85052007-07-31 03:50:36 +00005772 ;}
5773 break;
5774
Reid Spencer1013b4d2007-07-31 14:41:17 +00005775 case 304:
David Greene718fda32007-08-01 03:59:32 +00005776#line 3054 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencerb8f85052007-07-31 03:50:36 +00005777 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005778 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005779 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5780 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005781 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005782
David Greene718fda32007-08-01 03:59:32 +00005783 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005784 GEN_ERROR("Invalid getelementptr indices for type '" +
David Greene718fda32007-08-01 03:59:32 +00005785 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5786 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005787 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005788 yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size());
5789 delete yyvsp[-2].TypeVal;
5790 delete yyvsp[0].ValueList;
Reid Spencerb8f85052007-07-31 03:50:36 +00005791 ;}
5792 break;
5793
5794
Reid Spencerb8f85052007-07-31 03:50:36 +00005795 }
5796
David Greene718fda32007-08-01 03:59:32 +00005797/* Line 993 of yacc.c. */
5798#line 5799 "llvmAsmParser.tab.c"
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005799
5800 yyvsp -= yylen;
5801 yyssp -= yylen;
Reid Spencer7780acb2007-04-16 06:56:07 +00005802
Reid Spencerb8f85052007-07-31 03:50:36 +00005803
5804 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005805
5806 *++yyvsp = yyval;
5807
5808
Reid Spencerb8f85052007-07-31 03:50:36 +00005809 /* Now `shift' the result of the reduction. Determine what state
5810 that goes to, based on the state we popped back to and the rule
5811 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005812
5813 yyn = yyr1[yyn];
5814
Reid Spencerb8f85052007-07-31 03:50:36 +00005815 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5816 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005817 yystate = yytable[yystate];
5818 else
Reid Spencerb8f85052007-07-31 03:50:36 +00005819 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005820
5821 goto yynewstate;
5822
5823
Reid Spencerb8f85052007-07-31 03:50:36 +00005824/*------------------------------------.
5825| yyerrlab -- here on detecting error |
5826`------------------------------------*/
5827yyerrlab:
5828 /* If not already recovering from an error, report this error. */
5829 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005830 {
5831 ++yynerrs;
Reid Spencerb8f85052007-07-31 03:50:36 +00005832#if YYERROR_VERBOSE
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005833 yyn = yypact[yystate];
5834
Reid Spencerb8f85052007-07-31 03:50:36 +00005835 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005836 {
David Greene718fda32007-08-01 03:59:32 +00005837 YYSIZE_T yysize = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005838 int yytype = YYTRANSLATE (yychar);
David Greene718fda32007-08-01 03:59:32 +00005839 const char* yyprefix;
5840 char *yymsg;
Reid Spencerb8f85052007-07-31 03:50:36 +00005841 int yyx;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005842
Reid Spencerb8f85052007-07-31 03:50:36 +00005843 /* Start YYX at -YYN if negative to avoid negative indexes in
5844 YYCHECK. */
5845 int yyxbegin = yyn < 0 ? -yyn : 0;
5846
5847 /* Stay within bounds of both yycheck and yytname. */
5848 int yychecklim = YYLAST - yyn;
5849 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
David Greene718fda32007-08-01 03:59:32 +00005850 int yycount = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005851
David Greene718fda32007-08-01 03:59:32 +00005852 yyprefix = ", expecting ";
Reid Spencerb8f85052007-07-31 03:50:36 +00005853 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5854 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5855 {
David Greene718fda32007-08-01 03:59:32 +00005856 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
5857 yycount += 1;
5858 if (yycount == 5)
Reid Spencerb8f85052007-07-31 03:50:36 +00005859 {
David Greene718fda32007-08-01 03:59:32 +00005860 yysize = 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005861 break;
5862 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005863 }
David Greene718fda32007-08-01 03:59:32 +00005864 yysize += (sizeof ("syntax error, unexpected ")
5865 + yystrlen (yytname[yytype]));
5866 yymsg = (char *) YYSTACK_ALLOC (yysize);
5867 if (yymsg != 0)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005868 {
David Greene718fda32007-08-01 03:59:32 +00005869 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
5870 yyp = yystpcpy (yyp, yytname[yytype]);
5871
5872 if (yycount < 5)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005873 {
David Greene718fda32007-08-01 03:59:32 +00005874 yyprefix = ", expecting ";
5875 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5876 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5877 {
5878 yyp = yystpcpy (yyp, yyprefix);
5879 yyp = yystpcpy (yyp, yytname[yyx]);
5880 yyprefix = " or ";
5881 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005882 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005883 yyerror (yymsg);
5884 YYSTACK_FREE (yymsg);
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005885 }
5886 else
David Greene718fda32007-08-01 03:59:32 +00005887 yyerror ("syntax error; also virtual memory exhausted");
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005888 }
5889 else
5890#endif /* YYERROR_VERBOSE */
David Greene718fda32007-08-01 03:59:32 +00005891 yyerror ("syntax error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005892 }
5893
Reid Spencerb8f85052007-07-31 03:50:36 +00005894
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005895
5896 if (yyerrstatus == 3)
5897 {
David Greene718fda32007-08-01 03:59:32 +00005898 /* If just tried and failed to reuse lookahead token after an
Reid Spencerb8f85052007-07-31 03:50:36 +00005899 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005900
Reid Spencerb8f85052007-07-31 03:50:36 +00005901 if (yychar <= YYEOF)
5902 {
David Greene718fda32007-08-01 03:59:32 +00005903 /* If at end of input, pop the error token,
5904 then the rest of the stack, then return failure. */
Reid Spencerb8f85052007-07-31 03:50:36 +00005905 if (yychar == YYEOF)
David Greene718fda32007-08-01 03:59:32 +00005906 for (;;)
5907 {
5908 YYPOPSTACK;
5909 if (yyssp == yyss)
5910 YYABORT;
5911 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
5912 yydestruct (yystos[*yyssp], yyvsp);
5913 }
Reid Spencerb8f85052007-07-31 03:50:36 +00005914 }
5915 else
5916 {
David Greene718fda32007-08-01 03:59:32 +00005917 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
5918 yydestruct (yytoken, &yylval);
Reid Spencerb8f85052007-07-31 03:50:36 +00005919 yychar = YYEMPTY;
David Greene718fda32007-08-01 03:59:32 +00005920
Reid Spencerb8f85052007-07-31 03:50:36 +00005921 }
5922 }
5923
David Greene718fda32007-08-01 03:59:32 +00005924 /* Else will try to reuse lookahead token after shifting the error
Reid Spencerb8f85052007-07-31 03:50:36 +00005925 token. */
5926 goto yyerrlab1;
5927
5928
5929/*---------------------------------------------------.
5930| yyerrorlab -- error raised explicitly by YYERROR. |
5931`---------------------------------------------------*/
5932yyerrorlab:
5933
David Greene718fda32007-08-01 03:59:32 +00005934#ifdef __GNUC__
5935 /* Pacify GCC when the user code never invokes YYERROR and the label
5936 yyerrorlab therefore never appears in user code. */
Reid Spencerb8f85052007-07-31 03:50:36 +00005937 if (0)
5938 goto yyerrorlab;
David Greene718fda32007-08-01 03:59:32 +00005939#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005940
David Greene718fda32007-08-01 03:59:32 +00005941 yyvsp -= yylen;
Reid Spencerb8f85052007-07-31 03:50:36 +00005942 yyssp -= yylen;
5943 yystate = *yyssp;
5944 goto yyerrlab1;
5945
5946
5947/*-------------------------------------------------------------.
5948| yyerrlab1 -- common code for both syntax error and YYERROR. |
5949`-------------------------------------------------------------*/
5950yyerrlab1:
5951 yyerrstatus = 3; /* Each real token shifted decrements this. */
5952
5953 for (;;)
5954 {
5955 yyn = yypact[yystate];
5956 if (yyn != YYPACT_NINF)
5957 {
5958 yyn += YYTERROR;
5959 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5960 {
5961 yyn = yytable[yyn];
5962 if (0 < yyn)
5963 break;
5964 }
5965 }
5966
5967 /* Pop the current state because it cannot handle the error token. */
5968 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005969 YYABORT;
5970
David Greene718fda32007-08-01 03:59:32 +00005971 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
5972 yydestruct (yystos[yystate], yyvsp);
Reid Spencerb8f85052007-07-31 03:50:36 +00005973 YYPOPSTACK;
5974 yystate = *yyssp;
5975 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005976 }
5977
5978 if (yyn == YYFINAL)
5979 YYACCEPT;
5980
David Greene718fda32007-08-01 03:59:32 +00005981 YYDPRINTF ((stderr, "Shifting error token, "));
5982
Reid Spencer68a24bd2005-08-27 18:50:39 +00005983 *++yyvsp = yylval;
Reid Spencerb8f85052007-07-31 03:50:36 +00005984
5985
Reid Spencer68a24bd2005-08-27 18:50:39 +00005986 yystate = yyn;
5987 goto yynewstate;
5988
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005989
Reid Spencerb8f85052007-07-31 03:50:36 +00005990/*-------------------------------------.
5991| yyacceptlab -- YYACCEPT comes here. |
5992`-------------------------------------*/
5993yyacceptlab:
5994 yyresult = 0;
5995 goto yyreturn;
5996
5997/*-----------------------------------.
5998| yyabortlab -- YYABORT comes here. |
5999`-----------------------------------*/
6000yyabortlab:
6001 yyresult = 1;
6002 goto yyreturn;
6003
6004#ifndef yyoverflow
David Greene718fda32007-08-01 03:59:32 +00006005/*----------------------------------------------.
6006| yyoverflowlab -- parser overflow comes here. |
6007`----------------------------------------------*/
6008yyoverflowlab:
6009 yyerror ("parser stack overflow");
Reid Spencerb8f85052007-07-31 03:50:36 +00006010 yyresult = 2;
6011 /* Fall through. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00006012#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00006013
6014yyreturn:
Reid Spencerb8f85052007-07-31 03:50:36 +00006015#ifndef yyoverflow
6016 if (yyss != yyssa)
6017 YYSTACK_FREE (yyss);
6018#endif
6019 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006020}
Reid Spencerb8f85052007-07-31 03:50:36 +00006021
6022
David Greene718fda32007-08-01 03:59:32 +00006023#line 3071 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006024
6025
Reid Spencer14310612006-12-31 05:40:51 +00006026// common code from the two 'RunVMAsmParser' functions
6027static Module* RunParser(Module * M) {
6028
6029 llvmAsmlineno = 1; // Reset the current line number...
6030 CurModule.CurrentModule = M;
6031#if YYDEBUG
6032 yydebug = Debug;
6033#endif
6034
6035 // Check to make sure the parser succeeded
6036 if (yyparse()) {
6037 if (ParserResult)
6038 delete ParserResult;
6039 return 0;
6040 }
6041
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006042 // Emit an error if there are any unresolved types left.
6043 if (!CurModule.LateResolveTypes.empty()) {
6044 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6045 if (DID.Type == ValID::LocalName) {
6046 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6047 } else {
6048 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6049 }
6050 if (ParserResult)
6051 delete ParserResult;
6052 return 0;
6053 }
6054
6055 // Emit an error if there are any unresolved values left.
6056 if (!CurModule.LateResolveValues.empty()) {
6057 Value *V = CurModule.LateResolveValues.back();
6058 std::map<Value*, std::pair<ValID, int> >::iterator I =
6059 CurModule.PlaceHolderInfo.find(V);
6060
6061 if (I != CurModule.PlaceHolderInfo.end()) {
6062 ValID &DID = I->second.first;
6063 if (DID.Type == ValID::LocalName) {
6064 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6065 } else {
6066 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6067 }
6068 if (ParserResult)
6069 delete ParserResult;
6070 return 0;
6071 }
6072 }
6073
Reid Spencer14310612006-12-31 05:40:51 +00006074 // Check to make sure that parsing produced a result
6075 if (!ParserResult)
6076 return 0;
6077
6078 // Reset ParserResult variable while saving its value for the result.
6079 Module *Result = ParserResult;
6080 ParserResult = 0;
6081
6082 return Result;
6083}
6084
Reid Spencer61c83e02006-08-18 08:43:06 +00006085void llvm::GenerateError(const std::string &message, int LineNo) {
6086 if (LineNo == -1) LineNo = llvmAsmlineno;
6087 // TODO: column number in exception
6088 if (TheParseError)
6089 TheParseError->setError(CurFilename, message, LineNo);
6090 TriggerError = 1;
6091}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006092
6093int yyerror(const char *ErrorMsg) {
6094 std::string where
6095 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6096 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006097 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6098 if (yychar != YYEMPTY && yychar != 0)
6099 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6100 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006101 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006102 return 0;
6103}
Reid Spencerb8f85052007-07-31 03:50:36 +00006104