blob: 5d3843c6f83d94cf69b11442cc02ded8e2ce10f3 [file] [log] [blame]
Chandler Carruth563d4a42007-08-04 01:56:21 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Chandler Carruth563d4a42007-08-04 01:56:21 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Chandler Carruth563d4a42007-08-04 01:56:21 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007
Chandler Carruth563d4a42007-08-04 01:56:21 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062#define yyparse llvmAsmparse
Chandler Carruth563d4a42007-08-04 01:56:21 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Chandler Carruth563d4a42007-08-04 01:56:21 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
Chandler Carruth563d4a42007-08-04 01:56:21 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 DEPLIBS = 309,
129 CALL = 310,
130 TAIL = 311,
131 ASM_TOK = 312,
132 MODULE = 313,
133 SIDEEFFECT = 314,
134 CC_TOK = 315,
135 CCC_TOK = 316,
136 FASTCC_TOK = 317,
137 COLDCC_TOK = 318,
138 X86_STDCALLCC_TOK = 319,
139 X86_FASTCALLCC_TOK = 320,
140 DATALAYOUT = 321,
141 RET = 322,
142 BR = 323,
143 SWITCH = 324,
144 INVOKE = 325,
145 UNWIND = 326,
146 UNREACHABLE = 327,
147 ADD = 328,
148 SUB = 329,
149 MUL = 330,
150 UDIV = 331,
151 SDIV = 332,
152 FDIV = 333,
153 UREM = 334,
154 SREM = 335,
155 FREM = 336,
156 AND = 337,
157 OR = 338,
158 XOR = 339,
159 SHL = 340,
160 LSHR = 341,
161 ASHR = 342,
162 ICMP = 343,
163 FCMP = 344,
164 EQ = 345,
165 NE = 346,
166 SLT = 347,
167 SGT = 348,
168 SLE = 349,
169 SGE = 350,
170 ULT = 351,
171 UGT = 352,
172 ULE = 353,
173 UGE = 354,
174 OEQ = 355,
175 ONE = 356,
176 OLT = 357,
177 OGT = 358,
178 OLE = 359,
179 OGE = 360,
180 ORD = 361,
181 UNO = 362,
182 UEQ = 363,
183 UNE = 364,
184 MALLOC = 365,
185 ALLOCA = 366,
186 FREE = 367,
187 LOAD = 368,
188 STORE = 369,
189 GETELEMENTPTR = 370,
190 TRUNC = 371,
191 ZEXT = 372,
192 SEXT = 373,
193 FPTRUNC = 374,
194 FPEXT = 375,
195 BITCAST = 376,
196 UITOFP = 377,
197 SITOFP = 378,
198 FPTOUI = 379,
199 FPTOSI = 380,
200 INTTOPTR = 381,
201 PTRTOINT = 382,
202 PHI_TOK = 383,
203 SELECT = 384,
204 VAARG = 385,
205 EXTRACTELEMENT = 386,
206 INSERTELEMENT = 387,
207 SHUFFLEVECTOR = 388,
208 SIGNEXT = 389,
209 ZEROEXT = 390,
210 NORETURN = 391,
211 INREG = 392,
212 SRET = 393,
213 NOUNWIND = 394,
214 NOALIAS = 395,
215 BYVAL = 396,
216 NEST = 397,
217 DEFAULT = 398,
218 HIDDEN = 399,
219 PROTECTED = 400
220 };
221#endif
222/* Tokens. */
223#define ESINT64VAL 258
224#define EUINT64VAL 259
225#define ESAPINTVAL 260
226#define EUAPINTVAL 261
227#define LOCALVAL_ID 262
228#define GLOBALVAL_ID 263
229#define FPVAL 264
230#define VOID 265
231#define INTTYPE 266
232#define FLOAT 267
233#define DOUBLE 268
234#define X86_FP80 269
235#define FP128 270
236#define PPC_FP128 271
237#define LABEL 272
238#define TYPE 273
239#define LOCALVAR 274
240#define GLOBALVAR 275
241#define LABELSTR 276
242#define STRINGCONSTANT 277
243#define ATSTRINGCONSTANT 278
244#define PCTSTRINGCONSTANT 279
245#define ZEROINITIALIZER 280
246#define TRUETOK 281
247#define FALSETOK 282
248#define BEGINTOK 283
249#define ENDTOK 284
250#define DECLARE 285
251#define DEFINE 286
252#define GLOBAL 287
253#define CONSTANT 288
254#define SECTION 289
255#define ALIAS 290
256#define VOLATILE 291
257#define THREAD_LOCAL 292
258#define TO 293
259#define DOTDOTDOT 294
260#define NULL_TOK 295
261#define UNDEF 296
262#define INTERNAL 297
263#define LINKONCE 298
264#define WEAK 299
265#define APPENDING 300
266#define DLLIMPORT 301
267#define DLLEXPORT 302
268#define EXTERN_WEAK 303
269#define OPAQUE 304
270#define EXTERNAL 305
271#define TARGET 306
272#define TRIPLE 307
273#define ALIGN 308
274#define DEPLIBS 309
275#define CALL 310
276#define TAIL 311
277#define ASM_TOK 312
278#define MODULE 313
279#define SIDEEFFECT 314
280#define CC_TOK 315
281#define CCC_TOK 316
282#define FASTCC_TOK 317
283#define COLDCC_TOK 318
284#define X86_STDCALLCC_TOK 319
285#define X86_FASTCALLCC_TOK 320
286#define DATALAYOUT 321
287#define RET 322
288#define BR 323
289#define SWITCH 324
290#define INVOKE 325
291#define UNWIND 326
292#define UNREACHABLE 327
293#define ADD 328
294#define SUB 329
295#define MUL 330
296#define UDIV 331
297#define SDIV 332
298#define FDIV 333
299#define UREM 334
300#define SREM 335
301#define FREM 336
302#define AND 337
303#define OR 338
304#define XOR 339
305#define SHL 340
306#define LSHR 341
307#define ASHR 342
308#define ICMP 343
309#define FCMP 344
310#define EQ 345
311#define NE 346
312#define SLT 347
313#define SGT 348
314#define SLE 349
315#define SGE 350
316#define ULT 351
317#define UGT 352
318#define ULE 353
319#define UGE 354
320#define OEQ 355
321#define ONE 356
322#define OLT 357
323#define OGT 358
324#define OLE 359
325#define OGE 360
326#define ORD 361
327#define UNO 362
328#define UEQ 363
329#define UNE 364
330#define MALLOC 365
331#define ALLOCA 366
332#define FREE 367
333#define LOAD 368
334#define STORE 369
335#define GETELEMENTPTR 370
336#define TRUNC 371
337#define ZEXT 372
338#define SEXT 373
339#define FPTRUNC 374
340#define FPEXT 375
341#define BITCAST 376
342#define UITOFP 377
343#define SITOFP 378
344#define FPTOUI 379
345#define FPTOSI 380
346#define INTTOPTR 381
347#define PTRTOINT 382
348#define PHI_TOK 383
349#define SELECT 384
350#define VAARG 385
351#define EXTRACTELEMENT 386
352#define INSERTELEMENT 387
353#define SHUFFLEVECTOR 388
354#define SIGNEXT 389
355#define ZEROEXT 390
356#define NORETURN 391
357#define INREG 392
358#define SRET 393
359#define NOUNWIND 394
360#define NOALIAS 395
361#define BYVAL 396
362#define NEST 397
363#define DEFAULT 398
364#define HIDDEN 399
365#define PROTECTED 400
366
367
368
369
370/* Copy the first part of user declarations. */
371#line 14 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372
373#include "ParserInternals.h"
374#include "llvm/CallingConv.h"
375#include "llvm/InlineAsm.h"
376#include "llvm/Instructions.h"
377#include "llvm/Module.h"
378#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000379#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380#include "llvm/Support/GetElementPtrTypeIterator.h"
381#include "llvm/Support/CommandLine.h"
382#include "llvm/ADT/SmallVector.h"
383#include "llvm/ADT/STLExtras.h"
384#include "llvm/Support/MathExtras.h"
385#include "llvm/Support/Streams.h"
386#include <algorithm>
387#include <list>
388#include <map>
389#include <utility>
390#ifndef NDEBUG
391#define YYDEBUG 1
392#endif
393
394// The following is a gross hack. In order to rid the libAsmParser library of
395// exceptions, we have to have a way of getting the yyparse function to go into
396// an error situation. So, whenever we want an error to occur, the GenerateError
397// function (see bottom of file) sets TriggerError. Then, at the end of each
398// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
399// (a goto) to put YACC in error state. Furthermore, several calls to
400// GenerateError are made from inside productions and they must simulate the
401// previous exception behavior by exiting the production immediately. We have
402// replaced these with the GEN_ERROR macro which calls GeneratError and then
403// immediately invokes YYERROR. This would be so much cleaner if it was a
404// recursive descent parser.
405static bool TriggerError = false;
406#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
407#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
408
409int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
410int yylex(); // declaration" of xxx warnings.
411int yyparse();
412
413namespace llvm {
414 std::string CurFilename;
415#if YYDEBUG
416static cl::opt<bool>
417Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
418 cl::Hidden, cl::init(false));
419#endif
420}
421using namespace llvm;
422
423static Module *ParserResult;
424
425// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
426// relating to upreferences in the input stream.
427//
428//#define DEBUG_UPREFS 1
429#ifdef DEBUG_UPREFS
430#define UR_OUT(X) cerr << X
431#else
432#define UR_OUT(X)
433#endif
434
435#define YYERROR_VERBOSE 1
436
437static GlobalVariable *CurGV;
438
439
440// This contains info used when building the body of a function. It is
441// destroyed when the function is completed.
442//
443typedef std::vector<Value *> ValueList; // Numbered defs
444
445static void
446ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
447
448static struct PerModuleInfo {
449 Module *CurrentModule;
450 ValueList Values; // Module level numbered definitions
451 ValueList LateResolveValues;
452 std::vector<PATypeHolder> Types;
453 std::map<ValID, PATypeHolder> LateResolveTypes;
454
455 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
456 /// how they were referenced and on which line of the input they came from so
457 /// that we can resolve them later and print error messages as appropriate.
458 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
459
460 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
461 // references to global values. Global values may be referenced before they
462 // are defined, and if so, the temporary object that they represent is held
463 // here. This is used for forward references of GlobalValues.
464 //
465 typedef std::map<std::pair<const PointerType *,
466 ValID>, GlobalValue*> GlobalRefsType;
467 GlobalRefsType GlobalRefs;
468
469 void ModuleDone() {
470 // If we could not resolve some functions at function compilation time
471 // (calls to functions before they are defined), resolve them now... Types
472 // are resolved when the constant pool has been completely parsed.
473 //
474 ResolveDefinitions(LateResolveValues);
475 if (TriggerError)
476 return;
477
478 // Check to make sure that all global value forward references have been
479 // resolved!
480 //
481 if (!GlobalRefs.empty()) {
482 std::string UndefinedReferences = "Unresolved global references exist:\n";
483
484 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
485 I != E; ++I) {
486 UndefinedReferences += " " + I->first.first->getDescription() + " " +
487 I->first.second.getName() + "\n";
488 }
489 GenerateError(UndefinedReferences);
490 return;
491 }
492
Chandler Carruth563d4a42007-08-04 01:56:21 +0000493 // Look for intrinsic functions and CallInst that need to be upgraded
494 for (Module::iterator FI = CurrentModule->begin(),
495 FE = CurrentModule->end(); FI != FE; )
496 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
497
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498 Values.clear(); // Clear out function local definitions
499 Types.clear();
500 CurrentModule = 0;
501 }
502
503 // GetForwardRefForGlobal - Check to see if there is a forward reference
504 // for this global. If so, remove it from the GlobalRefs map and return it.
505 // If not, just return null.
506 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
507 // Check to see if there is a forward reference to this global variable...
508 // if there is, eliminate it and patch the reference to use the new def'n.
509 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
510 GlobalValue *Ret = 0;
511 if (I != GlobalRefs.end()) {
512 Ret = I->second;
513 GlobalRefs.erase(I);
514 }
515 return Ret;
516 }
517
518 bool TypeIsUnresolved(PATypeHolder* PATy) {
519 // If it isn't abstract, its resolved
520 const Type* Ty = PATy->get();
521 if (!Ty->isAbstract())
522 return false;
523 // Traverse the type looking for abstract types. If it isn't abstract then
524 // we don't need to traverse that leg of the type.
525 std::vector<const Type*> WorkList, SeenList;
526 WorkList.push_back(Ty);
527 while (!WorkList.empty()) {
528 const Type* Ty = WorkList.back();
529 SeenList.push_back(Ty);
530 WorkList.pop_back();
531 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
532 // Check to see if this is an unresolved type
533 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
534 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
535 for ( ; I != E; ++I) {
536 if (I->second.get() == OpTy)
537 return true;
538 }
539 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
540 const Type* TheTy = SeqTy->getElementType();
541 if (TheTy->isAbstract() && TheTy != Ty) {
542 std::vector<const Type*>::iterator I = SeenList.begin(),
543 E = SeenList.end();
544 for ( ; I != E; ++I)
545 if (*I == TheTy)
546 break;
547 if (I == E)
548 WorkList.push_back(TheTy);
549 }
550 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
551 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
552 const Type* TheTy = StrTy->getElementType(i);
553 if (TheTy->isAbstract() && TheTy != Ty) {
554 std::vector<const Type*>::iterator I = SeenList.begin(),
555 E = SeenList.end();
556 for ( ; I != E; ++I)
557 if (*I == TheTy)
558 break;
559 if (I == E)
560 WorkList.push_back(TheTy);
561 }
562 }
563 }
564 }
565 return false;
566 }
567} CurModule;
568
569static struct PerFunctionInfo {
570 Function *CurrentFunction; // Pointer to current function being created
571
572 ValueList Values; // Keep track of #'d definitions
573 unsigned NextValNum;
574 ValueList LateResolveValues;
575 bool isDeclare; // Is this function a forward declararation?
576 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
577 GlobalValue::VisibilityTypes Visibility;
578
579 /// BBForwardRefs - When we see forward references to basic blocks, keep
580 /// track of them here.
581 std::map<ValID, BasicBlock*> BBForwardRefs;
582
583 inline PerFunctionInfo() {
584 CurrentFunction = 0;
585 isDeclare = false;
586 Linkage = GlobalValue::ExternalLinkage;
587 Visibility = GlobalValue::DefaultVisibility;
588 }
589
590 inline void FunctionStart(Function *M) {
591 CurrentFunction = M;
592 NextValNum = 0;
593 }
594
595 void FunctionDone() {
596 // Any forward referenced blocks left?
597 if (!BBForwardRefs.empty()) {
598 GenerateError("Undefined reference to label " +
599 BBForwardRefs.begin()->second->getName());
600 return;
601 }
602
603 // Resolve all forward references now.
604 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
605
606 Values.clear(); // Clear out function local definitions
607 BBForwardRefs.clear();
608 CurrentFunction = 0;
609 isDeclare = false;
610 Linkage = GlobalValue::ExternalLinkage;
611 Visibility = GlobalValue::DefaultVisibility;
612 }
613} CurFun; // Info for the current function...
614
615static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
616
617
618//===----------------------------------------------------------------------===//
619// Code to handle definitions of all the types
620//===----------------------------------------------------------------------===//
621
622static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
623 // Things that have names or are void typed don't get slot numbers
624 if (V->hasName() || (V->getType() == Type::VoidTy))
625 return;
626
627 // In the case of function values, we have to allow for the forward reference
628 // of basic blocks, which are included in the numbering. Consequently, we keep
629 // track of the next insertion location with NextValNum. When a BB gets
630 // inserted, it could change the size of the CurFun.Values vector.
631 if (&ValueTab == &CurFun.Values) {
632 if (ValueTab.size() <= CurFun.NextValNum)
633 ValueTab.resize(CurFun.NextValNum+1);
634 ValueTab[CurFun.NextValNum++] = V;
635 return;
636 }
637 // For all other lists, its okay to just tack it on the back of the vector.
638 ValueTab.push_back(V);
639}
640
641static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
642 switch (D.Type) {
643 case ValID::LocalID: // Is it a numbered definition?
644 // Module constants occupy the lowest numbered slots...
645 if (D.Num < CurModule.Types.size())
646 return CurModule.Types[D.Num];
647 break;
648 case ValID::LocalName: // Is it a named definition?
649 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
650 D.destroy(); // Free old strdup'd memory...
651 return N;
652 }
653 break;
654 default:
655 GenerateError("Internal parser error: Invalid symbol type reference");
656 return 0;
657 }
658
659 // If we reached here, we referenced either a symbol that we don't know about
660 // or an id number that hasn't been read yet. We may be referencing something
661 // forward, so just create an entry to be resolved later and get to it...
662 //
663 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
664
665
666 if (inFunctionScope()) {
667 if (D.Type == ValID::LocalName) {
668 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
669 return 0;
670 } else {
671 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
672 return 0;
673 }
674 }
675
676 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
677 if (I != CurModule.LateResolveTypes.end())
678 return I->second;
679
680 Type *Typ = OpaqueType::get();
681 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
682 return Typ;
683 }
684
685// getExistingVal - Look up the value specified by the provided type and
686// the provided ValID. If the value exists and has already been defined, return
687// it. Otherwise return null.
688//
689static Value *getExistingVal(const Type *Ty, const ValID &D) {
690 if (isa<FunctionType>(Ty)) {
691 GenerateError("Functions are not values and "
692 "must be referenced as pointers");
693 return 0;
694 }
695
696 switch (D.Type) {
697 case ValID::LocalID: { // Is it a numbered definition?
698 // Check that the number is within bounds.
699 if (D.Num >= CurFun.Values.size())
700 return 0;
701 Value *Result = CurFun.Values[D.Num];
702 if (Ty != Result->getType()) {
703 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
704 Result->getType()->getDescription() + "' does not match "
705 "expected type, '" + Ty->getDescription() + "'");
706 return 0;
707 }
708 return Result;
709 }
710 case ValID::GlobalID: { // Is it a numbered definition?
711 if (D.Num >= CurModule.Values.size())
712 return 0;
713 Value *Result = CurModule.Values[D.Num];
714 if (Ty != Result->getType()) {
715 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
716 Result->getType()->getDescription() + "' does not match "
717 "expected type, '" + Ty->getDescription() + "'");
718 return 0;
719 }
720 return Result;
721 }
722
723 case ValID::LocalName: { // Is it a named definition?
724 if (!inFunctionScope())
725 return 0;
726 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
727 Value *N = SymTab.lookup(D.getName());
728 if (N == 0)
729 return 0;
730 if (N->getType() != Ty)
731 return 0;
732
733 D.destroy(); // Free old strdup'd memory...
734 return N;
735 }
736 case ValID::GlobalName: { // Is it a named definition?
737 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
738 Value *N = SymTab.lookup(D.getName());
739 if (N == 0)
740 return 0;
741 if (N->getType() != Ty)
742 return 0;
743
744 D.destroy(); // Free old strdup'd memory...
745 return N;
746 }
747
748 // Check to make sure that "Ty" is an integral type, and that our
749 // value will fit into the specified type...
750 case ValID::ConstSIntVal: // Is it a constant pool reference??
751 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
752 GenerateError("Signed integral constant '" +
753 itostr(D.ConstPool64) + "' is invalid for type '" +
754 Ty->getDescription() + "'");
755 return 0;
756 }
757 return ConstantInt::get(Ty, D.ConstPool64, true);
758
759 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
760 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
761 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
762 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
763 "' is invalid or out of range");
764 return 0;
765 } else { // This is really a signed reference. Transmogrify.
766 return ConstantInt::get(Ty, D.ConstPool64, true);
767 }
768 } else {
769 return ConstantInt::get(Ty, D.UConstPool64);
770 }
771
772 case ValID::ConstFPVal: // Is it a floating point const pool reference?
773 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
774 GenerateError("FP constant invalid for type");
775 return 0;
776 }
777 return ConstantFP::get(Ty, D.ConstPoolFP);
778
779 case ValID::ConstNullVal: // Is it a null value?
780 if (!isa<PointerType>(Ty)) {
781 GenerateError("Cannot create a a non pointer null");
782 return 0;
783 }
784 return ConstantPointerNull::get(cast<PointerType>(Ty));
785
786 case ValID::ConstUndefVal: // Is it an undef value?
787 return UndefValue::get(Ty);
788
789 case ValID::ConstZeroVal: // Is it a zero value?
790 return Constant::getNullValue(Ty);
791
792 case ValID::ConstantVal: // Fully resolved constant?
793 if (D.ConstantValue->getType() != Ty) {
794 GenerateError("Constant expression type different from required type");
795 return 0;
796 }
797 return D.ConstantValue;
798
799 case ValID::InlineAsmVal: { // Inline asm expression
800 const PointerType *PTy = dyn_cast<PointerType>(Ty);
801 const FunctionType *FTy =
802 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
803 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
804 GenerateError("Invalid type for asm constraint string");
805 return 0;
806 }
807 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
808 D.IAD->HasSideEffects);
809 D.destroy(); // Free InlineAsmDescriptor.
810 return IA;
811 }
812 default:
813 assert(0 && "Unhandled case!");
814 return 0;
815 } // End of switch
816
817 assert(0 && "Unhandled case!");
818 return 0;
819}
820
821// getVal - This function is identical to getExistingVal, except that if a
822// value is not already defined, it "improvises" by creating a placeholder var
823// that looks and acts just like the requested variable. When the value is
824// defined later, all uses of the placeholder variable are replaced with the
825// real thing.
826//
827static Value *getVal(const Type *Ty, const ValID &ID) {
828 if (Ty == Type::LabelTy) {
829 GenerateError("Cannot use a basic block here");
830 return 0;
831 }
832
833 // See if the value has already been defined.
834 Value *V = getExistingVal(Ty, ID);
835 if (V) return V;
836 if (TriggerError) return 0;
837
838 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
839 GenerateError("Invalid use of a composite type");
840 return 0;
841 }
842
843 // If we reached here, we referenced either a symbol that we don't know about
844 // or an id number that hasn't been read yet. We may be referencing something
845 // forward, so just create an entry to be resolved later and get to it...
846 //
847 switch (ID.Type) {
848 case ValID::GlobalName:
849 case ValID::GlobalID: {
850 const PointerType *PTy = dyn_cast<PointerType>(Ty);
851 if (!PTy) {
852 GenerateError("Invalid type for reference to global" );
853 return 0;
854 }
855 const Type* ElTy = PTy->getElementType();
856 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
857 V = new Function(FTy, GlobalValue::ExternalLinkage);
858 else
859 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
860 break;
861 }
862 default:
863 V = new Argument(Ty);
864 }
865
866 // Remember where this forward reference came from. FIXME, shouldn't we try
867 // to recycle these things??
868 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
869 llvmAsmlineno)));
870
871 if (inFunctionScope())
872 InsertValue(V, CurFun.LateResolveValues);
873 else
874 InsertValue(V, CurModule.LateResolveValues);
875 return V;
876}
877
878/// defineBBVal - This is a definition of a new basic block with the specified
879/// identifier which must be the same as CurFun.NextValNum, if its numeric.
880static BasicBlock *defineBBVal(const ValID &ID) {
881 assert(inFunctionScope() && "Can't get basic block at global scope!");
882
883 BasicBlock *BB = 0;
884
885 // First, see if this was forward referenced
886
887 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
888 if (BBI != CurFun.BBForwardRefs.end()) {
889 BB = BBI->second;
890 // The forward declaration could have been inserted anywhere in the
891 // function: insert it into the correct place now.
892 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
893 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
894
895 // We're about to erase the entry, save the key so we can clean it up.
896 ValID Tmp = BBI->first;
897
898 // Erase the forward ref from the map as its no longer "forward"
899 CurFun.BBForwardRefs.erase(ID);
900
901 // The key has been removed from the map but so we don't want to leave
902 // strdup'd memory around so destroy it too.
903 Tmp.destroy();
904
905 // If its a numbered definition, bump the number and set the BB value.
906 if (ID.Type == ValID::LocalID) {
907 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
908 InsertValue(BB);
909 }
910
911 ID.destroy();
912 return BB;
913 }
914
915 // We haven't seen this BB before and its first mention is a definition.
916 // Just create it and return it.
917 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
918 BB = new BasicBlock(Name, CurFun.CurrentFunction);
919 if (ID.Type == ValID::LocalID) {
920 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
921 InsertValue(BB);
922 }
923
924 ID.destroy(); // Free strdup'd memory
925 return BB;
926}
927
928/// getBBVal - get an existing BB value or create a forward reference for it.
929///
930static BasicBlock *getBBVal(const ValID &ID) {
931 assert(inFunctionScope() && "Can't get basic block at global scope!");
932
933 BasicBlock *BB = 0;
934
935 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
936 if (BBI != CurFun.BBForwardRefs.end()) {
937 BB = BBI->second;
938 } if (ID.Type == ValID::LocalName) {
939 std::string Name = ID.getName();
940 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
941 if (N)
942 if (N->getType()->getTypeID() == Type::LabelTyID)
943 BB = cast<BasicBlock>(N);
944 else
945 GenerateError("Reference to label '" + Name + "' is actually of type '"+
946 N->getType()->getDescription() + "'");
947 } else if (ID.Type == ValID::LocalID) {
948 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
949 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
950 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
951 else
952 GenerateError("Reference to label '%" + utostr(ID.Num) +
953 "' is actually of type '"+
954 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
955 }
956 } else {
957 GenerateError("Illegal label reference " + ID.getName());
958 return 0;
959 }
960
961 // If its already been defined, return it now.
962 if (BB) {
963 ID.destroy(); // Free strdup'd memory.
964 return BB;
965 }
966
967 // Otherwise, this block has not been seen before, create it.
968 std::string Name;
969 if (ID.Type == ValID::LocalName)
970 Name = ID.getName();
971 BB = new BasicBlock(Name, CurFun.CurrentFunction);
972
973 // Insert it in the forward refs map.
974 CurFun.BBForwardRefs[ID] = BB;
975
976 return BB;
977}
978
979
980//===----------------------------------------------------------------------===//
981// Code to handle forward references in instructions
982//===----------------------------------------------------------------------===//
983//
984// This code handles the late binding needed with statements that reference
985// values not defined yet... for example, a forward branch, or the PHI node for
986// a loop body.
987//
988// This keeps a table (CurFun.LateResolveValues) of all such forward references
989// and back patchs after we are done.
990//
991
992// ResolveDefinitions - If we could not resolve some defs at parsing
993// time (forward branches, phi functions for loops, etc...) resolve the
994// defs now...
995//
996static void
997ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
998 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
999 while (!LateResolvers.empty()) {
1000 Value *V = LateResolvers.back();
1001 LateResolvers.pop_back();
1002
1003 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1004 CurModule.PlaceHolderInfo.find(V);
1005 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1006
1007 ValID &DID = PHI->second.first;
1008
1009 Value *TheRealValue = getExistingVal(V->getType(), DID);
1010 if (TriggerError)
1011 return;
1012 if (TheRealValue) {
1013 V->replaceAllUsesWith(TheRealValue);
1014 delete V;
1015 CurModule.PlaceHolderInfo.erase(PHI);
1016 } else if (FutureLateResolvers) {
1017 // Functions have their unresolved items forwarded to the module late
1018 // resolver table
1019 InsertValue(V, *FutureLateResolvers);
1020 } else {
1021 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1022 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1023 "' of type '" + V->getType()->getDescription() + "'",
1024 PHI->second.second);
1025 return;
1026 } else {
1027 GenerateError("Reference to an invalid definition: #" +
1028 itostr(DID.Num) + " of type '" +
1029 V->getType()->getDescription() + "'",
1030 PHI->second.second);
1031 return;
1032 }
1033 }
1034 }
1035 LateResolvers.clear();
1036}
1037
1038// ResolveTypeTo - A brand new type was just declared. This means that (if
1039// name is not null) things referencing Name can be resolved. Otherwise, things
1040// refering to the number can be resolved. Do this now.
1041//
1042static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1043 ValID D;
1044 if (Name)
1045 D = ValID::createLocalName(*Name);
1046 else
1047 D = ValID::createLocalID(CurModule.Types.size());
1048
1049 std::map<ValID, PATypeHolder>::iterator I =
1050 CurModule.LateResolveTypes.find(D);
1051 if (I != CurModule.LateResolveTypes.end()) {
1052 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1053 CurModule.LateResolveTypes.erase(I);
1054 }
1055}
1056
1057// setValueName - Set the specified value to the name given. The name may be
1058// null potentially, in which case this is a noop. The string passed in is
1059// assumed to be a malloc'd string buffer, and is free'd by this function.
1060//
1061static void setValueName(Value *V, std::string *NameStr) {
1062 if (!NameStr) return;
1063 std::string Name(*NameStr); // Copy string
1064 delete NameStr; // Free old string
1065
1066 if (V->getType() == Type::VoidTy) {
1067 GenerateError("Can't assign name '" + Name+"' to value with void type");
1068 return;
1069 }
1070
1071 assert(inFunctionScope() && "Must be in function scope!");
1072 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1073 if (ST.lookup(Name)) {
1074 GenerateError("Redefinition of value '" + Name + "' of type '" +
1075 V->getType()->getDescription() + "'");
1076 return;
1077 }
1078
1079 // Set the name.
1080 V->setName(Name);
1081}
1082
1083/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1084/// this is a declaration, otherwise it is a definition.
1085static GlobalVariable *
1086ParseGlobalVariable(std::string *NameStr,
1087 GlobalValue::LinkageTypes Linkage,
1088 GlobalValue::VisibilityTypes Visibility,
1089 bool isConstantGlobal, const Type *Ty,
1090 Constant *Initializer, bool IsThreadLocal) {
1091 if (isa<FunctionType>(Ty)) {
1092 GenerateError("Cannot declare global vars of function type");
1093 return 0;
1094 }
1095
1096 const PointerType *PTy = PointerType::get(Ty);
1097
1098 std::string Name;
1099 if (NameStr) {
1100 Name = *NameStr; // Copy string
1101 delete NameStr; // Free old string
1102 }
1103
1104 // See if this global value was forward referenced. If so, recycle the
1105 // object.
1106 ValID ID;
1107 if (!Name.empty()) {
1108 ID = ValID::createGlobalName(Name);
1109 } else {
1110 ID = ValID::createGlobalID(CurModule.Values.size());
1111 }
1112
1113 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1114 // Move the global to the end of the list, from whereever it was
1115 // previously inserted.
1116 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1117 CurModule.CurrentModule->getGlobalList().remove(GV);
1118 CurModule.CurrentModule->getGlobalList().push_back(GV);
1119 GV->setInitializer(Initializer);
1120 GV->setLinkage(Linkage);
1121 GV->setVisibility(Visibility);
1122 GV->setConstant(isConstantGlobal);
1123 GV->setThreadLocal(IsThreadLocal);
1124 InsertValue(GV, CurModule.Values);
1125 return GV;
1126 }
1127
1128 // If this global has a name
1129 if (!Name.empty()) {
1130 // if the global we're parsing has an initializer (is a definition) and
1131 // has external linkage.
1132 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1133 // If there is already a global with external linkage with this name
1134 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1135 // If we allow this GVar to get created, it will be renamed in the
1136 // symbol table because it conflicts with an existing GVar. We can't
1137 // allow redefinition of GVars whose linking indicates that their name
1138 // must stay the same. Issue the error.
1139 GenerateError("Redefinition of global variable named '" + Name +
1140 "' of type '" + Ty->getDescription() + "'");
1141 return 0;
1142 }
1143 }
1144
1145 // Otherwise there is no existing GV to use, create one now.
1146 GlobalVariable *GV =
1147 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1148 CurModule.CurrentModule, IsThreadLocal);
1149 GV->setVisibility(Visibility);
1150 InsertValue(GV, CurModule.Values);
1151 return GV;
1152}
1153
1154// setTypeName - Set the specified type to the name given. The name may be
1155// null potentially, in which case this is a noop. The string passed in is
1156// assumed to be a malloc'd string buffer, and is freed by this function.
1157//
1158// This function returns true if the type has already been defined, but is
1159// allowed to be redefined in the specified context. If the name is a new name
1160// for the type plane, it is inserted and false is returned.
1161static bool setTypeName(const Type *T, std::string *NameStr) {
1162 assert(!inFunctionScope() && "Can't give types function-local names!");
1163 if (NameStr == 0) return false;
1164
1165 std::string Name(*NameStr); // Copy string
1166 delete NameStr; // Free old string
1167
1168 // We don't allow assigning names to void type
1169 if (T == Type::VoidTy) {
1170 GenerateError("Can't assign name '" + Name + "' to the void type");
1171 return false;
1172 }
1173
1174 // Set the type name, checking for conflicts as we do so.
1175 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1176
1177 if (AlreadyExists) { // Inserting a name that is already defined???
1178 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1179 assert(Existing && "Conflict but no matching type?!");
1180
1181 // There is only one case where this is allowed: when we are refining an
1182 // opaque type. In this case, Existing will be an opaque type.
1183 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1184 // We ARE replacing an opaque type!
1185 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1186 return true;
1187 }
1188
1189 // Otherwise, this is an attempt to redefine a type. That's okay if
1190 // the redefinition is identical to the original. This will be so if
1191 // Existing and T point to the same Type object. In this one case we
1192 // allow the equivalent redefinition.
1193 if (Existing == T) return true; // Yes, it's equal.
1194
1195 // Any other kind of (non-equivalent) redefinition is an error.
1196 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1197 T->getDescription() + "'");
1198 }
1199
1200 return false;
1201}
1202
1203//===----------------------------------------------------------------------===//
1204// Code for handling upreferences in type names...
1205//
1206
1207// TypeContains - Returns true if Ty directly contains E in it.
1208//
1209static bool TypeContains(const Type *Ty, const Type *E) {
1210 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1211 E) != Ty->subtype_end();
1212}
1213
1214namespace {
1215 struct UpRefRecord {
1216 // NestingLevel - The number of nesting levels that need to be popped before
1217 // this type is resolved.
1218 unsigned NestingLevel;
1219
1220 // LastContainedTy - This is the type at the current binding level for the
1221 // type. Every time we reduce the nesting level, this gets updated.
1222 const Type *LastContainedTy;
1223
1224 // UpRefTy - This is the actual opaque type that the upreference is
1225 // represented with.
1226 OpaqueType *UpRefTy;
1227
1228 UpRefRecord(unsigned NL, OpaqueType *URTy)
1229 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1230 };
1231}
1232
1233// UpRefs - A list of the outstanding upreferences that need to be resolved.
1234static std::vector<UpRefRecord> UpRefs;
1235
1236/// HandleUpRefs - Every time we finish a new layer of types, this function is
1237/// called. It loops through the UpRefs vector, which is a list of the
1238/// currently active types. For each type, if the up reference is contained in
1239/// the newly completed type, we decrement the level count. When the level
1240/// count reaches zero, the upreferenced type is the type that is passed in:
1241/// thus we can complete the cycle.
1242///
1243static PATypeHolder HandleUpRefs(const Type *ty) {
1244 // If Ty isn't abstract, or if there are no up-references in it, then there is
1245 // nothing to resolve here.
1246 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1247
1248 PATypeHolder Ty(ty);
1249 UR_OUT("Type '" << Ty->getDescription() <<
1250 "' newly formed. Resolving upreferences.\n" <<
1251 UpRefs.size() << " upreferences active!\n");
1252
1253 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1254 // to zero), we resolve them all together before we resolve them to Ty. At
1255 // the end of the loop, if there is anything to resolve to Ty, it will be in
1256 // this variable.
1257 OpaqueType *TypeToResolve = 0;
1258
1259 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1260 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1261 << UpRefs[i].second->getDescription() << ") = "
1262 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1263 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1264 // Decrement level of upreference
1265 unsigned Level = --UpRefs[i].NestingLevel;
1266 UpRefs[i].LastContainedTy = Ty;
1267 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1268 if (Level == 0) { // Upreference should be resolved!
1269 if (!TypeToResolve) {
1270 TypeToResolve = UpRefs[i].UpRefTy;
1271 } else {
1272 UR_OUT(" * Resolving upreference for "
1273 << UpRefs[i].second->getDescription() << "\n";
1274 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1275 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1276 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1277 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1278 }
1279 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1280 --i; // Do not skip the next element...
1281 }
1282 }
1283 }
1284
1285 if (TypeToResolve) {
1286 UR_OUT(" * Resolving upreference for "
1287 << UpRefs[i].second->getDescription() << "\n";
1288 std::string OldName = TypeToResolve->getDescription());
1289 TypeToResolve->refineAbstractTypeTo(Ty);
1290 }
1291
1292 return Ty;
1293}
1294
1295//===----------------------------------------------------------------------===//
1296// RunVMAsmParser - Define an interface to this parser
1297//===----------------------------------------------------------------------===//
1298//
1299static Module* RunParser(Module * M);
1300
1301Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1302 set_scan_file(F);
1303
1304 CurFilename = Filename;
1305 return RunParser(new Module(CurFilename));
1306}
1307
1308Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1309 set_scan_string(AsmString);
1310
1311 CurFilename = "from_memory";
1312 if (M == NULL) {
1313 return RunParser(new Module (CurFilename));
1314 } else {
1315 return RunParser(M);
1316 }
1317}
1318
1319
Chandler Carruth563d4a42007-08-04 01:56:21 +00001320
1321/* Enabling traces. */
1322#ifndef YYDEBUG
1323# define YYDEBUG 0
1324#endif
1325
1326/* Enabling verbose error messages. */
1327#ifdef YYERROR_VERBOSE
1328# undef YYERROR_VERBOSE
1329# define YYERROR_VERBOSE 1
1330#else
1331# define YYERROR_VERBOSE 0
1332#endif
1333
1334/* Enabling the token table. */
1335#ifndef YYTOKEN_TABLE
1336# define YYTOKEN_TABLE 0
1337#endif
1338
1339#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1340typedef union YYSTYPE
1341#line 963 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
1342{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 llvm::Module *ModuleVal;
1344 llvm::Function *FunctionVal;
1345 llvm::BasicBlock *BasicBlockVal;
1346 llvm::TerminatorInst *TermInstVal;
1347 llvm::Instruction *InstVal;
1348 llvm::Constant *ConstVal;
1349
1350 const llvm::Type *PrimType;
1351 std::list<llvm::PATypeHolder> *TypeList;
1352 llvm::PATypeHolder *TypeVal;
1353 llvm::Value *ValueVal;
1354 std::vector<llvm::Value*> *ValueList;
1355 llvm::ArgListType *ArgList;
1356 llvm::TypeWithAttrs TypeWithAttrs;
1357 llvm::TypeWithAttrsList *TypeWithAttrsList;
1358 llvm::ValueRefList *ValueRefList;
1359
1360 // Represent the RHS of PHI node
1361 std::list<std::pair<llvm::Value*,
1362 llvm::BasicBlock*> > *PHIList;
1363 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1364 std::vector<llvm::Constant*> *ConstVector;
1365
1366 llvm::GlobalValue::LinkageTypes Linkage;
1367 llvm::GlobalValue::VisibilityTypes Visibility;
1368 uint16_t ParamAttrs;
1369 llvm::APInt *APIntVal;
1370 int64_t SInt64Val;
1371 uint64_t UInt64Val;
1372 int SIntVal;
1373 unsigned UIntVal;
1374 double FPVal;
1375 bool BoolVal;
1376
1377 std::string *StrVal; // This memory must be deleted
1378 llvm::ValID ValIDVal;
1379
1380 llvm::Instruction::BinaryOps BinaryOpVal;
1381 llvm::Instruction::TermOps TermOpVal;
1382 llvm::Instruction::MemoryOps MemOpVal;
1383 llvm::Instruction::CastOps CastOpVal;
1384 llvm::Instruction::OtherOps OtherOpVal;
1385 llvm::ICmpInst::Predicate IPredicate;
1386 llvm::FCmpInst::Predicate FPredicate;
Chandler Carruth563d4a42007-08-04 01:56:21 +00001387}
1388/* Line 187 of yacc.c. */
1389#line 1390 "llvmAsmParser.tab.c"
1390 YYSTYPE;
1391# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1392# define YYSTYPE_IS_DECLARED 1
1393# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394#endif
1395
1396
1397
Chandler Carruth563d4a42007-08-04 01:56:21 +00001398/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400
Chandler Carruth563d4a42007-08-04 01:56:21 +00001401/* Line 216 of yacc.c. */
1402#line 1403 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001403
Chandler Carruth563d4a42007-08-04 01:56:21 +00001404#ifdef short
1405# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406#endif
1407
Chandler Carruth563d4a42007-08-04 01:56:21 +00001408#ifdef YYTYPE_UINT8
1409typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410#else
Chandler Carruth563d4a42007-08-04 01:56:21 +00001411typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412#endif
1413
Chandler Carruth563d4a42007-08-04 01:56:21 +00001414#ifdef YYTYPE_INT8
1415typedef YYTYPE_INT8 yytype_int8;
1416#elif (defined __STDC__ || defined __C99__FUNC__ \
1417 || defined __cplusplus || defined _MSC_VER)
1418typedef signed char yytype_int8;
1419#else
1420typedef short int yytype_int8;
1421#endif
1422
1423#ifdef YYTYPE_UINT16
1424typedef YYTYPE_UINT16 yytype_uint16;
1425#else
1426typedef unsigned short int yytype_uint16;
1427#endif
1428
1429#ifdef YYTYPE_INT16
1430typedef YYTYPE_INT16 yytype_int16;
1431#else
1432typedef short int yytype_int16;
1433#endif
1434
1435#ifndef YYSIZE_T
1436# ifdef __SIZE_TYPE__
1437# define YYSIZE_T __SIZE_TYPE__
1438# elif defined size_t
1439# define YYSIZE_T size_t
1440# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1441 || defined __cplusplus || defined _MSC_VER)
1442# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1443# define YYSIZE_T size_t
1444# else
1445# define YYSIZE_T unsigned int
1446# endif
1447#endif
1448
1449#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1450
1451#ifndef YY_
1452# if YYENABLE_NLS
1453# if ENABLE_NLS
1454# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1455# define YY_(msgid) dgettext ("bison-runtime", msgid)
1456# endif
1457# endif
1458# ifndef YY_
1459# define YY_(msgid) msgid
1460# endif
1461#endif
1462
1463/* Suppress unused-variable warnings by "using" E. */
1464#if ! defined lint || defined __GNUC__
1465# define YYUSE(e) ((void) (e))
1466#else
1467# define YYUSE(e) /* empty */
1468#endif
1469
1470/* Identity function, used to suppress warnings about constant conditions. */
1471#ifndef lint
1472# define YYID(n) (n)
1473#else
1474#if (defined __STDC__ || defined __C99__FUNC__ \
1475 || defined __cplusplus || defined _MSC_VER)
1476static int
1477YYID (int i)
1478#else
1479static int
1480YYID (i)
1481 int i;
1482#endif
1483{
1484 return i;
1485}
1486#endif
1487
1488#if ! defined yyoverflow || YYERROR_VERBOSE
1489
1490/* The parser invokes alloca or malloc; define the necessary symbols. */
1491
1492# ifdef YYSTACK_USE_ALLOCA
1493# if YYSTACK_USE_ALLOCA
1494# ifdef __GNUC__
1495# define YYSTACK_ALLOC __builtin_alloca
1496# elif defined __BUILTIN_VA_ARG_INCR
1497# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1498# elif defined _AIX
1499# define YYSTACK_ALLOC __alloca
1500# elif defined _MSC_VER
1501# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1502# define alloca _alloca
1503# else
1504# define YYSTACK_ALLOC alloca
1505# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1506 || defined __cplusplus || defined _MSC_VER)
1507# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1508# ifndef _STDLIB_H
1509# define _STDLIB_H 1
1510# endif
1511# endif
1512# endif
1513# endif
1514# endif
1515
1516# ifdef YYSTACK_ALLOC
1517 /* Pacify GCC's `empty if-body' warning. */
1518# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1519# ifndef YYSTACK_ALLOC_MAXIMUM
1520 /* The OS might guarantee only one guard page at the bottom of the stack,
1521 and a page size can be as small as 4096 bytes. So we cannot safely
1522 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1523 to allow for a few compiler-allocated temporary stack slots. */
1524# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1525# endif
1526# else
1527# define YYSTACK_ALLOC YYMALLOC
1528# define YYSTACK_FREE YYFREE
1529# ifndef YYSTACK_ALLOC_MAXIMUM
1530# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1531# endif
1532# if (defined __cplusplus && ! defined _STDLIB_H \
1533 && ! ((defined YYMALLOC || defined malloc) \
1534 && (defined YYFREE || defined free)))
1535# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1536# ifndef _STDLIB_H
1537# define _STDLIB_H 1
1538# endif
1539# endif
1540# ifndef YYMALLOC
1541# define YYMALLOC malloc
1542# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1543 || defined __cplusplus || defined _MSC_VER)
1544void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1545# endif
1546# endif
1547# ifndef YYFREE
1548# define YYFREE free
1549# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1550 || defined __cplusplus || defined _MSC_VER)
1551void free (void *); /* INFRINGES ON USER NAME SPACE */
1552# endif
1553# endif
1554# endif
1555#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1556
1557
1558#if (! defined yyoverflow \
1559 && (! defined __cplusplus \
1560 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1561
1562/* A type that is properly aligned for any stack member. */
1563union yyalloc
1564{
1565 yytype_int16 yyss;
1566 YYSTYPE yyvs;
1567 };
1568
1569/* The size of the maximum gap between one aligned stack and the next. */
1570# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1571
1572/* The size of an array large to enough to hold all stacks, each with
1573 N elements. */
1574# define YYSTACK_BYTES(N) \
1575 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1576 + YYSTACK_GAP_MAXIMUM)
1577
1578/* Copy COUNT objects from FROM to TO. The source and destination do
1579 not overlap. */
1580# ifndef YYCOPY
1581# if defined __GNUC__ && 1 < __GNUC__
1582# define YYCOPY(To, From, Count) \
1583 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1584# else
1585# define YYCOPY(To, From, Count) \
1586 do \
1587 { \
1588 YYSIZE_T yyi; \
1589 for (yyi = 0; yyi < (Count); yyi++) \
1590 (To)[yyi] = (From)[yyi]; \
1591 } \
1592 while (YYID (0))
1593# endif
1594# endif
1595
1596/* Relocate STACK from its old location to the new one. The
1597 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1598 elements in the stack, and YYPTR gives the new location of the
1599 stack. Advance YYPTR to a properly aligned location for the next
1600 stack. */
1601# define YYSTACK_RELOCATE(Stack) \
1602 do \
1603 { \
1604 YYSIZE_T yynewbytes; \
1605 YYCOPY (&yyptr->Stack, Stack, yysize); \
1606 Stack = &yyptr->Stack; \
1607 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1608 yyptr += yynewbytes / sizeof (*yyptr); \
1609 } \
1610 while (YYID (0))
1611
1612#endif
1613
1614/* YYFINAL -- State number of the termination state. */
1615#define YYFINAL 43
1616/* YYLAST -- Last index in YYTABLE. */
1617#define YYLAST 1685
1618
1619/* YYNTOKENS -- Number of terminals. */
1620#define YYNTOKENS 160
1621/* YYNNTS -- Number of nonterminals. */
1622#define YYNNTS 82
1623/* YYNRULES -- Number of rules. */
1624#define YYNRULES 310
1625/* YYNRULES -- Number of states. */
1626#define YYNSTATES 594
1627
1628/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1629#define YYUNDEFTOK 2
1630#define YYMAXUTOK 400
1631
1632#define YYTRANSLATE(YYX) \
1633 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1634
1635/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1636static const yytype_uint8 yytranslate[] =
1637{
1638 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1642 150, 151, 148, 2, 147, 2, 2, 2, 2, 2,
1643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1644 155, 146, 156, 2, 2, 2, 2, 2, 2, 2,
1645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1647 2, 152, 149, 154, 2, 2, 2, 2, 2, 159,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1650 153, 2, 2, 157, 2, 158, 2, 2, 2, 2,
1651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1661 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1662 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1663 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1664 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1665 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1666 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1667 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1668 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1669 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1670 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1671 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1672 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1673 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1674 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1675 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1676 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1677 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1678 145
1679};
1680
1681#if YYDEBUG
1682/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1683 YYRHS. */
1684static const yytype_uint16 yyprhs[] =
1685{
1686 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1687 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1688 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1689 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1690 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1691 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1692 119, 121, 123, 125, 127, 129, 130, 133, 134, 136,
1693 138, 140, 141, 144, 146, 148, 150, 152, 154, 156,
1694 158, 160, 161, 163, 165, 167, 168, 170, 172, 173,
1695 175, 177, 179, 181, 182, 184, 186, 187, 189, 191,
1696 193, 195, 197, 200, 202, 204, 206, 208, 210, 212,
1697 214, 216, 218, 219, 222, 224, 226, 228, 230, 231,
1698 234, 235, 238, 239, 243, 246, 247, 249, 250, 254,
1699 256, 259, 261, 263, 265, 267, 269, 271, 273, 275,
1700 277, 280, 282, 285, 291, 297, 303, 309, 313, 316,
1701 322, 327, 330, 332, 334, 336, 340, 342, 346, 348,
1702 349, 351, 355, 360, 364, 368, 373, 378, 382, 389,
1703 395, 398, 401, 404, 407, 410, 413, 416, 419, 422,
1704 425, 428, 431, 438, 444, 453, 460, 467, 475, 483,
1705 490, 499, 508, 512, 514, 516, 518, 520, 521, 524,
1706 531, 533, 534, 536, 539, 540, 544, 545, 549, 553,
1707 557, 561, 562, 570, 571, 580, 581, 590, 596, 599,
1708 603, 605, 609, 613, 617, 621, 623, 624, 630, 634,
1709 636, 640, 642, 643, 653, 655, 657, 662, 664, 666,
1710 669, 673, 674, 676, 678, 680, 682, 684, 686, 688,
1711 690, 692, 696, 698, 704, 706, 708, 710, 712, 714,
1712 716, 719, 722, 725, 729, 732, 733, 735, 738, 741,
1713 745, 755, 765, 774, 789, 791, 793, 800, 806, 809,
1714 816, 824, 828, 834, 835, 836, 840, 843, 845, 851,
1715 857, 864, 871, 876, 883, 888, 893, 900, 907, 910,
1716 919, 921, 923, 924, 928, 935, 939, 946, 949, 955,
1717 963
1718};
1719
1720/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1721static const yytype_int16 yyrhs[] =
1722{
1723 204, 0, -1, 73, -1, 74, -1, 75, -1, 76,
1724 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1725 -1, 85, -1, 86, -1, 87, -1, 82, -1, 83,
1726 -1, 84, -1, 116, -1, 117, -1, 118, -1, 119,
1727 -1, 120, -1, 121, -1, 122, -1, 123, -1, 124,
1728 -1, 125, -1, 126, -1, 127, -1, 90, -1, 91,
1729 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1730 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1731 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1732 -1, 107, -1, 108, -1, 109, -1, 96, -1, 97,
1733 -1, 98, -1, 99, -1, 26, -1, 27, -1, 11,
1734 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1735 -1, 19, -1, 22, -1, 24, -1, 168, -1, -1,
1736 168, 146, -1, -1, 20, -1, 23, -1, 173, -1,
1737 -1, 171, 146, -1, 42, -1, 44, -1, 43, -1,
1738 45, -1, 47, -1, 46, -1, 48, -1, 50, -1,
1739 -1, 143, -1, 144, -1, 145, -1, -1, 46, -1,
1740 48, -1, -1, 42, -1, 43, -1, 44, -1, 47,
1741 -1, -1, 44, -1, 42, -1, -1, 61, -1, 62,
1742 -1, 63, -1, 64, -1, 65, -1, 60, 4, -1,
1743 135, -1, 117, -1, 134, -1, 118, -1, 137, -1,
1744 138, -1, 140, -1, 141, -1, 142, -1, -1, 182,
1745 181, -1, 136, -1, 139, -1, 135, -1, 134, -1,
1746 -1, 184, 183, -1, -1, 53, 4, -1, -1, 147,
1747 53, 4, -1, 34, 22, -1, -1, 187, -1, -1,
1748 147, 190, 189, -1, 187, -1, 53, 4, -1, 11,
1749 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1750 -1, 17, -1, 49, -1, 191, -1, 192, 148, -1,
1751 226, -1, 149, 4, -1, 192, 150, 196, 151, 184,
1752 -1, 10, 150, 196, 151, 184, -1, 152, 4, 153,
1753 192, 154, -1, 155, 4, 153, 192, 156, -1, 157,
1754 197, 158, -1, 157, 158, -1, 155, 157, 197, 158,
1755 156, -1, 155, 157, 158, 156, -1, 192, 182, -1,
1756 192, -1, 10, -1, 193, -1, 195, 147, 193, -1,
1757 195, -1, 195, 147, 39, -1, 39, -1, -1, 192,
1758 -1, 197, 147, 192, -1, 192, 152, 200, 154, -1,
1759 192, 152, 154, -1, 192, 159, 22, -1, 192, 155,
1760 200, 156, -1, 192, 157, 200, 158, -1, 192, 157,
1761 158, -1, 192, 155, 157, 200, 158, 156, -1, 192,
1762 155, 157, 158, 156, -1, 192, 40, -1, 192, 41,
1763 -1, 192, 226, -1, 192, 199, -1, 192, 25, -1,
1764 166, 3, -1, 166, 5, -1, 166, 4, -1, 166,
1765 6, -1, 11, 26, -1, 11, 27, -1, 167, 9,
1766 -1, 163, 150, 198, 38, 192, 151, -1, 115, 150,
1767 198, 237, 151, -1, 129, 150, 198, 147, 198, 147,
1768 198, 151, -1, 161, 150, 198, 147, 198, 151, -1,
1769 162, 150, 198, 147, 198, 151, -1, 88, 164, 150,
1770 198, 147, 198, 151, -1, 89, 165, 150, 198, 147,
1771 198, 151, -1, 131, 150, 198, 147, 198, 151, -1,
1772 132, 150, 198, 147, 198, 147, 198, 151, -1, 133,
1773 150, 198, 147, 198, 147, 198, 151, -1, 200, 147,
1774 198, -1, 198, -1, 32, -1, 33, -1, 37, -1,
1775 -1, 194, 226, -1, 121, 150, 203, 38, 192, 151,
1776 -1, 205, -1, -1, 206, -1, 205, 206, -1, -1,
1777 31, 207, 222, -1, -1, 30, 208, 223, -1, 58,
1778 57, 212, -1, 170, 18, 192, -1, 170, 18, 10,
1779 -1, -1, 172, 176, 202, 201, 198, 209, 189, -1,
1780 -1, 172, 174, 176, 202, 201, 198, 210, 189, -1,
1781 -1, 172, 175, 176, 202, 201, 192, 211, 189, -1,
1782 172, 176, 35, 179, 203, -1, 51, 213, -1, 54,
1783 146, 214, -1, 22, -1, 52, 146, 22, -1, 66,
1784 146, 22, -1, 152, 215, 154, -1, 215, 147, 22,
1785 -1, 22, -1, -1, 216, 147, 192, 182, 169, -1,
1786 192, 182, 169, -1, 216, -1, 216, 147, 39, -1,
1787 39, -1, -1, 180, 194, 171, 150, 217, 151, 184,
1788 188, 185, -1, 28, -1, 157, -1, 178, 176, 218,
1789 219, -1, 29, -1, 158, -1, 229, 221, -1, 177,
1790 176, 218, -1, -1, 59, -1, 3, -1, 4, -1,
1791 9, -1, 26, -1, 27, -1, 40, -1, 41, -1,
1792 25, -1, 155, 200, 156, -1, 199, -1, 57, 224,
1793 22, 147, 22, -1, 7, -1, 8, -1, 168, -1,
1794 171, -1, 226, -1, 225, -1, 192, 227, -1, 229,
1795 230, -1, 220, 230, -1, 231, 170, 232, -1, 231,
1796 234, -1, -1, 21, -1, 67, 228, -1, 67, 10,
1797 -1, 68, 17, 227, -1, 68, 11, 227, 147, 17,
1798 227, 147, 17, 227, -1, 69, 166, 227, 147, 17,
1799 227, 152, 233, 154, -1, 69, 166, 227, 147, 17,
1800 227, 152, 154, -1, 70, 180, 194, 227, 150, 236,
1801 151, 184, 38, 17, 227, 71, 17, 227, -1, 71,
1802 -1, 72, -1, 233, 166, 225, 147, 17, 227, -1,
1803 166, 225, 147, 17, 227, -1, 170, 239, -1, 192,
1804 152, 227, 147, 227, 154, -1, 235, 147, 152, 227,
1805 147, 227, 154, -1, 192, 227, 182, -1, 236, 147,
1806 192, 227, 182, -1, -1, -1, 237, 147, 228, -1,
1807 56, 55, -1, 55, -1, 161, 192, 227, 147, 227,
1808 -1, 162, 192, 227, 147, 227, -1, 88, 164, 192,
1809 227, 147, 227, -1, 89, 165, 192, 227, 147, 227,
1810 -1, 163, 228, 38, 192, -1, 129, 228, 147, 228,
1811 147, 228, -1, 130, 228, 147, 192, -1, 131, 228,
1812 147, 228, -1, 132, 228, 147, 228, 147, 228, -1,
1813 133, 228, 147, 228, 147, 228, -1, 128, 235, -1,
1814 238, 180, 194, 227, 150, 236, 151, 184, -1, 241,
1815 -1, 36, -1, -1, 110, 192, 186, -1, 110, 192,
1816 147, 11, 227, 186, -1, 111, 192, 186, -1, 111,
1817 192, 147, 11, 227, 186, -1, 112, 228, -1, 240,
1818 113, 192, 227, 186, -1, 240, 114, 228, 147, 192,
1819 227, 186, -1, 115, 192, 227, 237, -1
1820};
1821
1822/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1823static const yytype_uint16 yyrline[] =
1824{
1825 0, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122,
1826 1122, 1123, 1123, 1123, 1123, 1123, 1123, 1124, 1124, 1124,
1827 1124, 1124, 1124, 1125, 1125, 1125, 1125, 1125, 1125, 1128,
1828 1128, 1129, 1129, 1130, 1130, 1131, 1131, 1132, 1132, 1136,
1829 1136, 1137, 1137, 1138, 1138, 1139, 1139, 1140, 1140, 1141,
1830 1141, 1142, 1142, 1143, 1144, 1149, 1150, 1150, 1150, 1150,
1831 1150, 1152, 1152, 1152, 1153, 1153, 1157, 1161, 1166, 1166,
1832 1168, 1169, 1174, 1180, 1181, 1182, 1183, 1184, 1188, 1189,
1833 1190, 1194, 1195, 1196, 1197, 1201, 1202, 1203, 1207, 1208,
1834 1209, 1210, 1211, 1215, 1216, 1217, 1220, 1221, 1222, 1223,
1835 1224, 1225, 1226, 1233, 1234, 1235, 1236, 1237, 1238, 1239,
1836 1240, 1241, 1244, 1245, 1250, 1251, 1252, 1253, 1256, 1257,
1837 1264, 1265, 1271, 1272, 1280, 1288, 1289, 1294, 1295, 1296,
1838 1301, 1314, 1314, 1314, 1314, 1314, 1314, 1314, 1317, 1321,
1839 1325, 1332, 1337, 1345, 1375, 1406, 1411, 1423, 1433, 1437,
1840 1447, 1454, 1461, 1468, 1473, 1478, 1485, 1486, 1493, 1500,
1841 1508, 1514, 1526, 1554, 1570, 1597, 1625, 1651, 1671, 1697,
1842 1717, 1729, 1736, 1802, 1812, 1822, 1828, 1838, 1844, 1854,
1843 1859, 1864, 1872, 1884, 1906, 1914, 1920, 1931, 1936, 1941,
1844 1947, 1953, 1962, 1966, 1974, 1974, 1977, 1977, 1980, 1991,
1845 2012, 2017, 2025, 2026, 2030, 2030, 2034, 2034, 2037, 2040,
1846 2064, 2075, 2075, 2086, 2085, 2095, 2094, 2105, 2124, 2127,
1847 2133, 2143, 2147, 2152, 2154, 2159, 2164, 2173, 2183, 2194,
1848 2198, 2207, 2216, 2221, 2342, 2342, 2344, 2353, 2353, 2355,
1849 2360, 2372, 2376, 2381, 2385, 2389, 2393, 2397, 2401, 2405,
1850 2409, 2413, 2438, 2442, 2452, 2456, 2460, 2465, 2472, 2472,
1851 2478, 2487, 2491, 2500, 2509, 2518, 2522, 2529, 2533, 2537,
1852 2542, 2552, 2571, 2580, 2660, 2664, 2671, 2682, 2695, 2705,
1853 2716, 2726, 2735, 2744, 2747, 2748, 2755, 2759, 2764, 2785,
1854 2802, 2816, 2830, 2842, 2850, 2857, 2863, 2869, 2875, 2890,
1855 2975, 2980, 2984, 2991, 2998, 3006, 3013, 3021, 3029, 3043,
1856 3060
1857};
1858#endif
1859
1860#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1861/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1862 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1863static const char *const yytname[] =
1864{
1865 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1866 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1867 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1868 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1869 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1870 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1871 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1872 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1873 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1874 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1875 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1876 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1877 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1878 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1879 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1880 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1881 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1882 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1883 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1884 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1885 "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN",
1886 "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "DEFAULT",
1887 "HIDDEN", "PROTECTED", "'='", "','", "'*'", "'\\\\'", "'('", "')'",
1888 "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1889 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1890 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1891 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1892 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1893 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1894 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1895 "SectionString", "OptSection", "GlobalVarAttributes",
1896 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1897 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1898 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1899 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1900 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1901 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1902 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1903 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1904 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1905 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1906 "OptVolatile", "MemoryInst", 0
1907};
1908#endif
1909
1910# ifdef YYPRINT
1911/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1912 token YYLEX-NUM. */
1913static const yytype_uint16 yytoknum[] =
1914{
1915 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1916 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1917 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1918 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1919 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1920 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1921 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1922 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1923 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1924 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1925 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1926 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1927 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1928 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1929 395, 396, 397, 398, 399, 400, 61, 44, 42, 92,
1930 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
1931};
1932# endif
1933
1934/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1935static const yytype_uint8 yyr1[] =
1936{
1937 0, 160, 161, 161, 161, 161, 161, 161, 161, 161,
1938 161, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1939 163, 163, 163, 163, 163, 163, 163, 163, 163, 164,
1940 164, 164, 164, 164, 164, 164, 164, 164, 164, 165,
1941 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
1942 165, 165, 165, 165, 165, 166, 167, 167, 167, 167,
1943 167, 168, 168, 168, 169, 169, 170, 170, 171, 171,
1944 172, 172, 173, 174, 174, 174, 174, 174, 175, 175,
1945 175, 176, 176, 176, 176, 177, 177, 177, 178, 178,
1946 178, 178, 178, 179, 179, 179, 180, 180, 180, 180,
1947 180, 180, 180, 181, 181, 181, 181, 181, 181, 181,
1948 181, 181, 182, 182, 183, 183, 183, 183, 184, 184,
1949 185, 185, 186, 186, 187, 188, 188, 189, 189, 190,
1950 190, 191, 191, 191, 191, 191, 191, 191, 192, 192,
1951 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1952 192, 193, 194, 194, 195, 195, 196, 196, 196, 196,
1953 197, 197, 198, 198, 198, 198, 198, 198, 198, 198,
1954 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1955 198, 198, 199, 199, 199, 199, 199, 199, 199, 199,
1956 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1957 204, 204, 205, 205, 207, 206, 208, 206, 206, 206,
1958 206, 209, 206, 210, 206, 211, 206, 206, 206, 206,
1959 212, 213, 213, 214, 215, 215, 215, 216, 216, 217,
1960 217, 217, 217, 218, 219, 219, 220, 221, 221, 222,
1961 223, 224, 224, 225, 225, 225, 225, 225, 225, 225,
1962 225, 225, 225, 225, 226, 226, 226, 226, 227, 227,
1963 228, 229, 229, 230, 231, 231, 231, 232, 232, 232,
1964 232, 232, 232, 232, 232, 232, 233, 233, 234, 235,
1965 235, 236, 236, 236, 237, 237, 238, 238, 239, 239,
1966 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
1967 239, 240, 240, 241, 241, 241, 241, 241, 241, 241,
1968 241
1969};
1970
1971/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1972static const yytype_uint8 yyr2[] =
1973{
1974 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1975 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1976 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1977 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1978 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1979 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1980 1, 1, 1, 1, 1, 0, 2, 0, 1, 1,
1981 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1982 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1983 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1984 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1985 1, 1, 0, 2, 1, 1, 1, 1, 0, 2,
1986 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1987 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1988 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1989 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1990 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1991 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1992 2, 2, 6, 5, 8, 6, 6, 7, 7, 6,
1993 8, 8, 3, 1, 1, 1, 1, 0, 2, 6,
1994 1, 0, 1, 2, 0, 3, 0, 3, 3, 3,
1995 3, 0, 7, 0, 8, 0, 8, 5, 2, 3,
1996 1, 3, 3, 3, 3, 1, 0, 5, 3, 1,
1997 3, 1, 0, 9, 1, 1, 4, 1, 1, 2,
1998 3, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1999 1, 3, 1, 5, 1, 1, 1, 1, 1, 1,
2000 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
2001 9, 9, 8, 14, 1, 1, 6, 5, 2, 6,
2002 7, 3, 5, 0, 0, 3, 2, 1, 5, 5,
2003 6, 6, 4, 6, 4, 4, 6, 6, 2, 8,
2004 1, 1, 0, 3, 6, 3, 6, 2, 5, 7,
2005 4
2006};
2007
2008/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2009 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2010 means the default is an error. */
2011static const yytype_uint16 yydefact[] =
2012{
2013 71, 61, 68, 62, 69, 63, 206, 204, 0, 0,
2014 0, 0, 0, 0, 81, 70, 0, 71, 202, 85,
2015 88, 0, 0, 218, 0, 0, 66, 0, 72, 73,
2016 75, 74, 76, 78, 77, 79, 80, 82, 83, 84,
2017 81, 81, 197, 1, 203, 86, 87, 81, 207, 89,
2018 90, 91, 92, 81, 265, 205, 265, 0, 0, 226,
2019 219, 220, 208, 254, 255, 210, 131, 132, 133, 136,
2020 135, 134, 137, 138, 0, 0, 0, 0, 256, 257,
2021 139, 209, 141, 197, 197, 93, 196, 0, 96, 96,
2022 266, 262, 67, 237, 238, 239, 261, 221, 222, 225,
2023 0, 159, 142, 0, 0, 0, 0, 148, 160, 0,
2024 140, 159, 0, 0, 95, 94, 0, 194, 195, 0,
2025 0, 97, 98, 99, 100, 101, 0, 240, 0, 302,
2026 264, 0, 223, 158, 112, 154, 156, 0, 0, 0,
2027 0, 0, 0, 147, 0, 0, 0, 153, 0, 152,
2028 0, 217, 131, 132, 133, 136, 135, 134, 0, 0,
2029 0, 211, 102, 0, 234, 235, 236, 301, 287, 0,
2030 0, 0, 0, 96, 274, 275, 2, 3, 4, 5,
2031 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
2032 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
2033 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
2034 0, 0, 0, 0, 0, 0, 0, 0, 263, 96,
2035 278, 0, 300, 224, 151, 0, 118, 0, 0, 150,
2036 0, 161, 118, 213, 215, 0, 198, 179, 180, 175,
2037 177, 176, 178, 181, 174, 170, 171, 0, 0, 0,
2038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2039 0, 173, 172, 127, 0, 286, 268, 0, 267, 0,
2040 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2041 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2042 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2043 48, 0, 122, 122, 307, 0, 0, 298, 0, 0,
2044 0, 0, 0, 0, 0, 0, 0, 0, 0, 104,
2045 106, 105, 103, 107, 108, 109, 110, 111, 113, 157,
2046 155, 144, 145, 146, 149, 143, 127, 127, 0, 0,
2047 0, 0, 0, 0, 0, 0, 163, 193, 0, 0,
2048 0, 167, 0, 164, 0, 0, 0, 0, 212, 232,
2049 243, 244, 245, 250, 246, 247, 248, 249, 241, 0,
2050 252, 259, 258, 260, 0, 269, 0, 0, 0, 0,
2051 0, 303, 0, 305, 284, 0, 0, 0, 0, 0,
2052 0, 0, 0, 0, 0, 0, 0, 0, 117, 116,
2053 114, 115, 119, 214, 216, 0, 0, 0, 284, 0,
2054 0, 0, 0, 0, 162, 148, 160, 0, 165, 166,
2055 0, 0, 0, 0, 0, 129, 127, 231, 112, 229,
2056 0, 242, 0, 0, 0, 0, 0, 0, 0, 0,
2057 0, 0, 310, 0, 0, 0, 294, 295, 0, 0,
2058 0, 0, 292, 0, 122, 0, 0, 0, 0, 0,
2059 0, 0, 0, 0, 192, 169, 0, 0, 0, 0,
2060 124, 130, 128, 65, 0, 118, 0, 251, 0, 0,
2061 283, 0, 0, 122, 123, 122, 0, 0, 0, 0,
2062 0, 0, 288, 289, 283, 0, 308, 0, 199, 0,
2063 0, 183, 0, 0, 0, 0, 168, 0, 0, 0,
2064 64, 228, 230, 112, 125, 0, 0, 0, 0, 0,
2065 290, 291, 304, 306, 285, 0, 0, 293, 296, 297,
2066 0, 122, 0, 0, 0, 189, 0, 0, 185, 186,
2067 182, 65, 126, 120, 253, 0, 0, 112, 0, 118,
2068 279, 0, 118, 309, 187, 188, 0, 0, 0, 227,
2069 0, 233, 0, 272, 0, 0, 281, 0, 0, 280,
2070 299, 184, 190, 191, 121, 270, 0, 271, 0, 112,
2071 0, 0, 0, 282, 0, 0, 0, 0, 277, 0,
2072 0, 276, 0, 273
2073};
2074
2075/* YYDEFGOTO[NTERM-NUM]. */
2076static const yytype_int16 yydefgoto[] =
2077{
2078 -1, 258, 259, 260, 284, 301, 158, 159, 78, 511,
2079 12, 79, 14, 15, 40, 41, 42, 47, 53, 116,
2080 126, 328, 224, 402, 331, 561, 381, 425, 543, 358,
2081 426, 80, 160, 135, 150, 136, 137, 109, 347, 370,
2082 348, 119, 87, 151, 16, 17, 18, 20, 19, 263,
2083 336, 337, 62, 23, 60, 100, 429, 430, 127, 166,
2084 54, 95, 55, 48, 432, 371, 82, 373, 268, 56,
2085 91, 92, 218, 565, 130, 307, 519, 442, 219, 220,
2086 221, 222
2087};
2088
2089/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2090 STATE-NUM. */
2091#define YYPACT_NINF -529
2092static const yytype_int16 yypact[] =
2093{
2094 40, -529, -529, -529, -529, -529, -529, -529, -17, -107,
2095 12, -64, 78, -40, 183, -529, 150, 370, -529, 147,
2096 115, -5, 26, -529, 14, 132, -529, 1319, -529, -529,
2097 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
2098 -90, -90, 173, -529, -529, -529, -529, -90, -529, -529,
2099 -529, -529, -529, -90, 154, -529, -7, 179, 197, 214,
2100 -529, -529, -529, -529, -529, 96, -529, -529, -529, -529,
2101 -529, -529, -529, -529, 253, 258, 3, 791, -529, -529,
2102 -529, 145, -529, 228, 228, 287, -529, 191, 189, 189,
2103 -529, -529, 109, -529, -529, -529, -529, -529, -529, -529,
2104 -66, 1052, -529, 125, 135, 835, 96, -529, 145, -110,
2105 -529, 1052, 191, 191, -529, -529, 1092, -529, -529, 1359,
2106 285, -529, -529, -529, -529, -529, 1377, -529, -12, 1525,
2107 -529, 272, -529, -529, 145, -529, 153, 152, 1430, 1430,
2108 168, -106, 1430, -529, 157, 1359, 1430, 96, 159, 145,
2109 102, -529, 39, 321, 323, 325, 326, 327, 266, 328,
2110 750, -529, -529, 141, -529, -529, -529, -529, -529, 288,
2111 1470, 94, 329, 189, -529, -529, -529, -529, -529, -529,
2112 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
2113 -529, 222, 625, 1430, 1430, 1430, 1430, -529, -529, -529,
2114 -529, -529, -529, -529, -529, -529, -529, -529, -529, 1430,
2115 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, -529, 189,
2116 -529, 128, -529, -529, 126, 1110, -529, -53, -72, -529,
2117 188, 145, -529, -529, 145, 1092, -529, -529, -529, -529,
2118 -529, -529, -529, -529, -529, -529, -529, 222, 625, 195,
2119 196, 200, 201, 202, 1204, 1528, 1012, 331, 204, 206,
2120 208, -529, -529, 212, 210, -529, 96, 486, -529, 623,
2121 623, -529, 623, 1377, -529, -529, -529, -529, -529, -529,
2122 -529, -529, -529, -529, 1430, -529, -529, -529, -529, -529,
2123 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
2124 -529, 1430, -1, 32, -529, 486, 52, 219, 220, 224,
2125 227, 230, 233, 486, 486, 343, 1377, 1430, 1430, -529,
2126 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
2127 -529, 77, -529, -529, -529, 77, 212, 212, 344, 234,
2128 235, 1359, 1359, 1359, 1359, 1359, -529, -529, -61, 1031,
2129 -100, -529, -101, -529, 1359, 1359, 1359, -19, -529, 1261,
2130 -529, -529, -529, -529, -529, -529, -529, -529, 310, 1359,
2131 -529, -529, -529, -529, 236, -529, 240, 623, 486, 486,
2132 20, -529, 21, -529, -529, 623, 239, 1430, 1430, 1430,
2133 1430, 1430, 249, 250, 1430, 623, 486, 251, -529, -529,
2134 -529, -529, -529, -529, -529, 1430, 1359, 1359, -529, 252,
2135 259, 260, 264, 1359, -529, 256, 750, -75, -529, -529,
2136 267, 268, 375, 396, 415, -529, 212, -529, 145, 273,
2137 274, -529, 401, -79, 409, 413, 281, 286, 289, 623,
2138 428, 623, 290, 291, 623, 292, 145, -529, 293, 299,
2139 623, 623, 145, 284, 300, 1430, 84, 303, 304, -44,
2140 1359, 1359, 1359, 1359, -529, -529, 279, 1359, 1359, 1430,
2141 -529, -529, -529, 80, 1279, -529, 306, -529, 623, 623,
2142 1430, 623, 623, 300, -529, 300, 1430, 623, 308, 1430,
2143 1430, 1430, -529, -529, 1430, 403, -529, 486, -529, 1359,
2144 1359, -529, 311, 315, 312, 314, -529, 316, 318, 129,
2145 -529, -529, -529, 145, 4, 435, 324, 320, 486, -33,
2146 -529, -529, -529, -529, -529, 330, 623, -529, -529, -529,
2147 -32, 300, 319, 332, 1359, -529, 1359, 1359, -529, -529,
2148 -529, 80, -529, 421, -529, 445, -2, -529, 1430, -529,
2149 -529, 333, -529, -529, -529, -529, 334, 335, 340, -529,
2150 471, -529, 623, -529, 885, 2, 126, 486, 42, -529,
2151 77, -529, -529, -529, -529, -529, 345, -529, 885, -529,
2152 460, 479, 350, 126, 623, 623, 483, 430, -529, 623,
2153 485, -529, 623, -529
2154};
2155
2156/* YYPGOTO[NTERM-NUM]. */
2157static const yytype_int16 yypgoto[] =
2158{
2159 -529, 374, 378, 385, 257, 269, -170, -529, 0, -25,
2160 423, 8, -529, -529, -529, -529, 95, -529, -529, -529,
2161 -152, -529, -424, -529, -227, -529, -291, 5, -529, -318,
2162 -529, -529, -26, 295, -120, -529, 407, 416, -58, -157,
2163 -232, 161, 198, 294, -529, -529, 506, -529, -529, -529,
2164 -529, -529, -529, -529, -529, -529, -529, -529, 436, -529,
2165 -529, -529, -529, -529, -529, -528, -140, 103, -184, -529,
2166 468, -529, -529, -529, -529, -529, 34, 122, -529, -529,
2167 -529, -529
2168};
2169
2170/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2171 positive, shift that token. If negative, reduce the rule which
2172 number is the opposite. If zero, do what YYDEFACT says.
2173 If YYTABLE_NINF, syntax error. */
2174#define YYTABLE_NINF -202
2175static const yytype_int16 yytable[] =
2176{
2177 11, 81, 272, 261, 473, 335, 163, 104, 13, 271,
2178 236, 304, 383, 271, 90, 423, 164, 11, 403, 404,
2179 262, 273, 93, 350, 352, 13, 308, 309, 310, 311,
2180 312, 439, 441, 315, 424, 21, 576, 142, 423, 24,
2181 -201, 142, -55, -55, -55, -55, 413, 413, 143, 22,
2182 582, 108, 230, 37, 38, 39, 418, 419, -67, 1,
2183 2, 161, 3, 4, 5, 237, 238, 316, 413, 25,
2184 6, 7, 413, 440, 440, 134, 110, 477, 111, 108,
2185 580, 131, 26, 466, 333, 134, 413, 233, 132, 541,
2186 149, 8, 11, 414, 9, 110, 27, 111, 10, 1,
2187 149, 332, 3, 486, 5, 269, 28, 501, 472, 63,
2188 64, 270, 227, 228, 548, 548, 231, 417, 549, 552,
2189 234, 1, 2, 566, 3, 4, 5, 372, 1, 372,
2190 372, 3, 372, 5, 397, 83, 84, 433, 398, 399,
2191 400, 57, 88, 401, 267, 165, 380, 110, 89, 111,
2192 43, 94, 563, 377, 61, 583, 577, 49, 50, 51,
2193 105, 2, 52, 496, 4, 372, 59, 302, 303, 267,
2194 305, 264, 58, 372, 372, 90, 398, 399, 400, 382,
2195 110, 401, 111, 306, 267, 267, 267, 267, 267, 313,
2196 314, 267, 522, 45, 523, 46, 395, 319, 320, 134,
2197 110, 97, 111, 445, 385, 447, 448, 449, 85, 149,
2198 86, 398, 399, 400, 321, 322, 401, 323, 324, 98,
2199 325, 326, 327, 117, 118, 29, 30, 31, 32, 33,
2200 34, 35, 110, 36, 111, 498, 99, 372, 372, 372,
2201 553, 317, 318, 319, 320, 372, 101, 149, 514, 120,
2202 121, 122, 123, 124, 125, 372, 372, 102, 378, 261,
2203 321, 322, 103, 323, 324, 86, 325, 326, 327, 239,
2204 240, 241, 242, 145, 146, 379, 262, 110, 138, 111,
2205 540, 112, 113, 408, 409, 410, 411, 412, 139, 162,
2206 149, 396, 267, 110, 223, 111, 420, 421, 422, 372,
2207 225, 372, 524, 226, 372, 527, 528, 529, 232, 235,
2208 372, 372, 274, 275, 276, 277, 278, 279, 280, 281,
2209 282, 283, 568, 416, 229, 570, 37, 38, 39, 114,
2210 -56, 115, -57, 428, -60, -59, -58, 243, 372, 372,
2211 271, 372, 372, 265, 334, 341, 342, 372, 457, 458,
2212 343, 344, 345, 353, 354, 464, 355, 372, 356, 357,
2213 359, 267, 446, 267, 267, 267, 386, 387, 452, 431,
2214 -200, 388, 374, 375, 389, 376, 564, 390, 372, 456,
2215 391, 394, 405, 434, 406, 407, 372, 435, -67, 1,
2216 2, 444, 3, 4, 5, 578, 450, 451, 455, 460,
2217 6, 7, 502, 503, 504, 505, 461, 462, 384, 507,
2218 508, 463, 465, 469, 467, 468, 392, 393, 470, 471,
2219 474, 8, 372, 476, 9, 475, 478, 372, 10, 497,
2220 479, 480, 484, 481, 494, 506, 482, 486, 487, 489,
2221 490, 532, 533, 509, 372, 372, 491, 495, 513, 372,
2222 499, 500, 372, 515, 518, 526, 440, 544, 534, 536,
2223 267, 537, 562, 267, 267, 267, 535, 538, 518, 539,
2224 554, 545, 546, 510, 560, 574, 556, 584, 557, 558,
2225 436, 437, 438, 555, 550, 571, 572, 569, 443, 360,
2226 361, 573, 581, 63, 64, 362, 585, 586, 453, 454,
2227 589, 590, 592, 215, 339, 1, 2, 216, 3, 4,
2228 5, 363, 364, 365, 217, 129, 559, 340, 144, 542,
2229 330, 141, 567, 44, 96, 128, 366, 367, 530, 338,
2230 459, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2231 0, 510, 483, 368, 485, 0, 0, 488, 0, 0,
2232 0, 0, 0, 492, 493, 0, 0, 0, 0, 176,
2233 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
2234 187, 188, 189, 190, 247, 248, 0, 0, 0, 0,
2235 0, 516, 517, 0, 520, 521, 0, 0, 0, 0,
2236 525, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2237 531, 249, 197, 198, 199, 200, 201, 202, 203, 204,
2238 205, 206, 207, 208, 0, 250, 0, 251, 252, 253,
2239 0, 547, 0, 0, 0, 0, 360, 361, 0, 551,
2240 63, 64, 362, 0, 110, 0, 111, 0, 0, 0,
2241 0, 369, 1, 2, 0, 3, 4, 5, 363, 364,
2242 365, 285, 286, 0, 0, 0, 0, 0, 0, 0,
2243 0, 0, 0, 366, 367, 575, 0, 0, 0, 0,
2244 579, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2245 368, 0, 0, 0, 0, 0, 0, 587, 588, 0,
2246 0, 0, 591, 0, 0, 593, 176, 177, 178, 179,
2247 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2248 190, 247, 248, 0, 0, 0, 0, 0, 0, 0,
2249 0, 287, 288, 289, 290, 291, 292, 293, 294, 295,
2250 296, 297, 298, 299, 300, 0, 0, 0, 249, 197,
2251 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
2252 208, 0, 250, 0, 251, 252, 253, 63, 64, 0,
2253 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
2254 2, 0, 3, 4, 5, 244, 0, 0, 369, 0,
2255 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2256 245, 246, 0, 0, 0, 0, 0, 0, 63, 64,
2257 0, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2258 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2259 0, 0, 0, 176, 177, 178, 179, 180, 181, 182,
2260 183, 184, 185, 186, 187, 188, 189, 190, 247, 248,
2261 73, 0, 63, 64, 0, 106, 66, 67, 68, 69,
2262 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2263 0, 0, 0, 0, 0, 249, 197, 198, 199, 200,
2264 201, 202, 203, 204, 205, 206, 207, 208, 0, 250,
2265 0, 251, 252, 253, 73, 0, 0, 0, 360, 361,
2266 0, 0, 0, 0, 362, 0, 0, 0, 110, 0,
2267 111, 0, 254, 0, 0, 255, 0, 256, 0, 257,
2268 363, 364, 365, 0, 0, 0, 0, 0, 0, 0,
2269 0, 0, 0, 0, 0, 366, 367, 0, 0, 0,
2270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2271 74, 0, 368, 75, 0, 0, 76, 0, 77, 107,
2272 0, 0, 0, 0, 0, 0, 0, 0, 176, 177,
2273 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2274 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2275 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2276 76, 0, 77, 140, 0, 0, 0, 0, 0, 0,
2277 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2278 206, 207, 208, 0, 250, 0, 251, 252, 253, 63,
2279 64, 0, 106, 152, 153, 154, 155, 156, 157, 72,
2280 0, 1, 2, 0, 3, 4, 5, 0, 63, 64,
2281 369, 106, 152, 153, 154, 155, 156, 157, 72, 0,
2282 1, 2, 0, 3, 4, 5, 0, 0, 0, 63,
2283 64, 73, 106, 66, 67, 68, 69, 70, 71, 72,
2284 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2285 73, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2286 0, 133, 0, 0, 0, 0, 0, 0, 0, 63,
2287 64, 73, 147, 66, 67, 68, 69, 70, 71, 72,
2288 0, 1, 2, 0, 3, 4, 5, 63, 64, 0,
2289 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2290 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2291 0, 73, 0, 0, 0, 0, 0, 0, 0, 329,
2292 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
2293 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2294 351, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2295 74, 0, 0, 75, 0, 0, 76, 0, 77, 415,
2296 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2297 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2298 0, 63, 64, 148, 106, 152, 153, 154, 155, 156,
2299 157, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2301 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2302 0, 0, 0, 73, 0, 0, 0, 0, 0, 74,
2303 0, 0, 75, 0, 0, 76, 0, 77, 63, 64,
2304 0, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2305 1, 2, 0, 3, 4, 5, 63, 64, 0, 106,
2306 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2307 427, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2308 73, 0, 0, 0, 0, 0, 0, 0, 512, 0,
2309 0, 0, 0, 0, 0, 0, 63, 64, 73, 65,
2310 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2311 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2312 0, 0, 0, 74, 0, 0, 75, 0, 346, 76,
2313 0, 77, 0, 0, 0, 0, 63, 64, 73, 106,
2314 152, 153, 154, 155, 156, 157, 72, 0, 1, 2,
2315 0, 3, 4, 5, 63, 64, 0, 147, 66, 67,
2316 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2317 4, 5, 0, 0, 0, 0, 0, 0, 73, 0,
2318 74, 0, 0, 75, 0, 0, 76, 0, 77, 0,
2319 0, 0, 0, 0, 0, 0, 73, 0, 74, 0,
2320 0, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2321 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2322 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2323 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2324 0, 75, 0, 0, 76, 0, 77, 63, 64, 73,
2325 266, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2326 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2327 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2328 0, 75, 0, 0, 76, 0, 77, 0, 0, 73,
2329 0, 0, 0, 0, 0, 0, 74, 0, 0, 75,
2330 0, 0, 76, 0, 77, 63, 64, 0, 106, 152,
2331 153, 154, 155, 156, 157, 72, 0, 1, 2, 0,
2332 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2333 0, 167, 0, 0, 0, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 0, 0, 73, 0, 74,
2335 168, 169, 75, 0, 0, 76, 0, 77, 0, 0,
2336 0, 0, 170, 171, 172, 173, 174, 175, 176, 177,
2337 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2338 188, 189, 190, 191, 192, 0, 0, 0, 0, 74,
2339 0, 0, 75, 0, 0, 76, 0, 77, 0, 0,
2340 0, 0, 0, 0, 0, 193, 194, 195, 0, 0,
2341 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2342 206, 207, 208, 209, 210, 211, 212, 213, 214, 0,
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2345 75, 0, 0, 76, 0, 349
2346};
2347
2348static const yytype_int16 yycheck[] =
2349{
2350 0, 27, 172, 160, 428, 232, 126, 4, 0, 11,
2351 150, 195, 303, 11, 21, 34, 28, 17, 336, 337,
2352 160, 173, 29, 255, 256, 17, 210, 211, 212, 213,
2353 214, 11, 11, 217, 53, 52, 564, 147, 34, 146,
2354 0, 147, 3, 4, 5, 6, 147, 147, 158, 66,
2355 578, 77, 158, 143, 144, 145, 156, 158, 18, 19,
2356 20, 119, 22, 23, 24, 26, 27, 219, 147, 57,
2357 30, 31, 147, 53, 53, 101, 148, 156, 150, 105,
2358 38, 147, 146, 158, 156, 111, 147, 145, 154, 513,
2359 116, 51, 92, 154, 54, 148, 18, 150, 58, 19,
2360 126, 154, 22, 147, 24, 11, 146, 151, 426, 7,
2361 8, 17, 138, 139, 147, 147, 142, 349, 151, 151,
2362 146, 19, 20, 547, 22, 23, 24, 267, 19, 269,
2363 270, 22, 272, 24, 318, 40, 41, 369, 134, 135,
2364 136, 146, 47, 139, 170, 157, 147, 148, 53, 150,
2365 0, 158, 154, 273, 22, 579, 154, 42, 43, 44,
2366 157, 20, 47, 454, 23, 305, 152, 193, 194, 195,
2367 196, 163, 146, 313, 314, 21, 134, 135, 136, 147,
2368 148, 139, 150, 209, 210, 211, 212, 213, 214, 215,
2369 216, 217, 483, 46, 485, 48, 316, 117, 118, 225,
2370 148, 22, 150, 387, 152, 389, 390, 391, 35, 235,
2371 37, 134, 135, 136, 134, 135, 139, 137, 138, 22,
2372 140, 141, 142, 32, 33, 42, 43, 44, 45, 46,
2373 47, 48, 148, 50, 150, 151, 22, 377, 378, 379,
2374 531, 113, 114, 117, 118, 385, 150, 273, 475, 60,
2375 61, 62, 63, 64, 65, 395, 396, 4, 284, 416,
2376 134, 135, 4, 137, 138, 37, 140, 141, 142, 3,
2377 4, 5, 6, 112, 113, 301, 416, 148, 153, 150,
2378 151, 83, 84, 341, 342, 343, 344, 345, 153, 4,
2379 316, 317, 318, 148, 22, 150, 354, 355, 356, 439,
2380 147, 441, 486, 151, 444, 489, 490, 491, 151, 150,
2381 450, 451, 90, 91, 92, 93, 94, 95, 96, 97,
2382 98, 99, 549, 349, 156, 552, 143, 144, 145, 42,
2383 9, 44, 9, 359, 9, 9, 9, 9, 478, 479,
2384 11, 481, 482, 55, 156, 150, 150, 487, 406, 407,
2385 150, 150, 150, 22, 150, 413, 150, 497, 150, 147,
2386 150, 387, 388, 389, 390, 391, 147, 147, 394, 59,
2387 0, 147, 269, 270, 147, 272, 546, 147, 518, 405,
2388 147, 38, 38, 147, 150, 150, 526, 147, 18, 19,
2389 20, 152, 22, 23, 24, 565, 147, 147, 147, 147,
2390 30, 31, 460, 461, 462, 463, 147, 147, 305, 467,
2391 468, 147, 156, 38, 147, 147, 313, 314, 22, 4,
2392 147, 51, 562, 22, 54, 151, 17, 567, 58, 455,
2393 17, 150, 4, 147, 150, 156, 147, 147, 147, 147,
2394 147, 499, 500, 469, 584, 585, 147, 147, 474, 589,
2395 147, 147, 592, 147, 480, 147, 53, 22, 147, 147,
2396 486, 147, 17, 489, 490, 491, 151, 151, 494, 151,
2397 151, 147, 152, 473, 53, 4, 534, 17, 536, 537,
2398 377, 378, 379, 151, 154, 151, 151, 154, 385, 3,
2399 4, 151, 147, 7, 8, 9, 17, 147, 395, 396,
2400 17, 71, 17, 129, 247, 19, 20, 129, 22, 23,
2401 24, 25, 26, 27, 129, 92, 541, 248, 111, 514,
2402 225, 105, 548, 17, 56, 89, 40, 41, 494, 235,
2403 408, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2404 -1, 541, 439, 57, 441, -1, -1, 444, -1, -1,
2405 -1, -1, -1, 450, 451, -1, -1, -1, -1, 73,
2406 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2407 84, 85, 86, 87, 88, 89, -1, -1, -1, -1,
2408 -1, 478, 479, -1, 481, 482, -1, -1, -1, -1,
2409 487, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2410 497, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2411 124, 125, 126, 127, -1, 129, -1, 131, 132, 133,
2412 -1, 518, -1, -1, -1, -1, 3, 4, -1, 526,
2413 7, 8, 9, -1, 148, -1, 150, -1, -1, -1,
2414 -1, 155, 19, 20, -1, 22, 23, 24, 25, 26,
2415 27, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2416 -1, -1, -1, 40, 41, 562, -1, -1, -1, -1,
2417 567, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2418 57, -1, -1, -1, -1, -1, -1, 584, 585, -1,
2419 -1, -1, 589, -1, -1, 592, 73, 74, 75, 76,
2420 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2421 87, 88, 89, -1, -1, -1, -1, -1, -1, -1,
2422 -1, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2423 105, 106, 107, 108, 109, -1, -1, -1, 115, 116,
2424 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2425 127, -1, 129, -1, 131, 132, 133, 7, 8, -1,
2426 -1, -1, -1, -1, -1, -1, -1, -1, -1, 19,
2427 20, -1, 22, 23, 24, 25, -1, -1, 155, -1,
2428 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2429 40, 41, -1, -1, -1, -1, -1, -1, 7, 8,
2430 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2431 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2432 -1, -1, -1, 73, 74, 75, 76, 77, 78, 79,
2433 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2434 49, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2435 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2436 -1, -1, -1, -1, -1, 115, 116, 117, 118, 119,
2437 120, 121, 122, 123, 124, 125, 126, 127, -1, 129,
2438 -1, 131, 132, 133, 49, -1, -1, -1, 3, 4,
2439 -1, -1, -1, -1, 9, -1, -1, -1, 148, -1,
2440 150, -1, 152, -1, -1, 155, -1, 157, -1, 159,
2441 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2442 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2443 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2444 149, -1, 57, 152, -1, -1, 155, -1, 157, 158,
2445 -1, -1, -1, -1, -1, -1, -1, -1, 73, 74,
2446 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2447 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2448 -1, -1, -1, -1, 149, -1, -1, 152, -1, -1,
2449 155, -1, 157, 158, -1, -1, -1, -1, -1, -1,
2450 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2451 125, 126, 127, -1, 129, -1, 131, 132, 133, 7,
2452 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2453 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2454 155, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2455 19, 20, -1, 22, 23, 24, -1, -1, -1, 7,
2456 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2457 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2458 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2459 -1, 39, -1, -1, -1, -1, -1, -1, -1, 7,
2460 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2461 -1, 19, 20, -1, 22, 23, 24, 7, 8, -1,
2462 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2463 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2464 -1, 49, -1, -1, -1, -1, -1, -1, -1, 39,
2465 -1, -1, -1, -1, -1, -1, -1, -1, -1, 49,
2466 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2467 158, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2468 149, -1, -1, 152, -1, -1, 155, -1, 157, 158,
2469 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2470 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2471 -1, 7, 8, 121, 10, 11, 12, 13, 14, 15,
2472 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2473 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2474 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2475 -1, -1, -1, 49, -1, -1, -1, -1, -1, 149,
2476 -1, -1, 152, -1, -1, 155, -1, 157, 7, 8,
2477 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2478 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
2479 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2480 39, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2481 49, -1, -1, -1, -1, -1, -1, -1, 39, -1,
2482 -1, -1, -1, -1, -1, -1, 7, 8, 49, 10,
2483 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2484 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2485 -1, -1, -1, 149, -1, -1, 152, -1, 154, 155,
2486 -1, 157, -1, -1, -1, -1, 7, 8, 49, 10,
2487 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2488 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2489 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2490 23, 24, -1, -1, -1, -1, -1, -1, 49, -1,
2491 149, -1, -1, 152, -1, -1, 155, -1, 157, -1,
2492 -1, -1, -1, -1, -1, -1, 49, -1, 149, -1,
2493 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
2494 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2495 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2496 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
2497 -1, 152, -1, -1, 155, -1, 157, 7, 8, 49,
2498 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2499 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2500 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
2501 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
2502 -1, -1, -1, -1, -1, -1, 149, -1, -1, 152,
2503 -1, -1, 155, -1, 157, 7, 8, -1, 10, 11,
2504 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2505 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2506 -1, 36, -1, -1, -1, -1, -1, -1, -1, -1,
2507 -1, -1, -1, -1, -1, -1, -1, 49, -1, 149,
2508 55, 56, 152, -1, -1, 155, -1, 157, -1, -1,
2509 -1, -1, 67, 68, 69, 70, 71, 72, 73, 74,
2510 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2511 85, 86, 87, 88, 89, -1, -1, -1, -1, 149,
2512 -1, -1, 152, -1, -1, 155, -1, 157, -1, -1,
2513 -1, -1, -1, -1, -1, 110, 111, 112, -1, -1,
2514 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2515 125, 126, 127, 128, 129, 130, 131, 132, 133, -1,
2516 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2517 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
2518 152, -1, -1, 155, -1, 157
2519};
2520
2521/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2522 symbol of state STATE-NUM. */
2523static const yytype_uint8 yystos[] =
2524{
2525 0, 19, 20, 22, 23, 24, 30, 31, 51, 54,
2526 58, 168, 170, 171, 172, 173, 204, 205, 206, 208,
2527 207, 52, 66, 213, 146, 57, 146, 18, 146, 42,
2528 43, 44, 45, 46, 47, 48, 50, 143, 144, 145,
2529 174, 175, 176, 0, 206, 46, 48, 177, 223, 42,
2530 43, 44, 47, 178, 220, 222, 229, 146, 146, 152,
2531 214, 22, 212, 7, 8, 10, 11, 12, 13, 14,
2532 15, 16, 17, 49, 149, 152, 155, 157, 168, 171,
2533 191, 192, 226, 176, 176, 35, 37, 202, 176, 176,
2534 21, 230, 231, 29, 158, 221, 230, 22, 22, 22,
2535 215, 150, 4, 4, 4, 157, 10, 158, 192, 197,
2536 148, 150, 202, 202, 42, 44, 179, 32, 33, 201,
2537 60, 61, 62, 63, 64, 65, 180, 218, 218, 170,
2538 234, 147, 154, 39, 192, 193, 195, 196, 153, 153,
2539 158, 197, 147, 158, 196, 201, 201, 10, 121, 192,
2540 194, 203, 11, 12, 13, 14, 15, 16, 166, 167,
2541 192, 198, 4, 194, 28, 157, 219, 36, 55, 56,
2542 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2543 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2544 87, 88, 89, 110, 111, 112, 115, 116, 117, 118,
2545 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2546 129, 130, 131, 132, 133, 161, 162, 163, 232, 238,
2547 239, 240, 241, 22, 182, 147, 151, 192, 192, 156,
2548 158, 192, 151, 198, 192, 150, 226, 26, 27, 3,
2549 4, 5, 6, 9, 25, 40, 41, 88, 89, 115,
2550 129, 131, 132, 133, 152, 155, 157, 159, 161, 162,
2551 163, 199, 226, 209, 171, 55, 10, 192, 228, 11,
2552 17, 11, 166, 180, 90, 91, 92, 93, 94, 95,
2553 96, 97, 98, 99, 164, 26, 27, 96, 97, 98,
2554 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2555 109, 165, 192, 192, 228, 192, 192, 235, 228, 228,
2556 228, 228, 228, 192, 192, 228, 180, 113, 114, 117,
2557 118, 134, 135, 137, 138, 140, 141, 142, 181, 39,
2558 193, 184, 154, 156, 156, 184, 210, 211, 203, 164,
2559 165, 150, 150, 150, 150, 150, 154, 198, 200, 157,
2560 200, 158, 200, 22, 150, 150, 150, 147, 189, 150,
2561 3, 4, 9, 25, 26, 27, 40, 41, 57, 155,
2562 199, 225, 226, 227, 227, 227, 227, 194, 192, 192,
2563 147, 186, 147, 186, 227, 152, 147, 147, 147, 147,
2564 147, 147, 227, 227, 38, 194, 192, 228, 134, 135,
2565 136, 139, 183, 189, 189, 38, 150, 150, 198, 198,
2566 198, 198, 198, 147, 154, 158, 192, 200, 156, 158,
2567 198, 198, 198, 34, 53, 187, 190, 39, 192, 216,
2568 217, 59, 224, 200, 147, 147, 227, 227, 227, 11,
2569 53, 11, 237, 227, 152, 228, 192, 228, 228, 228,
2570 147, 147, 192, 227, 227, 147, 192, 198, 198, 237,
2571 147, 147, 147, 147, 198, 156, 158, 147, 147, 38,
2572 22, 4, 189, 182, 147, 151, 22, 156, 17, 17,
2573 150, 147, 147, 227, 4, 227, 147, 147, 227, 147,
2574 147, 147, 227, 227, 150, 147, 186, 192, 151, 147,
2575 147, 151, 198, 198, 198, 198, 156, 198, 198, 192,
2576 168, 169, 39, 192, 184, 147, 227, 227, 192, 236,
2577 227, 227, 186, 186, 228, 227, 147, 228, 228, 228,
2578 236, 227, 198, 198, 147, 151, 147, 147, 151, 151,
2579 151, 182, 187, 188, 22, 147, 152, 227, 147, 151,
2580 154, 227, 151, 186, 151, 151, 198, 198, 198, 169,
2581 53, 185, 17, 154, 166, 233, 182, 192, 184, 154,
2582 184, 151, 151, 151, 4, 227, 225, 154, 166, 227,
2583 38, 147, 225, 182, 17, 17, 147, 227, 227, 17,
2584 71, 227, 17, 227
2585};
David Greene9145dd22007-08-01 03:59:32 +00002586
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587#define yyerrok (yyerrstatus = 0)
2588#define yyclearin (yychar = YYEMPTY)
Chandler Carruth563d4a42007-08-04 01:56:21 +00002589#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590#define YYEOF 0
Chandler Carruth563d4a42007-08-04 01:56:21 +00002591
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592#define YYACCEPT goto yyacceptlab
Chandler Carruth563d4a42007-08-04 01:56:21 +00002593#define YYABORT goto yyabortlab
2594#define YYERROR goto yyerrorlab
2595
2596
2597/* Like YYERROR except do call yyerror. This remains here temporarily
2598 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599 Once GCC version 2 has supplanted version 1, this can go. */
Chandler Carruth563d4a42007-08-04 01:56:21 +00002600
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002601#define YYFAIL goto yyerrlab
Chandler Carruth563d4a42007-08-04 01:56:21 +00002602
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002603#define YYRECOVERING() (!!yyerrstatus)
Chandler Carruth563d4a42007-08-04 01:56:21 +00002604
2605#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606do \
2607 if (yychar == YYEMPTY && yylen == 1) \
Chandler Carruth563d4a42007-08-04 01:56:21 +00002608 { \
2609 yychar = (Token); \
2610 yylval = (Value); \
2611 yytoken = YYTRANSLATE (yychar); \
2612 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 goto yybackup; \
2614 } \
2615 else \
Chandler Carruth563d4a42007-08-04 01:56:21 +00002616 { \
2617 yyerror (YY_("syntax error: cannot back up")); \
2618 YYERROR; \
2619 } \
2620while (YYID (0))
2621
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622
2623#define YYTERROR 1
2624#define YYERRCODE 256
2625
Chandler Carruth563d4a42007-08-04 01:56:21 +00002626
2627/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2628 If N is 0, then set CURRENT to the empty location which ends
2629 the previous symbol: RHS[0] (always defined). */
2630
2631#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2632#ifndef YYLLOC_DEFAULT
2633# define YYLLOC_DEFAULT(Current, Rhs, N) \
2634 do \
2635 if (YYID (N)) \
2636 { \
2637 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2638 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2639 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2640 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2641 } \
2642 else \
2643 { \
2644 (Current).first_line = (Current).last_line = \
2645 YYRHSLOC (Rhs, 0).last_line; \
2646 (Current).first_column = (Current).last_column = \
2647 YYRHSLOC (Rhs, 0).last_column; \
2648 } \
2649 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650#endif
2651
Chandler Carruth563d4a42007-08-04 01:56:21 +00002652
2653/* YY_LOCATION_PRINT -- Print the location on the stream.
2654 This macro was not mandated originally: define only if we know
2655 we won't break user code: when these are the locations we know. */
2656
2657#ifndef YY_LOCATION_PRINT
2658# if YYLTYPE_IS_TRIVIAL
2659# define YY_LOCATION_PRINT(File, Loc) \
2660 fprintf (File, "%d.%d-%d.%d", \
2661 (Loc).first_line, (Loc).first_column, \
2662 (Loc).last_line, (Loc).last_column)
2663# else
2664# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2665# endif
2666#endif
2667
2668
2669/* YYLEX -- calling `yylex' with the right arguments. */
2670
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671#ifdef YYLEX_PARAM
Chandler Carruth563d4a42007-08-04 01:56:21 +00002672# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673#else
Chandler Carruth563d4a42007-08-04 01:56:21 +00002674# define YYLEX yylex ()
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002675#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002676
2677/* Enable debugging if requested. */
2678#if YYDEBUG
2679
2680# ifndef YYFPRINTF
2681# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2682# define YYFPRINTF fprintf
2683# endif
2684
2685# define YYDPRINTF(Args) \
2686do { \
2687 if (yydebug) \
2688 YYFPRINTF Args; \
2689} while (YYID (0))
2690
2691# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2692do { \
2693 if (yydebug) \
2694 { \
2695 YYFPRINTF (stderr, "%s ", Title); \
2696 yy_symbol_print (stderr, \
2697 Type, Value); \
2698 YYFPRINTF (stderr, "\n"); \
2699 } \
2700} while (YYID (0))
2701
2702
2703/*--------------------------------.
2704| Print this symbol on YYOUTPUT. |
2705`--------------------------------*/
2706
2707/*ARGSUSED*/
2708#if (defined __STDC__ || defined __C99__FUNC__ \
2709 || defined __cplusplus || defined _MSC_VER)
2710static void
2711yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002712#else
Chandler Carruth563d4a42007-08-04 01:56:21 +00002713static void
2714yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2715 FILE *yyoutput;
2716 int yytype;
2717 YYSTYPE const * const yyvaluep;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002718#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002719{
2720 if (!yyvaluep)
2721 return;
2722# ifdef YYPRINT
2723 if (yytype < YYNTOKENS)
2724 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2725# else
2726 YYUSE (yyoutput);
2727# endif
2728 switch (yytype)
2729 {
2730 default:
2731 break;
2732 }
2733}
2734
2735
2736/*--------------------------------.
2737| Print this symbol on YYOUTPUT. |
2738`--------------------------------*/
2739
2740#if (defined __STDC__ || defined __C99__FUNC__ \
2741 || defined __cplusplus || defined _MSC_VER)
2742static void
2743yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2744#else
2745static void
2746yy_symbol_print (yyoutput, yytype, yyvaluep)
2747 FILE *yyoutput;
2748 int yytype;
2749 YYSTYPE const * const yyvaluep;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002751{
2752 if (yytype < YYNTOKENS)
2753 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2754 else
2755 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Reid Spenceraa8ae282007-07-31 03:50:36 +00002756
Chandler Carruth563d4a42007-08-04 01:56:21 +00002757 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2758 YYFPRINTF (yyoutput, ")");
2759}
Reid Spenceraa8ae282007-07-31 03:50:36 +00002760
Chandler Carruth563d4a42007-08-04 01:56:21 +00002761/*------------------------------------------------------------------.
2762| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2763| TOP (included). |
2764`------------------------------------------------------------------*/
Reid Spenceraa8ae282007-07-31 03:50:36 +00002765
Chandler Carruth563d4a42007-08-04 01:56:21 +00002766#if (defined __STDC__ || defined __C99__FUNC__ \
2767 || defined __cplusplus || defined _MSC_VER)
2768static void
2769yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2770#else
2771static void
2772yy_stack_print (bottom, top)
2773 yytype_int16 *bottom;
2774 yytype_int16 *top;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002776{
2777 YYFPRINTF (stderr, "Stack now");
2778 for (; bottom <= top; ++bottom)
2779 YYFPRINTF (stderr, " %d", *bottom);
2780 YYFPRINTF (stderr, "\n");
2781}
Reid Spenceraa8ae282007-07-31 03:50:36 +00002782
Chandler Carruth563d4a42007-08-04 01:56:21 +00002783# define YY_STACK_PRINT(Bottom, Top) \
2784do { \
2785 if (yydebug) \
2786 yy_stack_print ((Bottom), (Top)); \
2787} while (YYID (0))
Reid Spenceraa8ae282007-07-31 03:50:36 +00002788
Chandler Carruth563d4a42007-08-04 01:56:21 +00002789
2790/*------------------------------------------------.
2791| Report that the YYRULE is going to be reduced. |
2792`------------------------------------------------*/
2793
2794#if (defined __STDC__ || defined __C99__FUNC__ \
2795 || defined __cplusplus || defined _MSC_VER)
2796static void
2797yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2798#else
2799static void
2800yy_reduce_print (yyvsp, yyrule)
2801 YYSTYPE *yyvsp;
2802 int yyrule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002804{
2805 int yynrhs = yyr2[yyrule];
2806 int yyi;
2807 unsigned long int yylno = yyrline[yyrule];
2808 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2809 yyrule - 1, yylno);
2810 /* The symbols being reduced. */
2811 for (yyi = 0; yyi < yynrhs; yyi++)
2812 {
2813 fprintf (stderr, " $%d = ", yyi + 1);
2814 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2815 &(yyvsp[(yyi + 1) - (yynrhs)])
2816 );
2817 fprintf (stderr, "\n");
2818 }
2819}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820
Chandler Carruth563d4a42007-08-04 01:56:21 +00002821# define YY_REDUCE_PRINT(Rule) \
2822do { \
2823 if (yydebug) \
2824 yy_reduce_print (yyvsp, Rule); \
2825} while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826
Chandler Carruth563d4a42007-08-04 01:56:21 +00002827/* Nonzero means print parse trace. It is left uninitialized so that
2828 multiple parsers can coexist. */
2829int yydebug;
2830#else /* !YYDEBUG */
2831# define YYDPRINTF(Args)
2832# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2833# define YY_STACK_PRINT(Bottom, Top)
2834# define YY_REDUCE_PRINT(Rule)
2835#endif /* !YYDEBUG */
2836
2837
2838/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839#ifndef YYINITDEPTH
Chandler Carruth563d4a42007-08-04 01:56:21 +00002840# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841#endif
2842
Chandler Carruth563d4a42007-08-04 01:56:21 +00002843/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2844 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002845
Chandler Carruth563d4a42007-08-04 01:56:21 +00002846 Do not make this value too large; the results are undefined if
2847 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2848 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002849
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850#ifndef YYMAXDEPTH
Chandler Carruth563d4a42007-08-04 01:56:21 +00002851# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00002853
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002855
Chandler Carruth563d4a42007-08-04 01:56:21 +00002856#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857
Chandler Carruth563d4a42007-08-04 01:56:21 +00002858# ifndef yystrlen
2859# if defined __GLIBC__ && defined _STRING_H
2860# define yystrlen strlen
2861# else
2862/* Return the length of YYSTR. */
2863#if (defined __STDC__ || defined __C99__FUNC__ \
2864 || defined __cplusplus || defined _MSC_VER)
2865static YYSIZE_T
2866yystrlen (const char *yystr)
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002867#else
Chandler Carruth563d4a42007-08-04 01:56:21 +00002868static YYSIZE_T
2869yystrlen (yystr)
2870 const char *yystr;
2871#endif
2872{
2873 YYSIZE_T yylen;
2874 for (yylen = 0; yystr[yylen]; yylen++)
2875 continue;
2876 return yylen;
2877}
2878# endif
2879# endif
2880
2881# ifndef yystpcpy
2882# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2883# define yystpcpy stpcpy
2884# else
2885/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2886 YYDEST. */
2887#if (defined __STDC__ || defined __C99__FUNC__ \
2888 || defined __cplusplus || defined _MSC_VER)
2889static char *
2890yystpcpy (char *yydest, const char *yysrc)
2891#else
2892static char *
2893yystpcpy (yydest, yysrc)
2894 char *yydest;
2895 const char *yysrc;
2896#endif
2897{
2898 char *yyd = yydest;
2899 const char *yys = yysrc;
2900
2901 while ((*yyd++ = *yys++) != '\0')
2902 continue;
2903
2904 return yyd - 1;
2905}
2906# endif
2907# endif
2908
2909# ifndef yytnamerr
2910/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2911 quotes and backslashes, so that it's suitable for yyerror. The
2912 heuristic is that double-quoting is unnecessary unless the string
2913 contains an apostrophe, a comma, or backslash (other than
2914 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2915 null, do not copy; instead, return the length of what the result
2916 would have been. */
2917static YYSIZE_T
2918yytnamerr (char *yyres, const char *yystr)
2919{
2920 if (*yystr == '"')
2921 {
2922 YYSIZE_T yyn = 0;
2923 char const *yyp = yystr;
2924
2925 for (;;)
2926 switch (*++yyp)
2927 {
2928 case '\'':
2929 case ',':
2930 goto do_not_strip_quotes;
2931
2932 case '\\':
2933 if (*++yyp != '\\')
2934 goto do_not_strip_quotes;
2935 /* Fall through. */
2936 default:
2937 if (yyres)
2938 yyres[yyn] = *yyp;
2939 yyn++;
2940 break;
2941
2942 case '"':
2943 if (yyres)
2944 yyres[yyn] = '\0';
2945 return yyn;
2946 }
2947 do_not_strip_quotes: ;
2948 }
2949
2950 if (! yyres)
2951 return yystrlen (yystr);
2952
2953 return yystpcpy (yyres, yystr) - yyres;
2954}
2955# endif
2956
2957/* Copy into YYRESULT an error message about the unexpected token
2958 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2959 including the terminating null byte. If YYRESULT is null, do not
2960 copy anything; just return the number of bytes that would be
2961 copied. As a special case, return 0 if an ordinary "syntax error"
2962 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2963 size calculation. */
2964static YYSIZE_T
2965yysyntax_error (char *yyresult, int yystate, int yychar)
2966{
2967 int yyn = yypact[yystate];
2968
2969 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2970 return 0;
2971 else
2972 {
2973 int yytype = YYTRANSLATE (yychar);
2974 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2975 YYSIZE_T yysize = yysize0;
2976 YYSIZE_T yysize1;
2977 int yysize_overflow = 0;
2978 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2979 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2980 int yyx;
2981
2982# if 0
2983 /* This is so xgettext sees the translatable formats that are
2984 constructed on the fly. */
2985 YY_("syntax error, unexpected %s");
2986 YY_("syntax error, unexpected %s, expecting %s");
2987 YY_("syntax error, unexpected %s, expecting %s or %s");
2988 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2989 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2990# endif
2991 char *yyfmt;
2992 char const *yyf;
2993 static char const yyunexpected[] = "syntax error, unexpected %s";
2994 static char const yyexpecting[] = ", expecting %s";
2995 static char const yyor[] = " or %s";
2996 char yyformat[sizeof yyunexpected
2997 + sizeof yyexpecting - 1
2998 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2999 * (sizeof yyor - 1))];
3000 char const *yyprefix = yyexpecting;
3001
3002 /* Start YYX at -YYN if negative to avoid negative indexes in
3003 YYCHECK. */
3004 int yyxbegin = yyn < 0 ? -yyn : 0;
3005
3006 /* Stay within bounds of both yycheck and yytname. */
3007 int yychecklim = YYLAST - yyn + 1;
3008 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3009 int yycount = 1;
3010
3011 yyarg[0] = yytname[yytype];
3012 yyfmt = yystpcpy (yyformat, yyunexpected);
3013
3014 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3015 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3016 {
3017 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3018 {
3019 yycount = 1;
3020 yysize = yysize0;
3021 yyformat[sizeof yyunexpected - 1] = '\0';
3022 break;
3023 }
3024 yyarg[yycount++] = yytname[yyx];
3025 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3026 yysize_overflow |= (yysize1 < yysize);
3027 yysize = yysize1;
3028 yyfmt = yystpcpy (yyfmt, yyprefix);
3029 yyprefix = yyor;
3030 }
3031
3032 yyf = YY_(yyformat);
3033 yysize1 = yysize + yystrlen (yyf);
3034 yysize_overflow |= (yysize1 < yysize);
3035 yysize = yysize1;
3036
3037 if (yysize_overflow)
3038 return YYSIZE_MAXIMUM;
3039
3040 if (yyresult)
3041 {
3042 /* Avoid sprintf, as that infringes on the user's name space.
3043 Don't have undefined behavior even if the translation
3044 produced a string with the wrong number of "%s"s. */
3045 char *yyp = yyresult;
3046 int yyi = 0;
3047 while ((*yyp = *yyf) != '\0')
3048 {
3049 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3050 {
3051 yyp += yytnamerr (yyp, yyarg[yyi++]);
3052 yyf += 2;
3053 }
3054 else
3055 {
3056 yyp++;
3057 yyf++;
3058 }
3059 }
3060 }
3061 return yysize;
3062 }
3063}
3064#endif /* YYERROR_VERBOSE */
3065
3066
3067/*-----------------------------------------------.
3068| Release the memory associated to this symbol. |
3069`-----------------------------------------------*/
3070
3071/*ARGSUSED*/
3072#if (defined __STDC__ || defined __C99__FUNC__ \
3073 || defined __cplusplus || defined _MSC_VER)
3074static void
3075yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3076#else
3077static void
3078yydestruct (yymsg, yytype, yyvaluep)
3079 const char *yymsg;
3080 int yytype;
3081 YYSTYPE *yyvaluep;
3082#endif
3083{
3084 YYUSE (yyvaluep);
3085
3086 if (!yymsg)
3087 yymsg = "Deleting";
3088 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3089
3090 switch (yytype)
3091 {
3092
3093 default:
3094 break;
3095 }
3096}
3097
3098
3099/* Prevent warnings from -Wmissing-prototypes. */
3100
3101#ifdef YYPARSE_PARAM
3102#if defined __STDC__ || defined __cplusplus
3103int yyparse (void *YYPARSE_PARAM);
3104#else
3105int yyparse ();
3106#endif
3107#else /* ! YYPARSE_PARAM */
3108#if defined __STDC__ || defined __cplusplus
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109int yyparse (void);
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003110#else
Chandler Carruth563d4a42007-08-04 01:56:21 +00003111int yyparse ();
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003112#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00003113#endif /* ! YYPARSE_PARAM */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003114
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115
Chandler Carruth563d4a42007-08-04 01:56:21 +00003116
3117/* The look-ahead symbol. */
3118int yychar;
3119
3120/* The semantic value of the look-ahead symbol. */
3121YYSTYPE yylval;
3122
3123/* Number of syntax errors so far. */
3124int yynerrs;
3125
3126
3127
3128/*----------.
3129| yyparse. |
3130`----------*/
3131
3132#ifdef YYPARSE_PARAM
3133#if (defined __STDC__ || defined __C99__FUNC__ \
3134 || defined __cplusplus || defined _MSC_VER)
3135int
3136yyparse (void *YYPARSE_PARAM)
3137#else
3138int
3139yyparse (YYPARSE_PARAM)
3140 void *YYPARSE_PARAM;
3141#endif
3142#else /* ! YYPARSE_PARAM */
3143#if (defined __STDC__ || defined __C99__FUNC__ \
3144 || defined __cplusplus || defined _MSC_VER)
3145int
3146yyparse (void)
3147#else
3148int
3149yyparse ()
3150
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003151#endif
3152#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00003153{
3154
3155 int yystate;
3156 int yyn;
3157 int yyresult;
3158 /* Number of tokens to shift before error messages enabled. */
3159 int yyerrstatus;
3160 /* Look-ahead token as an internal (translated) token number. */
3161 int yytoken = 0;
3162#if YYERROR_VERBOSE
3163 /* Buffer for error messages, and its allocated size. */
3164 char yymsgbuf[128];
3165 char *yymsg = yymsgbuf;
3166 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003167#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003168
Chandler Carruth563d4a42007-08-04 01:56:21 +00003169 /* Three stacks and their tools:
3170 `yyss': related to states,
3171 `yyvs': related to semantic values,
3172 `yyls': related to locations.
3173
3174 Refer to the stacks thru separate pointers, to allow yyoverflow
3175 to reallocate them elsewhere. */
3176
3177 /* The state stack. */
3178 yytype_int16 yyssa[YYINITDEPTH];
3179 yytype_int16 *yyss = yyssa;
3180 yytype_int16 *yyssp;
3181
3182 /* The semantic value stack. */
3183 YYSTYPE yyvsa[YYINITDEPTH];
3184 YYSTYPE *yyvs = yyvsa;
3185 YYSTYPE *yyvsp;
3186
3187
3188
3189#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3190
3191 YYSIZE_T yystacksize = YYINITDEPTH;
3192
3193 /* The variables used to return semantic value and location from the
3194 action routines. */
3195 YYSTYPE yyval;
3196
3197
3198 /* The number of symbols on the RHS of the reduced rule.
3199 Keep to zero when no symbol should be popped. */
3200 int yylen = 0;
3201
3202 YYDPRINTF ((stderr, "Starting parse\n"));
3203
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003204 yystate = 0;
3205 yyerrstatus = 0;
3206 yynerrs = 0;
3207 yychar = YYEMPTY; /* Cause a token to be read. */
3208
3209 /* Initialize stack pointers.
3210 Waste one element of value and location stack
3211 so that they stay on the same level as the state stack.
3212 The wasted elements are never initialized. */
3213
Chandler Carruth563d4a42007-08-04 01:56:21 +00003214 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003216
Chandler Carruth563d4a42007-08-04 01:56:21 +00003217 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003218
Chandler Carruth563d4a42007-08-04 01:56:21 +00003219/*------------------------------------------------------------.
3220| yynewstate -- Push a new state, which is found in yystate. |
3221`------------------------------------------------------------*/
3222 yynewstate:
3223 /* In all cases, when you get here, the value and location stacks
3224 have just been pushed. So pushing a state here evens the stacks. */
3225 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003226
Chandler Carruth563d4a42007-08-04 01:56:21 +00003227 yysetstate:
3228 *yyssp = yystate;
3229
3230 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003232 /* Get the current used size of the three stacks, in elements. */
Chandler Carruth563d4a42007-08-04 01:56:21 +00003233 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003234
3235#ifdef yyoverflow
Chandler Carruth563d4a42007-08-04 01:56:21 +00003236 {
3237 /* Give user a chance to reallocate the stack. Use copies of
3238 these so that the &'s don't force the real ones into
3239 memory. */
3240 YYSTYPE *yyvs1 = yyvs;
3241 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003242
Chandler Carruth563d4a42007-08-04 01:56:21 +00003243
3244 /* Each stack pointer address is followed by the size of the
3245 data in use in that stack, in bytes. This used to be a
3246 conditional around just the two extra args, but that might
3247 be undefined if yyoverflow is a macro. */
3248 yyoverflow (YY_("memory exhausted"),
3249 &yyss1, yysize * sizeof (*yyssp),
3250 &yyvs1, yysize * sizeof (*yyvsp),
3251
3252 &yystacksize);
3253
3254 yyss = yyss1;
3255 yyvs = yyvs1;
3256 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257#else /* no yyoverflow */
Chandler Carruth563d4a42007-08-04 01:56:21 +00003258# ifndef YYSTACK_RELOCATE
3259 goto yyexhaustedlab;
3260# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261 /* Extend the stack our own way. */
Chandler Carruth563d4a42007-08-04 01:56:21 +00003262 if (YYMAXDEPTH <= yystacksize)
3263 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264 yystacksize *= 2;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003265 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003266 yystacksize = YYMAXDEPTH;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003267
3268 {
3269 yytype_int16 *yyss1 = yyss;
3270 union yyalloc *yyptr =
3271 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3272 if (! yyptr)
3273 goto yyexhaustedlab;
3274 YYSTACK_RELOCATE (yyss);
3275 YYSTACK_RELOCATE (yyvs);
3276
3277# undef YYSTACK_RELOCATE
3278 if (yyss1 != yyssa)
3279 YYSTACK_FREE (yyss1);
3280 }
3281# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003282#endif /* no yyoverflow */
3283
Chandler Carruth563d4a42007-08-04 01:56:21 +00003284 yyssp = yyss + yysize - 1;
3285 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003287
Chandler Carruth563d4a42007-08-04 01:56:21 +00003288 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3289 (unsigned long int) yystacksize));
3290
3291 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003292 YYABORT;
3293 }
3294
Chandler Carruth563d4a42007-08-04 01:56:21 +00003295 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003296
3297 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298
Chandler Carruth563d4a42007-08-04 01:56:21 +00003299/*-----------.
3300| yybackup. |
3301`-----------*/
3302yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303
Chandler Carruth563d4a42007-08-04 01:56:21 +00003304 /* Do appropriate processing given the current state. Read a
3305 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306
Chandler Carruth563d4a42007-08-04 01:56:21 +00003307 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308 yyn = yypact[yystate];
Chandler Carruth563d4a42007-08-04 01:56:21 +00003309 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310 goto yydefault;
3311
Chandler Carruth563d4a42007-08-04 01:56:21 +00003312 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313
Chandler Carruth563d4a42007-08-04 01:56:21 +00003314 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315 if (yychar == YYEMPTY)
3316 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00003317 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318 yychar = YYLEX;
3319 }
3320
Chandler Carruth563d4a42007-08-04 01:56:21 +00003321 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00003323 yychar = yytoken = YYEOF;
3324 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325 }
3326 else
3327 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00003328 yytoken = YYTRANSLATE (yychar);
3329 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003330 }
3331
Chandler Carruth563d4a42007-08-04 01:56:21 +00003332 /* If the proper action on seeing token YYTOKEN is to reduce or to
3333 detect an error, take that action. */
3334 yyn += yytoken;
3335 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003336 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 yyn = yytable[yyn];
Chandler Carruth563d4a42007-08-04 01:56:21 +00003338 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00003340 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003341 goto yyerrlab;
3342 yyn = -yyn;
3343 goto yyreduce;
3344 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003345
3346 if (yyn == YYFINAL)
3347 YYACCEPT;
3348
Chandler Carruth563d4a42007-08-04 01:56:21 +00003349 /* Count tokens shifted since error; after three, turn off error
3350 status. */
3351 if (yyerrstatus)
3352 yyerrstatus--;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003353
Chandler Carruth563d4a42007-08-04 01:56:21 +00003354 /* Shift the look-ahead token. */
3355 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356
Chandler Carruth563d4a42007-08-04 01:56:21 +00003357 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358 if (yychar != YYEOF)
3359 yychar = YYEMPTY;
3360
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003361 yystate = yyn;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003362 *++yyvsp = yylval;
3363
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364 goto yynewstate;
3365
Dale Johannesenf325d9f2007-08-03 01:03:46 +00003366
Chandler Carruth563d4a42007-08-04 01:56:21 +00003367/*-----------------------------------------------------------.
3368| yydefault -- do the default action for the current state. |
3369`-----------------------------------------------------------*/
3370yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371 yyn = yydefact[yystate];
3372 if (yyn == 0)
3373 goto yyerrlab;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003374 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003375
Chandler Carruth563d4a42007-08-04 01:56:21 +00003376
3377/*-----------------------------.
3378| yyreduce -- Do a reduction. |
3379`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003380yyreduce:
Chandler Carruth563d4a42007-08-04 01:56:21 +00003381 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003382 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383
Chandler Carruth563d4a42007-08-04 01:56:21 +00003384 /* If YYLEN is nonzero, implement the default value of the action:
3385 `$$ = $1'.
3386
3387 Otherwise, the following line sets YYVAL to garbage.
3388 This behavior is undocumented and Bison
3389 users should not rely upon it. Assigning to YYVAL
3390 unconditionally makes the parser a bit smaller, and it avoids a
3391 GCC warning that YYVAL may be used uninitialized. */
3392 yyval = yyvsp[1-yylen];
3393
3394
3395 YY_REDUCE_PRINT (yyn);
3396 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00003398 case 29:
3399#line 1128 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3400 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3401 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003402
Chandler Carruth563d4a42007-08-04 01:56:21 +00003403 case 30:
3404#line 1128 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3405 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3406 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003407
Chandler Carruth563d4a42007-08-04 01:56:21 +00003408 case 31:
3409#line 1129 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3410 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3411 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412
Chandler Carruth563d4a42007-08-04 01:56:21 +00003413 case 32:
3414#line 1129 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3415 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3416 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003417
Chandler Carruth563d4a42007-08-04 01:56:21 +00003418 case 33:
3419#line 1130 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3420 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3421 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003422
Chandler Carruth563d4a42007-08-04 01:56:21 +00003423 case 34:
3424#line 1130 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3425 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3426 break;
3427
3428 case 35:
3429#line 1131 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3430 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3431 break;
3432
3433 case 36:
3434#line 1131 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3435 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3436 break;
3437
3438 case 37:
3439#line 1132 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3440 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3441 break;
3442
3443 case 38:
3444#line 1132 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3445 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3446 break;
3447
3448 case 39:
3449#line 1136 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3450 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3451 break;
3452
3453 case 40:
3454#line 1136 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3455 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3456 break;
3457
3458 case 41:
3459#line 1137 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3460 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3461 break;
3462
3463 case 42:
3464#line 1137 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3465 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3466 break;
3467
3468 case 43:
3469#line 1138 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3470 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3471 break;
3472
3473 case 44:
3474#line 1138 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3475 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3476 break;
3477
3478 case 45:
3479#line 1139 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3480 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3481 break;
3482
3483 case 46:
3484#line 1139 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3485 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3486 break;
3487
3488 case 47:
3489#line 1140 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3490 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3491 break;
3492
3493 case 48:
3494#line 1140 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3495 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3496 break;
3497
3498 case 49:
3499#line 1141 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3500 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3501 break;
3502
3503 case 50:
3504#line 1141 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3505 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3506 break;
3507
3508 case 51:
3509#line 1142 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3510 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3511 break;
3512
3513 case 52:
3514#line 1142 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3515 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3516 break;
3517
3518 case 53:
3519#line 1143 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3520 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3521 break;
3522
3523 case 54:
3524#line 1144 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3525 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3526 break;
3527
3528 case 65:
3529#line 1153 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3530 { (yyval.StrVal) = 0; ;}
3531 break;
3532
3533 case 66:
3534#line 1157 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3535 {
3536 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003537 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003538 ;}
3539 break;
3540
3541 case 67:
3542#line 1161 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3543 {
3544 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003545 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003546 ;}
3547 break;
3548
3549 case 71:
3550#line 1169 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3551 {
3552 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003553 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003554 ;}
3555 break;
3556
3557 case 72:
3558#line 1174 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3559 {
3560 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003561 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003562 ;}
3563 break;
3564
3565 case 73:
3566#line 1180 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3567 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3568 break;
3569
3570 case 74:
3571#line 1181 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3572 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3573 break;
3574
3575 case 75:
3576#line 1182 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3577 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3578 break;
3579
3580 case 76:
3581#line 1183 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3582 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3583 break;
3584
3585 case 77:
3586#line 1184 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3587 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3588 break;
3589
3590 case 78:
3591#line 1188 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3592 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3593 break;
3594
3595 case 79:
3596#line 1189 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3597 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3598 break;
3599
3600 case 80:
3601#line 1190 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3602 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3603 break;
3604
3605 case 81:
3606#line 1194 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3607 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3608 break;
3609
3610 case 82:
3611#line 1195 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3612 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3613 break;
3614
3615 case 83:
3616#line 1196 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3617 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3618 break;
3619
3620 case 84:
3621#line 1197 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3622 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3623 break;
3624
3625 case 85:
3626#line 1201 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3627 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3628 break;
3629
3630 case 86:
3631#line 1202 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3632 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3633 break;
3634
3635 case 87:
3636#line 1203 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3637 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3638 break;
3639
3640 case 88:
3641#line 1207 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3642 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3643 break;
3644
3645 case 89:
3646#line 1208 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3647 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3648 break;
3649
3650 case 90:
3651#line 1209 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3652 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3653 break;
3654
3655 case 91:
3656#line 1210 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3657 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3658 break;
3659
3660 case 92:
3661#line 1211 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3662 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3663 break;
3664
3665 case 93:
3666#line 1215 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3667 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3668 break;
3669
3670 case 94:
3671#line 1216 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3672 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3673 break;
3674
3675 case 95:
3676#line 1217 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3677 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3678 break;
3679
3680 case 96:
3681#line 1220 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3682 { (yyval.UIntVal) = CallingConv::C; ;}
3683 break;
3684
3685 case 97:
3686#line 1221 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3687 { (yyval.UIntVal) = CallingConv::C; ;}
3688 break;
3689
3690 case 98:
3691#line 1222 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3692 { (yyval.UIntVal) = CallingConv::Fast; ;}
3693 break;
3694
3695 case 99:
3696#line 1223 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3697 { (yyval.UIntVal) = CallingConv::Cold; ;}
3698 break;
3699
3700 case 100:
3701#line 1224 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3702 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3703 break;
3704
3705 case 101:
3706#line 1225 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3707 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3708 break;
3709
3710 case 102:
3711#line 1226 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3712 {
3713 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003714 GEN_ERROR("Calling conv too large");
Chandler Carruth563d4a42007-08-04 01:56:21 +00003715 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003716 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003717 ;}
3718 break;
3719
3720 case 103:
3721#line 1233 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3722 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3723 break;
3724
3725 case 104:
3726#line 1234 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3727 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3728 break;
3729
3730 case 105:
3731#line 1235 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3732 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3733 break;
3734
3735 case 106:
3736#line 1236 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3737 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3738 break;
3739
3740 case 107:
3741#line 1237 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3742 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3743 break;
3744
3745 case 108:
3746#line 1238 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3747 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3748 break;
3749
3750 case 109:
3751#line 1239 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3752 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3753 break;
3754
3755 case 110:
3756#line 1240 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3757 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3758 break;
3759
3760 case 111:
3761#line 1241 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3762 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3763 break;
3764
3765 case 112:
3766#line 1244 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3767 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3768 break;
3769
3770 case 113:
3771#line 1245 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3772 {
3773 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3774 ;}
3775 break;
3776
3777 case 114:
3778#line 1250 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3779 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3780 break;
3781
3782 case 115:
3783#line 1251 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3784 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3785 break;
3786
3787 case 116:
3788#line 1252 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3789 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3790 break;
3791
3792 case 117:
3793#line 1253 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3794 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3795 break;
3796
3797 case 118:
3798#line 1256 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3799 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3800 break;
3801
3802 case 119:
3803#line 1257 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3804 {
3805 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3806 ;}
3807 break;
3808
3809 case 120:
3810#line 1264 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3811 { (yyval.UIntVal) = 0; ;}
3812 break;
3813
3814 case 121:
3815#line 1265 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3816 {
3817 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3818 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003819 GEN_ERROR("Alignment must be a power of two");
3820 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003821;}
3822 break;
3823
3824 case 122:
3825#line 1271 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3826 { (yyval.UIntVal) = 0; ;}
3827 break;
3828
3829 case 123:
3830#line 1272 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3831 {
3832 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3833 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003834 GEN_ERROR("Alignment must be a power of two");
3835 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003836;}
3837 break;
3838
3839 case 124:
3840#line 1280 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3841 {
3842 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3843 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003844 GEN_ERROR("Invalid character in section name");
Chandler Carruth563d4a42007-08-04 01:56:21 +00003845 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003846 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003847;}
3848 break;
3849
3850 case 125:
3851#line 1288 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3852 { (yyval.StrVal) = 0; ;}
3853 break;
3854
3855 case 126:
3856#line 1289 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3857 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3858 break;
3859
3860 case 127:
3861#line 1294 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3862 {;}
3863 break;
3864
3865 case 128:
3866#line 1295 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3867 {;}
3868 break;
3869
3870 case 129:
3871#line 1296 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3872 {
3873 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3874 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003875 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003876 ;}
3877 break;
3878
3879 case 130:
3880#line 1301 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3881 {
3882 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003883 GEN_ERROR("Alignment must be a power of two");
Chandler Carruth563d4a42007-08-04 01:56:21 +00003884 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003885 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003886 ;}
3887 break;
3888
3889 case 138:
3890#line 1317 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3891 {
3892 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003893 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003894 ;}
3895 break;
3896
3897 case 139:
3898#line 1321 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3899 {
3900 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003901 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003902 ;}
3903 break;
3904
3905 case 140:
3906#line 1325 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3907 { // Pointer type?
3908 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003909 GEN_ERROR("Cannot form a pointer to a basic block");
Chandler Carruth563d4a42007-08-04 01:56:21 +00003910 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3911 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003912 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003913 ;}
3914 break;
3915
3916 case 141:
3917#line 1332 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3918 { // Named types are also simple types...
3919 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003920 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003921 (yyval.TypeVal) = new PATypeHolder(tmp);
3922 ;}
3923 break;
3924
3925 case 142:
3926#line 1337 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3927 { // Type UpReference
3928 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003929 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chandler Carruth563d4a42007-08-04 01:56:21 +00003930 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3931 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 UR_OUT("New Upreference!\n");
3933 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003934 ;}
3935 break;
3936
3937 case 143:
3938#line 1345 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3939 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003940 std::vector<const Type*> Params;
3941 ParamAttrsVector Attrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003942 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3943 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003944 Attrs.push_back(X);
3945 }
3946 unsigned index = 1;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003947 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948 for (; I != E; ++I, ++index) {
3949 const Type *Ty = I->Ty->get();
3950 Params.push_back(Ty);
3951 if (Ty != Type::VoidTy)
3952 if (I->Attrs != ParamAttr::None) {
3953 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3954 Attrs.push_back(X);
3955 }
3956 }
3957 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3958 if (isVarArg) Params.pop_back();
3959
3960 ParamAttrsList *ActualAttrs = 0;
3961 if (!Attrs.empty())
3962 ActualAttrs = ParamAttrsList::get(Attrs);
Chandler Carruth563d4a42007-08-04 01:56:21 +00003963 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
3964 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
3965 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
3966 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003967 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00003968 ;}
3969 break;
3970
3971 case 144:
3972#line 1375 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
3973 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003974 std::vector<const Type*> Params;
3975 ParamAttrsVector Attrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00003976 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3977 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003978 Attrs.push_back(X);
3979 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00003980 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003981 unsigned index = 1;
3982 for ( ; I != E; ++I, ++index) {
3983 const Type* Ty = I->Ty->get();
3984 Params.push_back(Ty);
3985 if (Ty != Type::VoidTy)
3986 if (I->Attrs != ParamAttr::None) {
3987 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3988 Attrs.push_back(X);
3989 }
3990 }
3991 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3992 if (isVarArg) Params.pop_back();
3993
3994 ParamAttrsList *ActualAttrs = 0;
3995 if (!Attrs.empty())
3996 ActualAttrs = ParamAttrsList::get(Attrs);
3997
Chandler Carruth563d4a42007-08-04 01:56:21 +00003998 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
3999 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4000 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004001 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004002 ;}
4003 break;
4004
4005 case 145:
4006#line 1406 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4007 { // Sized array type?
4008 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4009 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004010 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004011 ;}
4012 break;
4013
4014 case 146:
4015#line 1411 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4016 { // Vector type?
4017 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4018 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004019 GEN_ERROR("Unsigned result not equal to signed result");
4020 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4021 GEN_ERROR("Element type of a VectorType must be primitive");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004022 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004023 GEN_ERROR("Vector length should be a power of 2");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004024 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4025 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004026 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004027 ;}
4028 break;
4029
4030 case 147:
4031#line 1423 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4032 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004033 std::vector<const Type*> Elements;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004034 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4035 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004036 Elements.push_back(*I);
4037
Chandler Carruth563d4a42007-08-04 01:56:21 +00004038 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4039 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004040 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004041 ;}
4042 break;
4043
4044 case 148:
4045#line 1433 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4046 { // Empty structure type?
4047 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004048 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004049 ;}
4050 break;
4051
4052 case 149:
4053#line 1437 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4054 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004055 std::vector<const Type*> Elements;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004056 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4057 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004058 Elements.push_back(*I);
4059
Chandler Carruth563d4a42007-08-04 01:56:21 +00004060 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4061 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004062 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004063 ;}
4064 break;
4065
4066 case 150:
4067#line 1447 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4068 { // Empty structure type?
4069 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004070 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004071 ;}
4072 break;
4073
4074 case 151:
4075#line 1454 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4076 {
4077 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4078 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
4079 ;}
4080 break;
4081
4082 case 152:
4083#line 1461 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4084 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004085 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004086 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4087 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004088 GEN_ERROR("LLVM functions cannot return aggregate types");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004089 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4090 ;}
4091 break;
4092
4093 case 153:
4094#line 1468 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4095 {
4096 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4097 ;}
4098 break;
4099
4100 case 154:
4101#line 1473 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4102 {
4103 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4104 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004105 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004106 ;}
4107 break;
4108
4109 case 155:
4110#line 1478 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4111 {
4112 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004113 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004114 ;}
4115 break;
4116
4117 case 157:
4118#line 1486 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4119 {
4120 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004121 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4122 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chandler Carruth563d4a42007-08-04 01:56:21 +00004123 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004124 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004125 ;}
4126 break;
4127
4128 case 158:
4129#line 1493 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4130 {
4131 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004132 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4133 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chandler Carruth563d4a42007-08-04 01:56:21 +00004134 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004135 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004136 ;}
4137 break;
4138
4139 case 159:
4140#line 1500 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4141 {
4142 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004143 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004144 ;}
4145 break;
4146
4147 case 160:
4148#line 1508 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4149 {
4150 (yyval.TypeList) = new std::list<PATypeHolder>();
4151 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4152 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004153 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004154 ;}
4155 break;
4156
4157 case 161:
4158#line 1514 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4159 {
4160 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4161 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004162 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004163 ;}
4164 break;
4165
4166 case 162:
4167#line 1526 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4168 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004169 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004170 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4171 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004172 if (ATy == 0)
4173 GEN_ERROR("Cannot make array constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004174 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004175 const Type *ETy = ATy->getElementType();
4176 int NumElements = ATy->getNumElements();
4177
4178 // Verify that we have the correct size...
Chandler Carruth563d4a42007-08-04 01:56:21 +00004179 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004180 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004181 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004182 itostr(NumElements) + "");
4183
4184 // Verify all elements are correct type!
Chandler Carruth563d4a42007-08-04 01:56:21 +00004185 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4186 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004187 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4188 ETy->getDescription() +"' as required!\nIt is of type '"+
Chandler Carruth563d4a42007-08-04 01:56:21 +00004189 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004190 }
4191
Chandler Carruth563d4a42007-08-04 01:56:21 +00004192 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4193 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004194 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004195 ;}
4196 break;
4197
4198 case 163:
4199#line 1554 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4200 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004201 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004202 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4203 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004204 if (ATy == 0)
4205 GEN_ERROR("Cannot make array constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004206 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004207
4208 int NumElements = ATy->getNumElements();
4209 if (NumElements != -1 && NumElements != 0)
4210 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4211 " arguments, but has size of " + itostr(NumElements) +"");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004212 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4213 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004214 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004215 ;}
4216 break;
4217
4218 case 164:
4219#line 1570 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4220 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004221 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004222 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4223 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004224 if (ATy == 0)
4225 GEN_ERROR("Cannot make array constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004226 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004227
4228 int NumElements = ATy->getNumElements();
4229 const Type *ETy = ATy->getElementType();
Chandler Carruth563d4a42007-08-04 01:56:21 +00004230 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004231 GEN_ERROR("Can't build string constant of size " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004232 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004233 " when array has size " + itostr(NumElements) + "");
4234 std::vector<Constant*> Vals;
4235 if (ETy == Type::Int8Ty) {
Chandler Carruth563d4a42007-08-04 01:56:21 +00004236 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4237 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004238 } else {
Chandler Carruth563d4a42007-08-04 01:56:21 +00004239 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004240 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4241 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00004242 delete (yyvsp[(3) - (3)].StrVal);
4243 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4244 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004245 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004246 ;}
4247 break;
4248
4249 case 165:
4250#line 1597 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4251 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004252 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004253 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4254 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004255 if (PTy == 0)
4256 GEN_ERROR("Cannot make packed constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004257 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004258 const Type *ETy = PTy->getElementType();
4259 int NumElements = PTy->getNumElements();
4260
4261 // Verify that we have the correct size...
Chandler Carruth563d4a42007-08-04 01:56:21 +00004262 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004264 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004265 itostr(NumElements) + "");
4266
4267 // Verify all elements are correct type!
Chandler Carruth563d4a42007-08-04 01:56:21 +00004268 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4269 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4271 ETy->getDescription() +"' as required!\nIt is of type '"+
Chandler Carruth563d4a42007-08-04 01:56:21 +00004272 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004273 }
4274
Chandler Carruth563d4a42007-08-04 01:56:21 +00004275 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4276 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004278 ;}
4279 break;
4280
4281 case 166:
4282#line 1625 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4283 {
4284 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004285 if (STy == 0)
4286 GEN_ERROR("Cannot make struct constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004287 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004288
Chandler Carruth563d4a42007-08-04 01:56:21 +00004289 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004290 GEN_ERROR("Illegal number of initializers for structure type");
4291
4292 // Check to ensure that constants are compatible with the type initializer!
Chandler Carruth563d4a42007-08-04 01:56:21 +00004293 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4294 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 GEN_ERROR("Expected type '" +
4296 STy->getElementType(i)->getDescription() +
4297 "' for element #" + utostr(i) +
4298 " of structure initializer");
4299
4300 // Check to ensure that Type is not packed
4301 if (STy->isPacked())
4302 GEN_ERROR("Unpacked Initializer to vector type '" +
4303 STy->getDescription() + "'");
4304
Chandler Carruth563d4a42007-08-04 01:56:21 +00004305 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4306 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004307 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004308 ;}
4309 break;
4310
4311 case 167:
4312#line 1651 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4313 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004314 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004315 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4316 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004317 if (STy == 0)
4318 GEN_ERROR("Cannot make struct constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004319 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004320
4321 if (STy->getNumContainedTypes() != 0)
4322 GEN_ERROR("Illegal number of initializers for structure type");
4323
4324 // Check to ensure that Type is not packed
4325 if (STy->isPacked())
4326 GEN_ERROR("Unpacked Initializer to vector type '" +
4327 STy->getDescription() + "'");
4328
Chandler Carruth563d4a42007-08-04 01:56:21 +00004329 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4330 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004331 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004332 ;}
4333 break;
4334
4335 case 168:
4336#line 1671 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4337 {
4338 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004339 if (STy == 0)
4340 GEN_ERROR("Cannot make struct constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004341 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004342
Chandler Carruth563d4a42007-08-04 01:56:21 +00004343 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004344 GEN_ERROR("Illegal number of initializers for structure type");
4345
4346 // Check to ensure that constants are compatible with the type initializer!
Chandler Carruth563d4a42007-08-04 01:56:21 +00004347 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4348 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004349 GEN_ERROR("Expected type '" +
4350 STy->getElementType(i)->getDescription() +
4351 "' for element #" + utostr(i) +
4352 " of structure initializer");
4353
4354 // Check to ensure that Type is packed
4355 if (!STy->isPacked())
4356 GEN_ERROR("Vector initializer to non-vector type '" +
4357 STy->getDescription() + "'");
4358
Chandler Carruth563d4a42007-08-04 01:56:21 +00004359 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4360 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004361 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004362 ;}
4363 break;
4364
4365 case 169:
4366#line 1697 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4367 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004369 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4370 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004371 if (STy == 0)
4372 GEN_ERROR("Cannot make struct constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004373 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004374
4375 if (STy->getNumContainedTypes() != 0)
4376 GEN_ERROR("Illegal number of initializers for structure type");
4377
4378 // Check to ensure that Type is packed
4379 if (!STy->isPacked())
4380 GEN_ERROR("Vector initializer to non-vector type '" +
4381 STy->getDescription() + "'");
4382
Chandler Carruth563d4a42007-08-04 01:56:21 +00004383 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4384 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004385 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004386 ;}
4387 break;
4388
4389 case 170:
4390#line 1717 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4391 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004392 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004393 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4394 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004395 if (PTy == 0)
4396 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004397 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004398
Chandler Carruth563d4a42007-08-04 01:56:21 +00004399 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4400 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004401 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004402 ;}
4403 break;
4404
4405 case 171:
4406#line 1729 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4407 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004408 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004409 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4410 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4411 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004412 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004413 ;}
4414 break;
4415
4416 case 172:
4417#line 1736 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4418 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004419 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004420 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4421 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004422 if (Ty == 0)
4423 GEN_ERROR("Global const reference must be a pointer type");
4424
4425 // ConstExprs can exist in the body of a function, thus creating
4426 // GlobalValues whenever they refer to a variable. Because we are in
4427 // the context of a function, getExistingVal will search the functions
4428 // symbol table instead of the module symbol table for the global symbol,
4429 // which throws things all off. To get around this, we just tell
4430 // getExistingVal that we are at global scope here.
4431 //
4432 Function *SavedCurFn = CurFun.CurrentFunction;
4433 CurFun.CurrentFunction = 0;
4434
Chandler Carruth563d4a42007-08-04 01:56:21 +00004435 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004436 CHECK_FOR_ERROR
4437
4438 CurFun.CurrentFunction = SavedCurFn;
4439
4440 // If this is an initializer for a constant pointer, which is referencing a
4441 // (currently) undefined variable, create a stub now that shall be replaced
4442 // in the future with the right type of variable.
4443 //
4444 if (V == 0) {
4445 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4446 const PointerType *PT = cast<PointerType>(Ty);
4447
4448 // First check to see if the forward references value is already created!
4449 PerModuleInfo::GlobalRefsType::iterator I =
Chandler Carruth563d4a42007-08-04 01:56:21 +00004450 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004451
4452 if (I != CurModule.GlobalRefs.end()) {
4453 V = I->second; // Placeholder already exists, use it...
Chandler Carruth563d4a42007-08-04 01:56:21 +00004454 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004455 } else {
4456 std::string Name;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004457 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4458 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4459 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004460 GEN_ERROR("Invalid reference to global");
4461
4462 // Create the forward referenced global.
4463 GlobalValue *GV;
4464 if (const FunctionType *FTy =
4465 dyn_cast<FunctionType>(PT->getElementType())) {
4466 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
4467 CurModule.CurrentModule);
4468 } else {
4469 GV = new GlobalVariable(PT->getElementType(), false,
4470 GlobalValue::ExternalWeakLinkage, 0,
4471 Name, CurModule.CurrentModule);
4472 }
4473
4474 // Keep track of the fact that we have a forward ref to recycle it
Chandler Carruth563d4a42007-08-04 01:56:21 +00004475 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004476 V = GV;
4477 }
4478 }
4479
Chandler Carruth563d4a42007-08-04 01:56:21 +00004480 (yyval.ConstVal) = cast<GlobalValue>(V);
4481 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004482 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004483 ;}
4484 break;
4485
4486 case 173:
4487#line 1802 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4488 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004489 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004490 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4491 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004492 GEN_ERROR("Mismatched types for constant expression: " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00004493 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4494 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4495 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004496 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004497 ;}
4498 break;
4499
4500 case 174:
4501#line 1812 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4502 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004503 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004504 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4505 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004506 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4507 GEN_ERROR("Cannot create a null initialized value of this type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004508 (yyval.ConstVal) = Constant::getNullValue(Ty);
4509 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004510 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004511 ;}
4512 break;
4513
4514 case 175:
4515#line 1822 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4516 { // integral constants
4517 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004518 GEN_ERROR("Constant value doesn't fit in type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004519 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004520 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004521 ;}
4522 break;
4523
4524 case 176:
4525#line 1828 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4526 { // arbitrary precision integer constants
4527 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4528 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004529 GEN_ERROR("Constant value does not fit in type");
4530 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00004531 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4532 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4533 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004534 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004535 ;}
4536 break;
4537
4538 case 177:
4539#line 1838 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4540 { // integral constants
4541 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004542 GEN_ERROR("Constant value doesn't fit in type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004543 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004544 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004545 ;}
4546 break;
4547
4548 case 178:
4549#line 1844 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4550 { // arbitrary precision integer constants
4551 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4552 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004553 GEN_ERROR("Constant value does not fit in type");
4554 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00004555 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4556 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4557 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004558 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004559 ;}
4560 break;
4561
4562 case 179:
4563#line 1854 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4564 { // Boolean constants
4565 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4566 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004567 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004568 ;}
4569 break;
4570
4571 case 180:
4572#line 1859 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4573 { // Boolean constants
4574 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4575 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004576 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004577 ;}
4578 break;
4579
4580 case 181:
4581#line 1864 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4582 { // Float & Double constants
4583 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004584 GEN_ERROR("Floating point constant invalid for type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004585 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004586 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004587 ;}
4588 break;
4589
4590 case 182:
4591#line 1872 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4592 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004593 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004594 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4595 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4596 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4597 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004598 GEN_ERROR("invalid cast opcode for cast from '" +
4599 Val->getType()->getDescription() + "' to '" +
4600 DestTy->getDescription() + "'");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004601 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4602 delete (yyvsp[(5) - (6)].TypeVal);
4603 ;}
4604 break;
4605
4606 case 183:
4607#line 1884 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4608 {
4609 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004610 GEN_ERROR("GetElementPtr requires a pointer operand");
4611
4612 const Type *IdxTy =
Chandler Carruth563d4a42007-08-04 01:56:21 +00004613 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004614 true);
4615 if (!IdxTy)
4616 GEN_ERROR("Index list invalid for constant getelementptr");
4617
4618 SmallVector<Constant*, 8> IdxVec;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004619 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4620 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004621 IdxVec.push_back(C);
4622 else
4623 GEN_ERROR("Indices to constant getelementptr must be constants");
4624
Chandler Carruth563d4a42007-08-04 01:56:21 +00004625 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004626
Chandler Carruth563d4a42007-08-04 01:56:21 +00004627 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004628 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004629 ;}
4630 break;
4631
4632 case 184:
4633#line 1906 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4634 {
4635 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004636 GEN_ERROR("Select condition must be of boolean type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004637 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004638 GEN_ERROR("Select operand types must match");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004639 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004640 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004641 ;}
4642 break;
4643
4644 case 185:
4645#line 1914 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4646 {
4647 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004648 GEN_ERROR("Binary operator types must match");
4649 CHECK_FOR_ERROR;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004650 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4651 ;}
4652 break;
4653
4654 case 186:
4655#line 1920 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4656 {
4657 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004658 GEN_ERROR("Logical operator types must match");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004659 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4660 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4661 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004662 GEN_ERROR("Logical operator requires integral operands");
4663 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00004664 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004665 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004666 ;}
4667 break;
4668
4669 case 187:
4670#line 1931 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4671 {
4672 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004673 GEN_ERROR("icmp operand types must match");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004674 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4675 ;}
4676 break;
4677
4678 case 188:
4679#line 1936 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4680 {
4681 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004682 GEN_ERROR("fcmp operand types must match");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004683 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4684 ;}
4685 break;
4686
4687 case 189:
4688#line 1941 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4689 {
4690 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004691 GEN_ERROR("Invalid extractelement operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004692 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004693 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004694 ;}
4695 break;
4696
4697 case 190:
4698#line 1947 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4699 {
4700 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004701 GEN_ERROR("Invalid insertelement operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004702 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004703 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004704 ;}
4705 break;
4706
4707 case 191:
4708#line 1953 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4709 {
4710 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004711 GEN_ERROR("Invalid shufflevector operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004712 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004713 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004714 ;}
4715 break;
4716
4717 case 192:
4718#line 1962 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4719 {
4720 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004721 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004722 ;}
4723 break;
4724
4725 case 193:
4726#line 1966 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4727 {
4728 (yyval.ConstVector) = new std::vector<Constant*>();
4729 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004730 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004731 ;}
4732 break;
4733
4734 case 194:
4735#line 1974 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4736 { (yyval.BoolVal) = false; ;}
4737 break;
4738
4739 case 195:
4740#line 1974 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4741 { (yyval.BoolVal) = true; ;}
4742 break;
4743
4744 case 196:
4745#line 1977 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4746 { (yyval.BoolVal) = true; ;}
4747 break;
4748
4749 case 197:
4750#line 1977 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4751 { (yyval.BoolVal) = false; ;}
4752 break;
4753
4754 case 198:
4755#line 1980 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4756 {
4757 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4758 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004759 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4760 if (!Aliasee)
4761 GEN_ERROR("Aliases can be created only to global values");
4762
Chandler Carruth563d4a42007-08-04 01:56:21 +00004763 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004764 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004765 delete (yyvsp[(1) - (2)].TypeVal);
4766 ;}
4767 break;
4768
4769 case 199:
4770#line 1991 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4771 {
4772 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4773 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4774 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004775 GEN_ERROR("invalid cast opcode for cast from '" +
4776 Val->getType()->getDescription() + "' to '" +
4777 DestTy->getDescription() + "'");
4778
Chandler Carruth563d4a42007-08-04 01:56:21 +00004779 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004780 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004781 delete (yyvsp[(5) - (6)].TypeVal);
4782 ;}
4783 break;
4784
4785 case 200:
4786#line 2012 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4787 {
4788 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer47470022007-07-31 14:41:17 +00004789 CurModule.ModuleDone();
4790 CHECK_FOR_ERROR;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004791 ;}
4792 break;
4793
4794 case 201:
4795#line 2017 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4796 {
4797 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004798 CurModule.ModuleDone();
4799 CHECK_FOR_ERROR;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004800 ;}
4801 break;
4802
4803 case 204:
4804#line 2030 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4805 { CurFun.isDeclare = false; ;}
4806 break;
4807
4808 case 205:
4809#line 2030 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4810 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004811 CurFun.FunctionDone();
4812 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004813 ;}
4814 break;
4815
4816 case 206:
4817#line 2034 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4818 { CurFun.isDeclare = true; ;}
4819 break;
4820
4821 case 207:
4822#line 2034 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4823 {
Reid Spencer47470022007-07-31 14:41:17 +00004824 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004825 ;}
4826 break;
4827
4828 case 208:
4829#line 2037 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4830 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004831 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004832 ;}
4833 break;
4834
4835 case 209:
4836#line 2040 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4837 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004838 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004839 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004840 // Eagerly resolve types. This is not an optimization, this is a
4841 // requirement that is due to the fact that we could have this:
4842 //
4843 // %list = type { %list * }
4844 // %list = type { %list * } ; repeated type decl
4845 //
4846 // If types are not resolved eagerly, then the two types will not be
4847 // determined to be the same type!
4848 //
Chandler Carruth563d4a42007-08-04 01:56:21 +00004849 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004850
Chandler Carruth563d4a42007-08-04 01:56:21 +00004851 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004852 CHECK_FOR_ERROR
4853 // If this is a named type that is not a redefinition, add it to the slot
4854 // table.
Chandler Carruth563d4a42007-08-04 01:56:21 +00004855 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004856 }
4857
Chandler Carruth563d4a42007-08-04 01:56:21 +00004858 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004859 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004860 ;}
4861 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004862
Chandler Carruth563d4a42007-08-04 01:56:21 +00004863 case 210:
4864#line 2064 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4865 {
4866 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4867
4868 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004869 CHECK_FOR_ERROR
4870 // If this is a named type that is not a redefinition, add it to the slot
4871 // table.
Chandler Carruth563d4a42007-08-04 01:56:21 +00004872 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004873 }
4874 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004875 ;}
4876 break;
4877
4878 case 211:
4879#line 2075 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4880 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004881 /* "Externally Visible" Linkage */
Chandler Carruth563d4a42007-08-04 01:56:21 +00004882 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004883 GEN_ERROR("Global value initializer is not a constant");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004884 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4885 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004886 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004887 ;}
4888 break;
4889
4890 case 212:
4891#line 2082 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4892 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004893 CurGV = 0;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004894 ;}
4895 break;
4896
4897 case 213:
4898#line 2086 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4899 {
4900 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004901 GEN_ERROR("Global value initializer is not a constant");
Chandler Carruth563d4a42007-08-04 01:56:21 +00004902 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004903 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004904 ;}
4905 break;
4906
4907 case 214:
4908#line 2091 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4909 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004910 CurGV = 0;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004911 ;}
4912 break;
4913
4914 case 215:
4915#line 2095 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4916 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004917 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004918 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4919 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), *(yyvsp[(6) - (6)].TypeVal), 0, (yyvsp[(4) - (6)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004920 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004921 delete (yyvsp[(6) - (6)].TypeVal);
4922 ;}
4923 break;
4924
4925 case 216:
4926#line 2101 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4927 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004928 CurGV = 0;
4929 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004930 ;}
4931 break;
4932
4933 case 217:
4934#line 2105 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4935 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004936 std::string Name;
Chandler Carruth563d4a42007-08-04 01:56:21 +00004937 if ((yyvsp[(1) - (5)].StrVal)) {
4938 Name = *(yyvsp[(1) - (5)].StrVal);
4939 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004940 }
4941 if (Name.empty())
4942 GEN_ERROR("Alias name cannot be empty");
4943
Chandler Carruth563d4a42007-08-04 01:56:21 +00004944 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004945 if (Aliasee == 0)
4946 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
4947
Chandler Carruth563d4a42007-08-04 01:56:21 +00004948 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004949 CurModule.CurrentModule);
Chandler Carruth563d4a42007-08-04 01:56:21 +00004950 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004951 InsertValue(GA, CurModule.Values);
4952 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004953 ;}
4954 break;
4955
4956 case 218:
4957#line 2124 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4958 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004959 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004960 ;}
4961 break;
4962
4963 case 219:
4964#line 2127 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4965 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004966 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004967 ;}
4968 break;
4969
4970 case 220:
4971#line 2133 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4972 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004973 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4974 if (AsmSoFar.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00004975 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004976 else
Chandler Carruth563d4a42007-08-04 01:56:21 +00004977 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
4978 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004979 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00004980;}
4981 break;
4982
4983 case 221:
4984#line 2143 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4985 {
4986 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
4987 delete (yyvsp[(3) - (3)].StrVal);
4988 ;}
4989 break;
4990
4991 case 222:
4992#line 2147 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
4993 {
4994 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
4995 delete (yyvsp[(3) - (3)].StrVal);
4996 ;}
4997 break;
4998
4999 case 224:
5000#line 2154 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5001 {
5002 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5003 delete (yyvsp[(3) - (3)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005004 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005005 ;}
5006 break;
5007
5008 case 225:
5009#line 2159 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5010 {
5011 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5012 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005013 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005014 ;}
5015 break;
5016
5017 case 226:
5018#line 2164 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5019 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005020 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005021 ;}
5022 break;
5023
5024 case 227:
5025#line 2173 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5026 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005027 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005028 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5029 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005030 GEN_ERROR("void typed arguments are invalid");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005031 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5032 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5033 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005034 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005035 ;}
5036 break;
5037
5038 case 228:
5039#line 2183 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5040 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005041 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005042 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5043 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005044 GEN_ERROR("void typed arguments are invalid");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005045 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5046 (yyval.ArgList) = new ArgListType;
5047 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005048 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005049 ;}
5050 break;
5051
5052 case 229:
5053#line 2194 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5054 {
5055 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005056 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005057 ;}
5058 break;
5059
5060 case 230:
5061#line 2198 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5062 {
5063 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005064 struct ArgListEntry E;
5065 E.Ty = new PATypeHolder(Type::VoidTy);
5066 E.Name = 0;
5067 E.Attrs = ParamAttr::None;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005068 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005069 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005070 ;}
5071 break;
5072
5073 case 231:
5074#line 2207 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5075 {
5076 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005077 struct ArgListEntry E;
5078 E.Ty = new PATypeHolder(Type::VoidTy);
5079 E.Name = 0;
5080 E.Attrs = ParamAttr::None;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005081 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005082 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005083 ;}
5084 break;
5085
5086 case 232:
5087#line 2216 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5088 {
5089 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005090 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005091 ;}
5092 break;
5093
5094 case 233:
5095#line 2222 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5096 {
5097 std::string FunctionName(*(yyvsp[(3) - (9)].StrVal));
5098 delete (yyvsp[(3) - (9)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005099
5100 // Check the function result for abstractness if this is a define. We should
5101 // have no abstract types at this point
Chandler Carruth563d4a42007-08-04 01:56:21 +00005102 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
5103 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005104
5105 std::vector<const Type*> ParamTypeList;
5106 ParamAttrsVector Attrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005107 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
5108 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005109 Attrs.push_back(PAWI);
5110 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005111 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005112 unsigned index = 1;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005113 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005114 const Type* Ty = I->Ty->get();
5115 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5116 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5117 ParamTypeList.push_back(Ty);
5118 if (Ty != Type::VoidTy)
5119 if (I->Attrs != ParamAttr::None) {
5120 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5121 Attrs.push_back(PAWI);
5122 }
5123 }
5124 }
5125
5126 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5127 if (isVarArg) ParamTypeList.pop_back();
5128
5129 ParamAttrsList *PAL = 0;
5130 if (!Attrs.empty())
5131 PAL = ParamAttrsList::get(Attrs);
5132
Chandler Carruth563d4a42007-08-04 01:56:21 +00005133 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005134 const PointerType *PFT = PointerType::get(FT);
Chandler Carruth563d4a42007-08-04 01:56:21 +00005135 delete (yyvsp[(2) - (9)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005136
5137 ValID ID;
5138 if (!FunctionName.empty()) {
5139 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5140 } else {
5141 ID = ValID::createGlobalID(CurModule.Values.size());
5142 }
5143
5144 Function *Fn = 0;
5145 // See if this function was forward referenced. If so, recycle the object.
5146 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5147 // Move the function to the end of the list, from whereever it was
5148 // previously inserted.
5149 Fn = cast<Function>(FWRef);
5150 CurModule.CurrentModule->getFunctionList().remove(Fn);
5151 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5152 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5153 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
5154 if (Fn->getFunctionType() != FT) {
5155 // The existing function doesn't have the same type. This is an overload
5156 // error.
5157 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
5158 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5159 // Neither the existing or the current function is a declaration and they
5160 // have the same name and same type. Clearly this is a redefinition.
5161 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
5162 } if (Fn->isDeclaration()) {
5163 // Make sure to strip off any argument names so we can't get conflicts.
5164 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5165 AI != AE; ++AI)
5166 AI->setName("");
5167 }
5168 } else { // Not already defined?
5169 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5170 CurModule.CurrentModule);
5171
5172 InsertValue(Fn, CurModule.Values);
5173 }
5174
5175 CurFun.FunctionStart(Fn);
5176
5177 if (CurFun.isDeclare) {
5178 // If we have declaration, always overwrite linkage. This will allow us to
5179 // correctly handle cases, when pointer to function is passed as argument to
5180 // another function.
5181 Fn->setLinkage(CurFun.Linkage);
5182 Fn->setVisibility(CurFun.Visibility);
5183 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005184 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5185 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5186 if ((yyvsp[(8) - (9)].StrVal)) {
5187 Fn->setSection(*(yyvsp[(8) - (9)].StrVal));
5188 delete (yyvsp[(8) - (9)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005189 }
5190
5191 // Add all of the arguments we parsed to the function...
Chandler Carruth563d4a42007-08-04 01:56:21 +00005192 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005193 if (isVarArg) { // Nuke the last entry
Chandler Carruth563d4a42007-08-04 01:56:21 +00005194 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005195 "Not a varargs marker!");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005196 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5197 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 }
5199 Function::arg_iterator ArgIt = Fn->arg_begin();
5200 Function::arg_iterator ArgEnd = Fn->arg_end();
5201 unsigned Idx = 1;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005202 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5203 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005204 delete I->Ty; // Delete the typeholder...
5205 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5206 CHECK_FOR_ERROR
5207 InsertValue(ArgIt);
5208 Idx++;
5209 }
5210
Chandler Carruth563d4a42007-08-04 01:56:21 +00005211 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005212 }
5213 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005214;}
5215 break;
5216
5217 case 236:
5218#line 2344 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5219 {
5220 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005221
5222 // Make sure that we keep track of the linkage type even if there was a
5223 // previous "declare".
Chandler Carruth563d4a42007-08-04 01:56:21 +00005224 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5225 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5226;}
5227 break;
5228
5229 case 239:
5230#line 2355 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5231 {
5232 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005233 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005234;}
5235 break;
5236
5237 case 240:
5238#line 2360 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5239 {
5240 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5241 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5242 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005243 CurFun.FunctionDone();
5244 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005245 ;}
5246 break;
5247
5248 case 241:
5249#line 2372 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5250 {
5251 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005252 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005253 ;}
5254 break;
5255
5256 case 242:
5257#line 2376 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5258 {
5259 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005260 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005261 ;}
5262 break;
5263
5264 case 243:
5265#line 2381 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5266 { // A reference to a direct constant
5267 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005268 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005269 ;}
5270 break;
5271
5272 case 244:
5273#line 2385 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5274 {
5275 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005276 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005277 ;}
5278 break;
5279
5280 case 245:
5281#line 2389 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5282 { // Perhaps it's an FP constant?
5283 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005284 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005285 ;}
5286 break;
5287
5288 case 246:
5289#line 2393 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5290 {
5291 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005292 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005293 ;}
5294 break;
5295
5296 case 247:
5297#line 2397 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5298 {
5299 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005300 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005301 ;}
5302 break;
5303
5304 case 248:
5305#line 2401 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5306 {
5307 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005308 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005309 ;}
5310 break;
5311
5312 case 249:
5313#line 2405 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5314 {
5315 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005316 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005317 ;}
5318 break;
5319
5320 case 250:
5321#line 2409 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5322 { // A vector zero constant.
5323 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005324 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005325 ;}
5326 break;
5327
5328 case 251:
5329#line 2413 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5330 { // Nonempty unsized packed vector
5331 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5332 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005333
5334 VectorType* pt = VectorType::get(ETy, NumElements);
5335 PATypeHolder* PTy = new PATypeHolder(
5336 HandleUpRefs(
5337 VectorType::get(
5338 ETy,
5339 NumElements)
5340 )
5341 );
5342
5343 // Verify all elements are correct type!
Chandler Carruth563d4a42007-08-04 01:56:21 +00005344 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5345 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005346 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5347 ETy->getDescription() +"' as required!\nIt is of type '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00005348 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005349 }
5350
Chandler Carruth563d4a42007-08-04 01:56:21 +00005351 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5352 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005353 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005354 ;}
5355 break;
5356
5357 case 252:
5358#line 2438 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5359 {
5360 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005361 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005362 ;}
5363 break;
5364
5365 case 253:
5366#line 2442 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5367 {
5368 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5369 delete (yyvsp[(3) - (5)].StrVal);
5370 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005371 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005372 ;}
5373 break;
5374
5375 case 254:
5376#line 2452 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5377 { // Is it an integer reference...?
5378 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005379 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005380 ;}
5381 break;
5382
5383 case 255:
5384#line 2456 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5385 {
5386 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005387 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005388 ;}
5389 break;
5390
5391 case 256:
5392#line 2460 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5393 { // Is it a named reference...?
5394 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5395 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005396 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005397 ;}
5398 break;
5399
5400 case 257:
5401#line 2465 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5402 { // Is it a named reference...?
5403 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5404 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005405 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005406 ;}
5407 break;
5408
5409 case 260:
5410#line 2478 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5411 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005412 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005413 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5414 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5415 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005416 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005417 ;}
5418 break;
5419
5420 case 261:
5421#line 2487 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5422 {
5423 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005424 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005425 ;}
5426 break;
5427
5428 case 262:
5429#line 2491 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5430 { // Do not allow functions with 0 basic blocks
5431 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005432 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005433 ;}
5434 break;
5435
5436 case 263:
5437#line 2500 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5438 {
5439 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005440 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005441 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5442 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5443 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005444 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005445 ;}
5446 break;
5447
5448 case 264:
5449#line 2509 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5450 {
5451 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005452 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5453 if (CI2->getParent() == 0)
Chandler Carruth563d4a42007-08-04 01:56:21 +00005454 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5455 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5456 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005457 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005458 ;}
5459 break;
5460
5461 case 265:
5462#line 2518 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5463 { // Empty space between instruction lists
5464 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005465 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005466 ;}
5467 break;
5468
5469 case 266:
5470#line 2522 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5471 { // Labelled (named) basic block
5472 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5473 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005474 CHECK_FOR_ERROR
5475
Chandler Carruth563d4a42007-08-04 01:56:21 +00005476 ;}
5477 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005478
Chandler Carruth563d4a42007-08-04 01:56:21 +00005479 case 267:
5480#line 2529 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5481 { // Return with a result...
5482 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5483 CHECK_FOR_ERROR
5484 ;}
5485 break;
5486
5487 case 268:
5488#line 2533 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5489 { // Return with no result...
5490 (yyval.TermInstVal) = new ReturnInst();
5491 CHECK_FOR_ERROR
5492 ;}
5493 break;
5494
5495 case 269:
5496#line 2537 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5497 { // Unconditional Branch...
5498 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5499 CHECK_FOR_ERROR
5500 (yyval.TermInstVal) = new BranchInst(tmpBB);
5501 ;}
5502 break;
5503
5504 case 270:
5505#line 2542 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5506 {
5507 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5508 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5509 CHECK_FOR_ERROR
5510 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5511 CHECK_FOR_ERROR
5512 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5513 CHECK_FOR_ERROR
5514 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5515 ;}
5516 break;
5517
5518 case 271:
5519#line 2552 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5520 {
5521 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5522 CHECK_FOR_ERROR
5523 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5524 CHECK_FOR_ERROR
5525 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5526 (yyval.TermInstVal) = S;
5527
5528 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5529 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005530 for (; I != E; ++I) {
5531 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5532 S->addCase(CI, I->second);
5533 else
5534 GEN_ERROR("Switch case is constant, but not a simple integer");
5535 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005536 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005537 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005538 ;}
5539 break;
5540
5541 case 272:
5542#line 2571 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5543 {
5544 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005545 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005546 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005547 CHECK_FOR_ERROR
5548 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chandler Carruth563d4a42007-08-04 01:56:21 +00005549 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005550 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005551 ;}
5552 break;
5553
5554 case 273:
5555#line 2581 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5556 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005557
5558 // Handle the short syntax
5559 const PointerType *PFTy = 0;
5560 const FunctionType *Ty = 0;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005561 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005562 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5563 // Pull out the types of all of the arguments...
5564 std::vector<const Type*> ParamTypes;
5565 ParamAttrsVector Attrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005566 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5567 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005568 Attrs.push_back(PAWI);
5569 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005570 ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005571 unsigned index = 1;
5572 for (; I != E; ++I, ++index) {
5573 const Type *Ty = I->Val->getType();
5574 if (Ty == Type::VoidTy)
5575 GEN_ERROR("Short call syntax cannot be used with varargs");
5576 ParamTypes.push_back(Ty);
5577 if (I->Attrs != ParamAttr::None) {
5578 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5579 Attrs.push_back(PAWI);
5580 }
5581 }
5582
5583 ParamAttrsList *PAL = 0;
5584 if (!Attrs.empty())
5585 PAL = ParamAttrsList::get(Attrs);
Chandler Carruth563d4a42007-08-04 01:56:21 +00005586 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005587 PFTy = PointerType::get(Ty);
5588 }
5589
Chandler Carruth563d4a42007-08-04 01:56:21 +00005590 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005591
Chandler Carruth563d4a42007-08-04 01:56:21 +00005592 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005593 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005594 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005595 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005596 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005597 CHECK_FOR_ERROR
5598
5599 // Check the arguments
5600 ValueList Args;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005601 if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005602 // Make sure no arguments is a good thing!
5603 if (Ty->getNumParams() != 0)
5604 GEN_ERROR("No arguments passed to a function that "
5605 "expects arguments");
5606 } else { // Has arguments?
5607 // Loop through FunctionType's arguments and ensure they are specified
5608 // correctly!
5609 FunctionType::param_iterator I = Ty->param_begin();
5610 FunctionType::param_iterator E = Ty->param_end();
Chandler Carruth563d4a42007-08-04 01:56:21 +00005611 ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005612
5613 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5614 if (ArgI->Val->getType() != *I)
5615 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5616 (*I)->getDescription() + "'");
5617 Args.push_back(ArgI->Val);
5618 }
5619
5620 if (Ty->isVarArg()) {
5621 if (I == E)
5622 for (; ArgI != ArgE; ++ArgI)
5623 Args.push_back(ArgI->Val); // push the remaining varargs
5624 } else if (I != E || ArgI != ArgE)
5625 GEN_ERROR("Invalid number of parameters detected");
5626 }
5627
5628 // Create the InvokeInst
5629 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Chandler Carruth563d4a42007-08-04 01:56:21 +00005630 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5631 (yyval.TermInstVal) = II;
5632 delete (yyvsp[(6) - (14)].ValueRefList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005633 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005634 ;}
5635 break;
5636
5637 case 274:
5638#line 2660 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5639 {
5640 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005641 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005642 ;}
5643 break;
5644
5645 case 275:
5646#line 2664 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5647 {
5648 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005649 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005650 ;}
5651 break;
5652
5653 case 276:
5654#line 2671 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5655 {
5656 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5657 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005658 CHECK_FOR_ERROR
5659 if (V == 0)
5660 GEN_ERROR("May only switch on a constant pool value");
5661
Chandler Carruth563d4a42007-08-04 01:56:21 +00005662 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005663 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005664 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5665 ;}
5666 break;
5667
5668 case 277:
5669#line 2682 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5670 {
5671 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5672 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005673 CHECK_FOR_ERROR
5674
5675 if (V == 0)
5676 GEN_ERROR("May only switch on a constant pool value");
5677
Chandler Carruth563d4a42007-08-04 01:56:21 +00005678 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005679 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005680 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5681 ;}
5682 break;
5683
5684 case 278:
5685#line 2695 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5686 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005687 // Is this definition named?? if so, assign the name...
Chandler Carruth563d4a42007-08-04 01:56:21 +00005688 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005689 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005690 InsertValue((yyvsp[(2) - (2)].InstVal));
5691 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005692 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005693 ;}
5694 break;
5695
5696 case 279:
5697#line 2705 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5698 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005699 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005700 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5701 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5702 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005703 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005704 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005705 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005706 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5707 delete (yyvsp[(1) - (6)].TypeVal);
5708 ;}
5709 break;
5710
5711 case 280:
5712#line 2716 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5713 {
5714 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5715 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005716 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005717 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005718 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005719 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5720 ;}
5721 break;
5722
5723 case 281:
5724#line 2726 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5725 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005726 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005727 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005728 // Used for call and invoke instructions
Chandler Carruth563d4a42007-08-04 01:56:21 +00005729 (yyval.ValueRefList) = new ValueRefList();
5730 ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5731 (yyval.ValueRefList)->push_back(E);
5732 delete (yyvsp[(1) - (3)].TypeVal);
5733 ;}
5734 break;
5735
5736 case 282:
5737#line 2735 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5738 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005739 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005740 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5741 (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList);
5742 ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5743 (yyval.ValueRefList)->push_back(E);
5744 delete (yyvsp[(3) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005745 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005746 ;}
5747 break;
5748
5749 case 283:
5750#line 2744 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5751 { (yyval.ValueRefList) = new ValueRefList(); ;}
5752 break;
5753
5754 case 284:
5755#line 2747 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5756 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5757 break;
5758
5759 case 285:
5760#line 2748 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5761 {
5762 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5763 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005764 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005765 ;}
5766 break;
5767
5768 case 286:
5769#line 2755 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5770 {
5771 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005772 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005773 ;}
5774 break;
5775
5776 case 287:
5777#line 2759 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5778 {
5779 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005780 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005781 ;}
5782 break;
5783
5784 case 288:
5785#line 2764 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5786 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005787 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005788 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5789 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5790 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005791 GEN_ERROR(
5792 "Arithmetic operator requires integer, FP, or packed operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005793 if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) &&
5794 ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem ||
5795 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem ||
5796 (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005797 GEN_ERROR("Remainder not supported on vector types");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005798 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005799 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005800 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005801 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005802 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5803 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005804 GEN_ERROR("binary operator returned null");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005805 delete (yyvsp[(2) - (5)].TypeVal);
5806 ;}
5807 break;
5808
5809 case 289:
5810#line 2785 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5811 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005812 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005813 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5814 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5815 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5816 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005817 GEN_ERROR("Logical operator requires integral operands");
5818 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005819 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005820 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005821 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005822 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005823 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5824 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005825 GEN_ERROR("binary operator returned null");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005826 delete (yyvsp[(2) - (5)].TypeVal);
5827 ;}
5828 break;
5829
5830 case 290:
5831#line 2802 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5832 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005833 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005834 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5835 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005836 GEN_ERROR("Vector types not supported by icmp instruction");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005837 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005838 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005839 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005840 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005841 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5842 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005843 GEN_ERROR("icmp operator returned null");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005844 delete (yyvsp[(3) - (6)].TypeVal);
5845 ;}
5846 break;
5847
5848 case 291:
5849#line 2816 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5850 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005851 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005852 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5853 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005854 GEN_ERROR("Vector types not supported by fcmp instruction");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005855 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005856 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005857 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005858 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005859 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5860 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005861 GEN_ERROR("fcmp operator returned null");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005862 delete (yyvsp[(3) - (6)].TypeVal);
5863 ;}
5864 break;
5865
5866 case 292:
5867#line 2830 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5868 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005869 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005870 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5871 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5872 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5873 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005874 GEN_ERROR("invalid cast opcode for cast from '" +
5875 Val->getType()->getDescription() + "' to '" +
5876 DestTy->getDescription() + "'");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005877 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5878 delete (yyvsp[(4) - (4)].TypeVal);
5879 ;}
5880 break;
5881
5882 case 293:
5883#line 2842 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5884 {
5885 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005886 GEN_ERROR("select condition must be boolean");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005887 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005888 GEN_ERROR("select value types should match");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005889 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005890 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005891 ;}
5892 break;
5893
5894 case 294:
5895#line 2850 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5896 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005897 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00005898 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5899 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5900 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005901 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005902 ;}
5903 break;
5904
5905 case 295:
5906#line 2857 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5907 {
5908 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005909 GEN_ERROR("Invalid extractelement operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005910 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005911 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005912 ;}
5913 break;
5914
5915 case 296:
5916#line 2863 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5917 {
5918 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005919 GEN_ERROR("Invalid insertelement operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005920 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005921 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005922 ;}
5923 break;
5924
5925 case 297:
5926#line 2869 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5927 {
5928 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005929 GEN_ERROR("Invalid shufflevector operands");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005930 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005931 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005932 ;}
5933 break;
5934
5935 case 298:
5936#line 2875 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5937 {
5938 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005939 if (!Ty->isFirstClassType())
5940 GEN_ERROR("PHI node operands must be of first class type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005941 (yyval.InstVal) = new PHINode(Ty);
5942 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
5943 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
5944 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005945 GEN_ERROR("All elements of a PHI node must be of the same type");
Chandler Carruth563d4a42007-08-04 01:56:21 +00005946 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
5947 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005948 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00005949 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005950 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00005951 ;}
5952 break;
5953
5954 case 299:
5955#line 2891 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
5956 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005957
5958 // Handle the short syntax
5959 const PointerType *PFTy = 0;
5960 const FunctionType *Ty = 0;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005961 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005962 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5963 // Pull out the types of all of the arguments...
5964 std::vector<const Type*> ParamTypes;
5965 ParamAttrsVector Attrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005966 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
5967 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005968 Attrs.push_back(PAWI);
5969 }
5970 unsigned index = 1;
Chandler Carruth563d4a42007-08-04 01:56:21 +00005971 ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005972 for (; I != E; ++I, ++index) {
5973 const Type *Ty = I->Val->getType();
5974 if (Ty == Type::VoidTy)
5975 GEN_ERROR("Short call syntax cannot be used with varargs");
5976 ParamTypes.push_back(Ty);
5977 if (I->Attrs != ParamAttr::None) {
5978 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5979 Attrs.push_back(PAWI);
5980 }
5981 }
5982
5983 ParamAttrsList *PAL = 0;
5984 if (!Attrs.empty())
5985 PAL = ParamAttrsList::get(Attrs);
5986
Chandler Carruth563d4a42007-08-04 01:56:21 +00005987 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005988 PFTy = PointerType::get(Ty);
5989 }
5990
Chandler Carruth563d4a42007-08-04 01:56:21 +00005991 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005992 CHECK_FOR_ERROR
5993
5994 // Check for call to invalid intrinsic to avoid crashing later.
5995 if (Function *theF = dyn_cast<Function>(V)) {
5996 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
5997 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5998 !theF->getIntrinsicID(true))
5999 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6000 theF->getName() + "'");
6001 }
6002
6003 // Check the arguments
6004 ValueList Args;
Chandler Carruth563d4a42007-08-04 01:56:21 +00006005 if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006006 // Make sure no arguments is a good thing!
6007 if (Ty->getNumParams() != 0)
6008 GEN_ERROR("No arguments passed to a function that "
6009 "expects arguments");
6010 } else { // Has arguments?
6011 // Loop through FunctionType's arguments and ensure they are specified
6012 // correctly!
6013 //
6014 FunctionType::param_iterator I = Ty->param_begin();
6015 FunctionType::param_iterator E = Ty->param_end();
Chandler Carruth563d4a42007-08-04 01:56:21 +00006016 ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006017
6018 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6019 if (ArgI->Val->getType() != *I)
6020 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6021 (*I)->getDescription() + "'");
6022 Args.push_back(ArgI->Val);
6023 }
6024 if (Ty->isVarArg()) {
6025 if (I == E)
6026 for (; ArgI != ArgE; ++ArgI)
6027 Args.push_back(ArgI->Val); // push the remaining varargs
6028 } else if (I != E || ArgI != ArgE)
6029 GEN_ERROR("Invalid number of parameters detected");
6030 }
6031 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00006032 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chandler Carruth563d4a42007-08-04 01:56:21 +00006033 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6034 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
6035 (yyval.InstVal) = CI;
6036 delete (yyvsp[(6) - (8)].ValueRefList);
6037 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006038 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006039 ;}
6040 break;
6041
6042 case 300:
6043#line 2975 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6044 {
6045 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006046 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006047 ;}
6048 break;
6049
6050 case 301:
6051#line 2980 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6052 {
6053 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006054 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006055 ;}
6056 break;
6057
6058 case 302:
6059#line 2984 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6060 {
6061 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006062 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006063 ;}
6064 break;
6065
6066 case 303:
6067#line 2991 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6068 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006069 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006070 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6071 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6072 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006073 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006074 ;}
6075 break;
6076
6077 case 304:
6078#line 2998 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6079 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006080 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006081 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6082 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006083 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006084 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6085 delete (yyvsp[(2) - (6)].TypeVal);
6086 ;}
6087 break;
6088
6089 case 305:
6090#line 3006 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6091 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006092 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006093 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6094 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6095 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006096 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006097 ;}
6098 break;
6099
6100 case 306:
6101#line 3013 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6102 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006103 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006104 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6105 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006106 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006107 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6108 delete (yyvsp[(2) - (6)].TypeVal);
6109 ;}
6110 break;
6111
6112 case 307:
6113#line 3021 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6114 {
6115 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006116 GEN_ERROR("Trying to free nonpointer type " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00006117 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6118 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006119 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006120 ;}
6121 break;
6122
6123 case 308:
6124#line 3029 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6125 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006126 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006127 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6128 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006129 GEN_ERROR("Can't load from nonpointer type: " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00006130 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6131 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006132 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00006133 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6134 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006135 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006136 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6137 delete (yyvsp[(3) - (5)].TypeVal);
6138 ;}
6139 break;
6140
6141 case 309:
6142#line 3043 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6143 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006144 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006145 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6146 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006147 if (!PT)
6148 GEN_ERROR("Can't store to a nonpointer type: " +
Chandler Carruth563d4a42007-08-04 01:56:21 +00006149 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006150 const Type *ElTy = PT->getElementType();
Chandler Carruth563d4a42007-08-04 01:56:21 +00006151 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6152 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006153 "' into space of type '" + ElTy->getDescription() + "'");
6154
Chandler Carruth563d4a42007-08-04 01:56:21 +00006155 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006156 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006157 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6158 delete (yyvsp[(5) - (7)].TypeVal);
6159 ;}
6160 break;
6161
6162 case 310:
6163#line 3060 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
6164 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006165 if (!UpRefs.empty())
Chandler Carruth563d4a42007-08-04 01:56:21 +00006166 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6167 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006168 GEN_ERROR("getelementptr insn requires pointer operand");
6169
Chandler Carruth563d4a42007-08-04 01:56:21 +00006170 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size(), true))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006171 GEN_ERROR("Invalid getelementptr indices for type '" +
Chandler Carruth563d4a42007-08-04 01:56:21 +00006172 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6173 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006174 CHECK_FOR_ERROR
Chandler Carruth563d4a42007-08-04 01:56:21 +00006175 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size());
6176 delete (yyvsp[(2) - (4)].TypeVal);
6177 delete (yyvsp[(4) - (4)].ValueList);
6178 ;}
6179 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006180
Chandler Carruth563d4a42007-08-04 01:56:21 +00006181
6182/* Line 1267 of yacc.c. */
6183#line 6184 "llvmAsmParser.tab.c"
6184 default: break;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00006185 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00006186 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6187
6188 YYPOPSTACK (yylen);
6189 yylen = 0;
6190 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006191
6192 *++yyvsp = yyval;
6193
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006194
Chandler Carruth563d4a42007-08-04 01:56:21 +00006195 /* Now `shift' the result of the reduction. Determine what state
6196 that goes to, based on the state we popped back to and the rule
6197 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006198
6199 yyn = yyr1[yyn];
6200
Chandler Carruth563d4a42007-08-04 01:56:21 +00006201 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6202 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006203 yystate = yytable[yystate];
6204 else
Chandler Carruth563d4a42007-08-04 01:56:21 +00006205 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006206
6207 goto yynewstate;
6208
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006209
Chandler Carruth563d4a42007-08-04 01:56:21 +00006210/*------------------------------------.
6211| yyerrlab -- here on detecting error |
6212`------------------------------------*/
6213yyerrlab:
6214 /* If not already recovering from an error, report this error. */
6215 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006216 {
6217 ++yynerrs;
Chandler Carruth563d4a42007-08-04 01:56:21 +00006218#if ! YYERROR_VERBOSE
6219 yyerror (YY_("syntax error"));
6220#else
6221 {
6222 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6223 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6224 {
6225 YYSIZE_T yyalloc = 2 * yysize;
6226 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6227 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6228 if (yymsg != yymsgbuf)
6229 YYSTACK_FREE (yymsg);
6230 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6231 if (yymsg)
6232 yymsg_alloc = yyalloc;
6233 else
6234 {
6235 yymsg = yymsgbuf;
6236 yymsg_alloc = sizeof yymsgbuf;
6237 }
6238 }
Dale Johannesenf325d9f2007-08-03 01:03:46 +00006239
Chandler Carruth563d4a42007-08-04 01:56:21 +00006240 if (0 < yysize && yysize <= yymsg_alloc)
6241 {
6242 (void) yysyntax_error (yymsg, yystate, yychar);
6243 yyerror (yymsg);
6244 }
6245 else
6246 {
6247 yyerror (YY_("syntax error"));
6248 if (yysize != 0)
6249 goto yyexhaustedlab;
6250 }
6251 }
6252#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006253 }
6254
Chandler Carruth563d4a42007-08-04 01:56:21 +00006255
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006256
6257 if (yyerrstatus == 3)
6258 {
Chandler Carruth563d4a42007-08-04 01:56:21 +00006259 /* If just tried and failed to reuse look-ahead token after an
6260 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006261
Chandler Carruth563d4a42007-08-04 01:56:21 +00006262 if (yychar <= YYEOF)
6263 {
6264 /* Return failure if at end of input. */
6265 if (yychar == YYEOF)
6266 YYABORT;
6267 }
6268 else
6269 {
6270 yydestruct ("Error: discarding",
6271 yytoken, &yylval);
6272 yychar = YYEMPTY;
6273 }
6274 }
6275
6276 /* Else will try to reuse look-ahead token after shifting the error
6277 token. */
6278 goto yyerrlab1;
6279
6280
6281/*---------------------------------------------------.
6282| yyerrorlab -- error raised explicitly by YYERROR. |
6283`---------------------------------------------------*/
6284yyerrorlab:
6285
6286 /* Pacify compilers like GCC when the user code never invokes
6287 YYERROR and the label yyerrorlab therefore never appears in user
6288 code. */
6289 if (/*CONSTCOND*/ 0)
6290 goto yyerrorlab;
6291
6292 /* Do not reclaim the symbols of the rule which action triggered
6293 this YYERROR. */
6294 YYPOPSTACK (yylen);
6295 yylen = 0;
6296 YY_STACK_PRINT (yyss, yyssp);
6297 yystate = *yyssp;
6298 goto yyerrlab1;
6299
6300
6301/*-------------------------------------------------------------.
6302| yyerrlab1 -- common code for both syntax error and YYERROR. |
6303`-------------------------------------------------------------*/
6304yyerrlab1:
6305 yyerrstatus = 3; /* Each real token shifted decrements this. */
6306
6307 for (;;)
6308 {
6309 yyn = yypact[yystate];
6310 if (yyn != YYPACT_NINF)
6311 {
6312 yyn += YYTERROR;
6313 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6314 {
6315 yyn = yytable[yyn];
6316 if (0 < yyn)
6317 break;
6318 }
6319 }
6320
6321 /* Pop the current state because it cannot handle the error token. */
6322 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006323 YYABORT;
6324
Dale Johannesenf325d9f2007-08-03 01:03:46 +00006325
Chandler Carruth563d4a42007-08-04 01:56:21 +00006326 yydestruct ("Error: popping",
6327 yystos[yystate], yyvsp);
6328 YYPOPSTACK (1);
6329 yystate = *yyssp;
6330 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006331 }
6332
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006333 if (yyn == YYFINAL)
6334 YYACCEPT;
6335
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006336 *++yyvsp = yylval;
Chandler Carruth563d4a42007-08-04 01:56:21 +00006337
6338
6339 /* Shift the error token. */
6340 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006341
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006342 yystate = yyn;
6343 goto yynewstate;
6344
Reid Spenceraa8ae282007-07-31 03:50:36 +00006345
Chandler Carruth563d4a42007-08-04 01:56:21 +00006346/*-------------------------------------.
6347| yyacceptlab -- YYACCEPT comes here. |
6348`-------------------------------------*/
6349yyacceptlab:
6350 yyresult = 0;
6351 goto yyreturn;
6352
6353/*-----------------------------------.
6354| yyabortlab -- YYABORT comes here. |
6355`-----------------------------------*/
6356yyabortlab:
6357 yyresult = 1;
6358 goto yyreturn;
6359
6360#ifndef yyoverflow
6361/*-------------------------------------------------.
6362| yyexhaustedlab -- memory exhaustion comes here. |
6363`-------------------------------------------------*/
6364yyexhaustedlab:
6365 yyerror (YY_("memory exhausted"));
6366 yyresult = 2;
6367 /* Fall through. */
Reid Spenceraa8ae282007-07-31 03:50:36 +00006368#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00006369
6370yyreturn:
6371 if (yychar != YYEOF && yychar != YYEMPTY)
6372 yydestruct ("Cleanup: discarding lookahead",
6373 yytoken, &yylval);
6374 /* Do not reclaim the symbols of the rule which action triggered
6375 this YYABORT or YYACCEPT. */
6376 YYPOPSTACK (yylen);
6377 YY_STACK_PRINT (yyss, yyssp);
6378 while (yyssp != yyss)
6379 {
6380 yydestruct ("Cleanup: popping",
6381 yystos[*yyssp], yyvsp);
6382 YYPOPSTACK (1);
Dale Johannesenf325d9f2007-08-03 01:03:46 +00006383 }
Chandler Carruth563d4a42007-08-04 01:56:21 +00006384#ifndef yyoverflow
6385 if (yyss != yyssa)
6386 YYSTACK_FREE (yyss);
6387#endif
6388#if YYERROR_VERBOSE
6389 if (yymsg != yymsgbuf)
6390 YYSTACK_FREE (yymsg);
6391#endif
6392 /* Make sure YYID is used. */
6393 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006394}
Chandler Carruth563d4a42007-08-04 01:56:21 +00006395
6396
6397#line 3077 "/home/chandlerc/code/compilers/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006398
6399
6400// common code from the two 'RunVMAsmParser' functions
6401static Module* RunParser(Module * M) {
6402
6403 llvmAsmlineno = 1; // Reset the current line number...
6404 CurModule.CurrentModule = M;
6405#if YYDEBUG
6406 yydebug = Debug;
6407#endif
6408
6409 // Check to make sure the parser succeeded
6410 if (yyparse()) {
6411 if (ParserResult)
6412 delete ParserResult;
6413 return 0;
6414 }
6415
6416 // Emit an error if there are any unresolved types left.
6417 if (!CurModule.LateResolveTypes.empty()) {
6418 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6419 if (DID.Type == ValID::LocalName) {
6420 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6421 } else {
6422 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6423 }
6424 if (ParserResult)
6425 delete ParserResult;
6426 return 0;
6427 }
6428
6429 // Emit an error if there are any unresolved values left.
6430 if (!CurModule.LateResolveValues.empty()) {
6431 Value *V = CurModule.LateResolveValues.back();
6432 std::map<Value*, std::pair<ValID, int> >::iterator I =
6433 CurModule.PlaceHolderInfo.find(V);
6434
6435 if (I != CurModule.PlaceHolderInfo.end()) {
6436 ValID &DID = I->second.first;
6437 if (DID.Type == ValID::LocalName) {
6438 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6439 } else {
6440 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6441 }
6442 if (ParserResult)
6443 delete ParserResult;
6444 return 0;
6445 }
6446 }
6447
6448 // Check to make sure that parsing produced a result
6449 if (!ParserResult)
6450 return 0;
6451
6452 // Reset ParserResult variable while saving its value for the result.
6453 Module *Result = ParserResult;
6454 ParserResult = 0;
6455
6456 return Result;
6457}
6458
6459void llvm::GenerateError(const std::string &message, int LineNo) {
6460 if (LineNo == -1) LineNo = llvmAsmlineno;
6461 // TODO: column number in exception
6462 if (TheParseError)
6463 TheParseError->setError(CurFilename, message, LineNo);
6464 TriggerError = 1;
6465}
6466
6467int yyerror(const char *ErrorMsg) {
6468 std::string where
6469 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6470 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
6471 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6472 if (yychar != YYEMPTY && yychar != 0)
6473 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6474 "'";
6475 GenerateError(errMsg);
6476 return 0;
6477}
Chandler Carruth563d4a42007-08-04 01:56:21 +00006478