blob: a3e123590f2f49ddd7113270c37d9157ca94fe70 [file] [log] [blame]
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Anton Korobeynikov66e28652007-11-14 09:53:48 +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
Anton Korobeynikov66e28652007-11-14 09:53:48 +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
Anton Korobeynikov66e28652007-11-14 09:53:48 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Anton Korobeynikov66e28652007-11-14 09:53:48 +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
Anton Korobeynikov66e28652007-11-14 09:53:48 +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 CONST = 398,
218 PURE = 399,
219 DEFAULT = 400,
220 HIDDEN = 401,
221 PROTECTED = 402
222 };
223#endif
224/* Tokens. */
225#define ESINT64VAL 258
226#define EUINT64VAL 259
227#define ESAPINTVAL 260
228#define EUAPINTVAL 261
229#define LOCALVAL_ID 262
230#define GLOBALVAL_ID 263
231#define FPVAL 264
232#define VOID 265
233#define INTTYPE 266
234#define FLOAT 267
235#define DOUBLE 268
236#define X86_FP80 269
237#define FP128 270
238#define PPC_FP128 271
239#define LABEL 272
240#define TYPE 273
241#define LOCALVAR 274
242#define GLOBALVAR 275
243#define LABELSTR 276
244#define STRINGCONSTANT 277
245#define ATSTRINGCONSTANT 278
246#define PCTSTRINGCONSTANT 279
247#define ZEROINITIALIZER 280
248#define TRUETOK 281
249#define FALSETOK 282
250#define BEGINTOK 283
251#define ENDTOK 284
252#define DECLARE 285
253#define DEFINE 286
254#define GLOBAL 287
255#define CONSTANT 288
256#define SECTION 289
257#define ALIAS 290
258#define VOLATILE 291
259#define THREAD_LOCAL 292
260#define TO 293
261#define DOTDOTDOT 294
262#define NULL_TOK 295
263#define UNDEF 296
264#define INTERNAL 297
265#define LINKONCE 298
266#define WEAK 299
267#define APPENDING 300
268#define DLLIMPORT 301
269#define DLLEXPORT 302
270#define EXTERN_WEAK 303
271#define OPAQUE 304
272#define EXTERNAL 305
273#define TARGET 306
274#define TRIPLE 307
275#define ALIGN 308
276#define DEPLIBS 309
277#define CALL 310
278#define TAIL 311
279#define ASM_TOK 312
280#define MODULE 313
281#define SIDEEFFECT 314
282#define CC_TOK 315
283#define CCC_TOK 316
284#define FASTCC_TOK 317
285#define COLDCC_TOK 318
286#define X86_STDCALLCC_TOK 319
287#define X86_FASTCALLCC_TOK 320
288#define DATALAYOUT 321
289#define RET 322
290#define BR 323
291#define SWITCH 324
292#define INVOKE 325
293#define UNWIND 326
294#define UNREACHABLE 327
295#define ADD 328
296#define SUB 329
297#define MUL 330
298#define UDIV 331
299#define SDIV 332
300#define FDIV 333
301#define UREM 334
302#define SREM 335
303#define FREM 336
304#define AND 337
305#define OR 338
306#define XOR 339
307#define SHL 340
308#define LSHR 341
309#define ASHR 342
310#define ICMP 343
311#define FCMP 344
312#define EQ 345
313#define NE 346
314#define SLT 347
315#define SGT 348
316#define SLE 349
317#define SGE 350
318#define ULT 351
319#define UGT 352
320#define ULE 353
321#define UGE 354
322#define OEQ 355
323#define ONE 356
324#define OLT 357
325#define OGT 358
326#define OLE 359
327#define OGE 360
328#define ORD 361
329#define UNO 362
330#define UEQ 363
331#define UNE 364
332#define MALLOC 365
333#define ALLOCA 366
334#define FREE 367
335#define LOAD 368
336#define STORE 369
337#define GETELEMENTPTR 370
338#define TRUNC 371
339#define ZEXT 372
340#define SEXT 373
341#define FPTRUNC 374
342#define FPEXT 375
343#define BITCAST 376
344#define UITOFP 377
345#define SITOFP 378
346#define FPTOUI 379
347#define FPTOSI 380
348#define INTTOPTR 381
349#define PTRTOINT 382
350#define PHI_TOK 383
351#define SELECT 384
352#define VAARG 385
353#define EXTRACTELEMENT 386
354#define INSERTELEMENT 387
355#define SHUFFLEVECTOR 388
356#define SIGNEXT 389
357#define ZEROEXT 390
358#define NORETURN 391
359#define INREG 392
360#define SRET 393
361#define NOUNWIND 394
362#define NOALIAS 395
363#define BYVAL 396
364#define NEST 397
365#define CONST 398
366#define PURE 399
367#define DEFAULT 400
368#define HIDDEN 401
369#define PROTECTED 402
370
371
372
373
374/* Copy the first part of user declarations. */
375#line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
377#include "ParserInternals.h"
378#include "llvm/CallingConv.h"
379#include "llvm/InlineAsm.h"
380#include "llvm/Instructions.h"
381#include "llvm/Module.h"
382#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000383#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384#include "llvm/Support/GetElementPtrTypeIterator.h"
385#include "llvm/Support/CommandLine.h"
386#include "llvm/ADT/SmallVector.h"
387#include "llvm/ADT/STLExtras.h"
388#include "llvm/Support/MathExtras.h"
389#include "llvm/Support/Streams.h"
390#include <algorithm>
391#include <list>
392#include <map>
393#include <utility>
394#ifndef NDEBUG
395#define YYDEBUG 1
396#endif
397
398// The following is a gross hack. In order to rid the libAsmParser library of
399// exceptions, we have to have a way of getting the yyparse function to go into
400// an error situation. So, whenever we want an error to occur, the GenerateError
401// function (see bottom of file) sets TriggerError. Then, at the end of each
402// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
403// (a goto) to put YACC in error state. Furthermore, several calls to
404// GenerateError are made from inside productions and they must simulate the
405// previous exception behavior by exiting the production immediately. We have
406// replaced these with the GEN_ERROR macro which calls GeneratError and then
407// immediately invokes YYERROR. This would be so much cleaner if it was a
408// recursive descent parser.
409static bool TriggerError = false;
410#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
411#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
412
413int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
414int yylex(); // declaration" of xxx warnings.
415int yyparse();
416
417namespace llvm {
418 std::string CurFilename;
419#if YYDEBUG
420static cl::opt<bool>
421Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
422 cl::Hidden, cl::init(false));
423#endif
424}
425using namespace llvm;
426
427static Module *ParserResult;
428
429// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
430// relating to upreferences in the input stream.
431//
432//#define DEBUG_UPREFS 1
433#ifdef DEBUG_UPREFS
434#define UR_OUT(X) cerr << X
435#else
436#define UR_OUT(X)
437#endif
438
439#define YYERROR_VERBOSE 1
440
441static GlobalVariable *CurGV;
442
443
444// This contains info used when building the body of a function. It is
445// destroyed when the function is completed.
446//
447typedef std::vector<Value *> ValueList; // Numbered defs
448
449static void
450ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
451
452static struct PerModuleInfo {
453 Module *CurrentModule;
454 ValueList Values; // Module level numbered definitions
455 ValueList LateResolveValues;
456 std::vector<PATypeHolder> Types;
457 std::map<ValID, PATypeHolder> LateResolveTypes;
458
459 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
460 /// how they were referenced and on which line of the input they came from so
461 /// that we can resolve them later and print error messages as appropriate.
462 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
463
464 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
465 // references to global values. Global values may be referenced before they
466 // are defined, and if so, the temporary object that they represent is held
467 // here. This is used for forward references of GlobalValues.
468 //
469 typedef std::map<std::pair<const PointerType *,
470 ValID>, GlobalValue*> GlobalRefsType;
471 GlobalRefsType GlobalRefs;
472
473 void ModuleDone() {
474 // If we could not resolve some functions at function compilation time
475 // (calls to functions before they are defined), resolve them now... Types
476 // are resolved when the constant pool has been completely parsed.
477 //
478 ResolveDefinitions(LateResolveValues);
479 if (TriggerError)
480 return;
481
482 // Check to make sure that all global value forward references have been
483 // resolved!
484 //
485 if (!GlobalRefs.empty()) {
486 std::string UndefinedReferences = "Unresolved global references exist:\n";
487
488 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
489 I != E; ++I) {
490 UndefinedReferences += " " + I->first.first->getDescription() + " " +
491 I->first.second.getName() + "\n";
492 }
493 GenerateError(UndefinedReferences);
494 return;
495 }
496
Chandler Carruth563d4a42007-08-04 01:56:21 +0000497 // Look for intrinsic functions and CallInst that need to be upgraded
498 for (Module::iterator FI = CurrentModule->begin(),
499 FE = CurrentModule->end(); FI != FE; )
500 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
501
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 Values.clear(); // Clear out function local definitions
503 Types.clear();
504 CurrentModule = 0;
505 }
506
507 // GetForwardRefForGlobal - Check to see if there is a forward reference
508 // for this global. If so, remove it from the GlobalRefs map and return it.
509 // If not, just return null.
510 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
511 // Check to see if there is a forward reference to this global variable...
512 // if there is, eliminate it and patch the reference to use the new def'n.
513 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
514 GlobalValue *Ret = 0;
515 if (I != GlobalRefs.end()) {
516 Ret = I->second;
517 GlobalRefs.erase(I);
518 }
519 return Ret;
520 }
521
522 bool TypeIsUnresolved(PATypeHolder* PATy) {
523 // If it isn't abstract, its resolved
524 const Type* Ty = PATy->get();
525 if (!Ty->isAbstract())
526 return false;
527 // Traverse the type looking for abstract types. If it isn't abstract then
528 // we don't need to traverse that leg of the type.
529 std::vector<const Type*> WorkList, SeenList;
530 WorkList.push_back(Ty);
531 while (!WorkList.empty()) {
532 const Type* Ty = WorkList.back();
533 SeenList.push_back(Ty);
534 WorkList.pop_back();
535 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
536 // Check to see if this is an unresolved type
537 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
538 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
539 for ( ; I != E; ++I) {
540 if (I->second.get() == OpTy)
541 return true;
542 }
543 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
544 const Type* TheTy = SeqTy->getElementType();
545 if (TheTy->isAbstract() && TheTy != Ty) {
546 std::vector<const Type*>::iterator I = SeenList.begin(),
547 E = SeenList.end();
548 for ( ; I != E; ++I)
549 if (*I == TheTy)
550 break;
551 if (I == E)
552 WorkList.push_back(TheTy);
553 }
554 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
555 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
556 const Type* TheTy = StrTy->getElementType(i);
557 if (TheTy->isAbstract() && TheTy != Ty) {
558 std::vector<const Type*>::iterator I = SeenList.begin(),
559 E = SeenList.end();
560 for ( ; I != E; ++I)
561 if (*I == TheTy)
562 break;
563 if (I == E)
564 WorkList.push_back(TheTy);
565 }
566 }
567 }
568 }
569 return false;
570 }
571} CurModule;
572
573static struct PerFunctionInfo {
574 Function *CurrentFunction; // Pointer to current function being created
575
576 ValueList Values; // Keep track of #'d definitions
577 unsigned NextValNum;
578 ValueList LateResolveValues;
579 bool isDeclare; // Is this function a forward declararation?
580 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
581 GlobalValue::VisibilityTypes Visibility;
582
583 /// BBForwardRefs - When we see forward references to basic blocks, keep
584 /// track of them here.
585 std::map<ValID, BasicBlock*> BBForwardRefs;
586
587 inline PerFunctionInfo() {
588 CurrentFunction = 0;
589 isDeclare = false;
590 Linkage = GlobalValue::ExternalLinkage;
591 Visibility = GlobalValue::DefaultVisibility;
592 }
593
594 inline void FunctionStart(Function *M) {
595 CurrentFunction = M;
596 NextValNum = 0;
597 }
598
599 void FunctionDone() {
600 // Any forward referenced blocks left?
601 if (!BBForwardRefs.empty()) {
602 GenerateError("Undefined reference to label " +
603 BBForwardRefs.begin()->second->getName());
604 return;
605 }
606
607 // Resolve all forward references now.
608 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
609
610 Values.clear(); // Clear out function local definitions
611 BBForwardRefs.clear();
612 CurrentFunction = 0;
613 isDeclare = false;
614 Linkage = GlobalValue::ExternalLinkage;
615 Visibility = GlobalValue::DefaultVisibility;
616 }
617} CurFun; // Info for the current function...
618
619static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
620
621
622//===----------------------------------------------------------------------===//
623// Code to handle definitions of all the types
624//===----------------------------------------------------------------------===//
625
626static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
627 // Things that have names or are void typed don't get slot numbers
628 if (V->hasName() || (V->getType() == Type::VoidTy))
629 return;
630
631 // In the case of function values, we have to allow for the forward reference
632 // of basic blocks, which are included in the numbering. Consequently, we keep
633 // track of the next insertion location with NextValNum. When a BB gets
634 // inserted, it could change the size of the CurFun.Values vector.
635 if (&ValueTab == &CurFun.Values) {
636 if (ValueTab.size() <= CurFun.NextValNum)
637 ValueTab.resize(CurFun.NextValNum+1);
638 ValueTab[CurFun.NextValNum++] = V;
639 return;
640 }
641 // For all other lists, its okay to just tack it on the back of the vector.
642 ValueTab.push_back(V);
643}
644
645static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
646 switch (D.Type) {
647 case ValID::LocalID: // Is it a numbered definition?
648 // Module constants occupy the lowest numbered slots...
649 if (D.Num < CurModule.Types.size())
650 return CurModule.Types[D.Num];
651 break;
652 case ValID::LocalName: // Is it a named definition?
653 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
654 D.destroy(); // Free old strdup'd memory...
655 return N;
656 }
657 break;
658 default:
659 GenerateError("Internal parser error: Invalid symbol type reference");
660 return 0;
661 }
662
663 // If we reached here, we referenced either a symbol that we don't know about
664 // or an id number that hasn't been read yet. We may be referencing something
665 // forward, so just create an entry to be resolved later and get to it...
666 //
667 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
668
669
670 if (inFunctionScope()) {
671 if (D.Type == ValID::LocalName) {
672 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
673 return 0;
674 } else {
675 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
676 return 0;
677 }
678 }
679
680 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
681 if (I != CurModule.LateResolveTypes.end())
682 return I->second;
683
684 Type *Typ = OpaqueType::get();
685 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
686 return Typ;
687 }
688
689// getExistingVal - Look up the value specified by the provided type and
690// the provided ValID. If the value exists and has already been defined, return
691// it. Otherwise return null.
692//
693static Value *getExistingVal(const Type *Ty, const ValID &D) {
694 if (isa<FunctionType>(Ty)) {
695 GenerateError("Functions are not values and "
696 "must be referenced as pointers");
697 return 0;
698 }
699
700 switch (D.Type) {
701 case ValID::LocalID: { // Is it a numbered definition?
702 // Check that the number is within bounds.
703 if (D.Num >= CurFun.Values.size())
704 return 0;
705 Value *Result = CurFun.Values[D.Num];
706 if (Ty != Result->getType()) {
707 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
708 Result->getType()->getDescription() + "' does not match "
709 "expected type, '" + Ty->getDescription() + "'");
710 return 0;
711 }
712 return Result;
713 }
714 case ValID::GlobalID: { // Is it a numbered definition?
715 if (D.Num >= CurModule.Values.size())
716 return 0;
717 Value *Result = CurModule.Values[D.Num];
718 if (Ty != Result->getType()) {
719 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
720 Result->getType()->getDescription() + "' does not match "
721 "expected type, '" + Ty->getDescription() + "'");
722 return 0;
723 }
724 return Result;
725 }
726
727 case ValID::LocalName: { // Is it a named definition?
728 if (!inFunctionScope())
729 return 0;
730 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
731 Value *N = SymTab.lookup(D.getName());
732 if (N == 0)
733 return 0;
734 if (N->getType() != Ty)
735 return 0;
736
737 D.destroy(); // Free old strdup'd memory...
738 return N;
739 }
740 case ValID::GlobalName: { // Is it a named definition?
741 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
742 Value *N = SymTab.lookup(D.getName());
743 if (N == 0)
744 return 0;
745 if (N->getType() != Ty)
746 return 0;
747
748 D.destroy(); // Free old strdup'd memory...
749 return N;
750 }
751
752 // Check to make sure that "Ty" is an integral type, and that our
753 // value will fit into the specified type...
754 case ValID::ConstSIntVal: // Is it a constant pool reference??
755 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
756 GenerateError("Signed integral constant '" +
757 itostr(D.ConstPool64) + "' is invalid for type '" +
758 Ty->getDescription() + "'");
759 return 0;
760 }
761 return ConstantInt::get(Ty, D.ConstPool64, true);
762
763 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
764 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
765 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
766 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
767 "' is invalid or out of range");
768 return 0;
769 } else { // This is really a signed reference. Transmogrify.
770 return ConstantInt::get(Ty, D.ConstPool64, true);
771 }
772 } else {
773 return ConstantInt::get(Ty, D.UConstPool64);
774 }
775
776 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesen3afee192007-09-07 21:07:57 +0000777 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 GenerateError("FP constant invalid for type");
779 return 0;
780 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000781 // Lexer has no type info, so builds all float and double FP constants
782 // as double. Fix this here. Long double does not need this.
783 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
784 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000785 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
786 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787
788 case ValID::ConstNullVal: // Is it a null value?
789 if (!isa<PointerType>(Ty)) {
790 GenerateError("Cannot create a a non pointer null");
791 return 0;
792 }
793 return ConstantPointerNull::get(cast<PointerType>(Ty));
794
795 case ValID::ConstUndefVal: // Is it an undef value?
796 return UndefValue::get(Ty);
797
798 case ValID::ConstZeroVal: // Is it a zero value?
799 return Constant::getNullValue(Ty);
800
801 case ValID::ConstantVal: // Fully resolved constant?
802 if (D.ConstantValue->getType() != Ty) {
803 GenerateError("Constant expression type different from required type");
804 return 0;
805 }
806 return D.ConstantValue;
807
808 case ValID::InlineAsmVal: { // Inline asm expression
809 const PointerType *PTy = dyn_cast<PointerType>(Ty);
810 const FunctionType *FTy =
811 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
812 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
813 GenerateError("Invalid type for asm constraint string");
814 return 0;
815 }
816 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
817 D.IAD->HasSideEffects);
818 D.destroy(); // Free InlineAsmDescriptor.
819 return IA;
820 }
821 default:
822 assert(0 && "Unhandled case!");
823 return 0;
824 } // End of switch
825
826 assert(0 && "Unhandled case!");
827 return 0;
828}
829
830// getVal - This function is identical to getExistingVal, except that if a
831// value is not already defined, it "improvises" by creating a placeholder var
832// that looks and acts just like the requested variable. When the value is
833// defined later, all uses of the placeholder variable are replaced with the
834// real thing.
835//
836static Value *getVal(const Type *Ty, const ValID &ID) {
837 if (Ty == Type::LabelTy) {
838 GenerateError("Cannot use a basic block here");
839 return 0;
840 }
841
842 // See if the value has already been defined.
843 Value *V = getExistingVal(Ty, ID);
844 if (V) return V;
845 if (TriggerError) return 0;
846
847 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
848 GenerateError("Invalid use of a composite type");
849 return 0;
850 }
851
852 // If we reached here, we referenced either a symbol that we don't know about
853 // or an id number that hasn't been read yet. We may be referencing something
854 // forward, so just create an entry to be resolved later and get to it...
855 //
856 switch (ID.Type) {
857 case ValID::GlobalName:
858 case ValID::GlobalID: {
859 const PointerType *PTy = dyn_cast<PointerType>(Ty);
860 if (!PTy) {
861 GenerateError("Invalid type for reference to global" );
862 return 0;
863 }
864 const Type* ElTy = PTy->getElementType();
865 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
866 V = new Function(FTy, GlobalValue::ExternalLinkage);
867 else
868 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
869 break;
870 }
871 default:
872 V = new Argument(Ty);
873 }
874
875 // Remember where this forward reference came from. FIXME, shouldn't we try
876 // to recycle these things??
877 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
878 llvmAsmlineno)));
879
880 if (inFunctionScope())
881 InsertValue(V, CurFun.LateResolveValues);
882 else
883 InsertValue(V, CurModule.LateResolveValues);
884 return V;
885}
886
887/// defineBBVal - This is a definition of a new basic block with the specified
888/// identifier which must be the same as CurFun.NextValNum, if its numeric.
889static BasicBlock *defineBBVal(const ValID &ID) {
890 assert(inFunctionScope() && "Can't get basic block at global scope!");
891
892 BasicBlock *BB = 0;
893
894 // First, see if this was forward referenced
895
896 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
897 if (BBI != CurFun.BBForwardRefs.end()) {
898 BB = BBI->second;
899 // The forward declaration could have been inserted anywhere in the
900 // function: insert it into the correct place now.
901 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
902 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
903
904 // We're about to erase the entry, save the key so we can clean it up.
905 ValID Tmp = BBI->first;
906
907 // Erase the forward ref from the map as its no longer "forward"
908 CurFun.BBForwardRefs.erase(ID);
909
910 // The key has been removed from the map but so we don't want to leave
911 // strdup'd memory around so destroy it too.
912 Tmp.destroy();
913
914 // If its a numbered definition, bump the number and set the BB value.
915 if (ID.Type == ValID::LocalID) {
916 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
917 InsertValue(BB);
918 }
919
920 ID.destroy();
921 return BB;
922 }
923
924 // We haven't seen this BB before and its first mention is a definition.
925 // Just create it and return it.
926 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
927 BB = new BasicBlock(Name, CurFun.CurrentFunction);
928 if (ID.Type == ValID::LocalID) {
929 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
930 InsertValue(BB);
931 }
932
933 ID.destroy(); // Free strdup'd memory
934 return BB;
935}
936
937/// getBBVal - get an existing BB value or create a forward reference for it.
938///
939static BasicBlock *getBBVal(const ValID &ID) {
940 assert(inFunctionScope() && "Can't get basic block at global scope!");
941
942 BasicBlock *BB = 0;
943
944 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
945 if (BBI != CurFun.BBForwardRefs.end()) {
946 BB = BBI->second;
947 } if (ID.Type == ValID::LocalName) {
948 std::string Name = ID.getName();
949 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
950 if (N)
951 if (N->getType()->getTypeID() == Type::LabelTyID)
952 BB = cast<BasicBlock>(N);
953 else
954 GenerateError("Reference to label '" + Name + "' is actually of type '"+
955 N->getType()->getDescription() + "'");
956 } else if (ID.Type == ValID::LocalID) {
957 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
958 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
959 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
960 else
961 GenerateError("Reference to label '%" + utostr(ID.Num) +
962 "' is actually of type '"+
963 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
964 }
965 } else {
966 GenerateError("Illegal label reference " + ID.getName());
967 return 0;
968 }
969
970 // If its already been defined, return it now.
971 if (BB) {
972 ID.destroy(); // Free strdup'd memory.
973 return BB;
974 }
975
976 // Otherwise, this block has not been seen before, create it.
977 std::string Name;
978 if (ID.Type == ValID::LocalName)
979 Name = ID.getName();
980 BB = new BasicBlock(Name, CurFun.CurrentFunction);
981
982 // Insert it in the forward refs map.
983 CurFun.BBForwardRefs[ID] = BB;
984
985 return BB;
986}
987
988
989//===----------------------------------------------------------------------===//
990// Code to handle forward references in instructions
991//===----------------------------------------------------------------------===//
992//
993// This code handles the late binding needed with statements that reference
994// values not defined yet... for example, a forward branch, or the PHI node for
995// a loop body.
996//
997// This keeps a table (CurFun.LateResolveValues) of all such forward references
998// and back patchs after we are done.
999//
1000
1001// ResolveDefinitions - If we could not resolve some defs at parsing
1002// time (forward branches, phi functions for loops, etc...) resolve the
1003// defs now...
1004//
1005static void
1006ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1007 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1008 while (!LateResolvers.empty()) {
1009 Value *V = LateResolvers.back();
1010 LateResolvers.pop_back();
1011
1012 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1013 CurModule.PlaceHolderInfo.find(V);
1014 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1015
1016 ValID &DID = PHI->second.first;
1017
1018 Value *TheRealValue = getExistingVal(V->getType(), DID);
1019 if (TriggerError)
1020 return;
1021 if (TheRealValue) {
1022 V->replaceAllUsesWith(TheRealValue);
1023 delete V;
1024 CurModule.PlaceHolderInfo.erase(PHI);
1025 } else if (FutureLateResolvers) {
1026 // Functions have their unresolved items forwarded to the module late
1027 // resolver table
1028 InsertValue(V, *FutureLateResolvers);
1029 } else {
1030 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1031 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1032 "' of type '" + V->getType()->getDescription() + "'",
1033 PHI->second.second);
1034 return;
1035 } else {
1036 GenerateError("Reference to an invalid definition: #" +
1037 itostr(DID.Num) + " of type '" +
1038 V->getType()->getDescription() + "'",
1039 PHI->second.second);
1040 return;
1041 }
1042 }
1043 }
1044 LateResolvers.clear();
1045}
1046
1047// ResolveTypeTo - A brand new type was just declared. This means that (if
1048// name is not null) things referencing Name can be resolved. Otherwise, things
1049// refering to the number can be resolved. Do this now.
1050//
1051static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1052 ValID D;
1053 if (Name)
1054 D = ValID::createLocalName(*Name);
1055 else
1056 D = ValID::createLocalID(CurModule.Types.size());
1057
1058 std::map<ValID, PATypeHolder>::iterator I =
1059 CurModule.LateResolveTypes.find(D);
1060 if (I != CurModule.LateResolveTypes.end()) {
1061 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1062 CurModule.LateResolveTypes.erase(I);
1063 }
1064}
1065
1066// setValueName - Set the specified value to the name given. The name may be
1067// null potentially, in which case this is a noop. The string passed in is
1068// assumed to be a malloc'd string buffer, and is free'd by this function.
1069//
1070static void setValueName(Value *V, std::string *NameStr) {
1071 if (!NameStr) return;
1072 std::string Name(*NameStr); // Copy string
1073 delete NameStr; // Free old string
1074
1075 if (V->getType() == Type::VoidTy) {
1076 GenerateError("Can't assign name '" + Name+"' to value with void type");
1077 return;
1078 }
1079
1080 assert(inFunctionScope() && "Must be in function scope!");
1081 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1082 if (ST.lookup(Name)) {
1083 GenerateError("Redefinition of value '" + Name + "' of type '" +
1084 V->getType()->getDescription() + "'");
1085 return;
1086 }
1087
1088 // Set the name.
1089 V->setName(Name);
1090}
1091
1092/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1093/// this is a declaration, otherwise it is a definition.
1094static GlobalVariable *
1095ParseGlobalVariable(std::string *NameStr,
1096 GlobalValue::LinkageTypes Linkage,
1097 GlobalValue::VisibilityTypes Visibility,
1098 bool isConstantGlobal, const Type *Ty,
1099 Constant *Initializer, bool IsThreadLocal) {
1100 if (isa<FunctionType>(Ty)) {
1101 GenerateError("Cannot declare global vars of function type");
1102 return 0;
1103 }
1104
1105 const PointerType *PTy = PointerType::get(Ty);
1106
1107 std::string Name;
1108 if (NameStr) {
1109 Name = *NameStr; // Copy string
1110 delete NameStr; // Free old string
1111 }
1112
1113 // See if this global value was forward referenced. If so, recycle the
1114 // object.
1115 ValID ID;
1116 if (!Name.empty()) {
1117 ID = ValID::createGlobalName(Name);
1118 } else {
1119 ID = ValID::createGlobalID(CurModule.Values.size());
1120 }
1121
1122 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1123 // Move the global to the end of the list, from whereever it was
1124 // previously inserted.
1125 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1126 CurModule.CurrentModule->getGlobalList().remove(GV);
1127 CurModule.CurrentModule->getGlobalList().push_back(GV);
1128 GV->setInitializer(Initializer);
1129 GV->setLinkage(Linkage);
1130 GV->setVisibility(Visibility);
1131 GV->setConstant(isConstantGlobal);
1132 GV->setThreadLocal(IsThreadLocal);
1133 InsertValue(GV, CurModule.Values);
1134 return GV;
1135 }
1136
1137 // If this global has a name
1138 if (!Name.empty()) {
1139 // if the global we're parsing has an initializer (is a definition) and
1140 // has external linkage.
1141 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1142 // If there is already a global with external linkage with this name
1143 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1144 // If we allow this GVar to get created, it will be renamed in the
1145 // symbol table because it conflicts with an existing GVar. We can't
1146 // allow redefinition of GVars whose linking indicates that their name
1147 // must stay the same. Issue the error.
1148 GenerateError("Redefinition of global variable named '" + Name +
1149 "' of type '" + Ty->getDescription() + "'");
1150 return 0;
1151 }
1152 }
1153
1154 // Otherwise there is no existing GV to use, create one now.
1155 GlobalVariable *GV =
1156 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1157 CurModule.CurrentModule, IsThreadLocal);
1158 GV->setVisibility(Visibility);
1159 InsertValue(GV, CurModule.Values);
1160 return GV;
1161}
1162
1163// setTypeName - Set the specified type to the name given. The name may be
1164// null potentially, in which case this is a noop. The string passed in is
1165// assumed to be a malloc'd string buffer, and is freed by this function.
1166//
1167// This function returns true if the type has already been defined, but is
1168// allowed to be redefined in the specified context. If the name is a new name
1169// for the type plane, it is inserted and false is returned.
1170static bool setTypeName(const Type *T, std::string *NameStr) {
1171 assert(!inFunctionScope() && "Can't give types function-local names!");
1172 if (NameStr == 0) return false;
1173
1174 std::string Name(*NameStr); // Copy string
1175 delete NameStr; // Free old string
1176
1177 // We don't allow assigning names to void type
1178 if (T == Type::VoidTy) {
1179 GenerateError("Can't assign name '" + Name + "' to the void type");
1180 return false;
1181 }
1182
1183 // Set the type name, checking for conflicts as we do so.
1184 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1185
1186 if (AlreadyExists) { // Inserting a name that is already defined???
1187 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1188 assert(Existing && "Conflict but no matching type?!");
1189
1190 // There is only one case where this is allowed: when we are refining an
1191 // opaque type. In this case, Existing will be an opaque type.
1192 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1193 // We ARE replacing an opaque type!
1194 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1195 return true;
1196 }
1197
1198 // Otherwise, this is an attempt to redefine a type. That's okay if
1199 // the redefinition is identical to the original. This will be so if
1200 // Existing and T point to the same Type object. In this one case we
1201 // allow the equivalent redefinition.
1202 if (Existing == T) return true; // Yes, it's equal.
1203
1204 // Any other kind of (non-equivalent) redefinition is an error.
1205 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1206 T->getDescription() + "'");
1207 }
1208
1209 return false;
1210}
1211
1212//===----------------------------------------------------------------------===//
1213// Code for handling upreferences in type names...
1214//
1215
1216// TypeContains - Returns true if Ty directly contains E in it.
1217//
1218static bool TypeContains(const Type *Ty, const Type *E) {
1219 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1220 E) != Ty->subtype_end();
1221}
1222
1223namespace {
1224 struct UpRefRecord {
1225 // NestingLevel - The number of nesting levels that need to be popped before
1226 // this type is resolved.
1227 unsigned NestingLevel;
1228
1229 // LastContainedTy - This is the type at the current binding level for the
1230 // type. Every time we reduce the nesting level, this gets updated.
1231 const Type *LastContainedTy;
1232
1233 // UpRefTy - This is the actual opaque type that the upreference is
1234 // represented with.
1235 OpaqueType *UpRefTy;
1236
1237 UpRefRecord(unsigned NL, OpaqueType *URTy)
1238 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1239 };
1240}
1241
1242// UpRefs - A list of the outstanding upreferences that need to be resolved.
1243static std::vector<UpRefRecord> UpRefs;
1244
1245/// HandleUpRefs - Every time we finish a new layer of types, this function is
1246/// called. It loops through the UpRefs vector, which is a list of the
1247/// currently active types. For each type, if the up reference is contained in
1248/// the newly completed type, we decrement the level count. When the level
1249/// count reaches zero, the upreferenced type is the type that is passed in:
1250/// thus we can complete the cycle.
1251///
1252static PATypeHolder HandleUpRefs(const Type *ty) {
1253 // If Ty isn't abstract, or if there are no up-references in it, then there is
1254 // nothing to resolve here.
1255 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1256
1257 PATypeHolder Ty(ty);
1258 UR_OUT("Type '" << Ty->getDescription() <<
1259 "' newly formed. Resolving upreferences.\n" <<
1260 UpRefs.size() << " upreferences active!\n");
1261
1262 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1263 // to zero), we resolve them all together before we resolve them to Ty. At
1264 // the end of the loop, if there is anything to resolve to Ty, it will be in
1265 // this variable.
1266 OpaqueType *TypeToResolve = 0;
1267
1268 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1269 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1270 << UpRefs[i].second->getDescription() << ") = "
1271 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1272 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1273 // Decrement level of upreference
1274 unsigned Level = --UpRefs[i].NestingLevel;
1275 UpRefs[i].LastContainedTy = Ty;
1276 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1277 if (Level == 0) { // Upreference should be resolved!
1278 if (!TypeToResolve) {
1279 TypeToResolve = UpRefs[i].UpRefTy;
1280 } else {
1281 UR_OUT(" * Resolving upreference for "
1282 << UpRefs[i].second->getDescription() << "\n";
1283 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1284 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1285 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1286 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1287 }
1288 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1289 --i; // Do not skip the next element...
1290 }
1291 }
1292 }
1293
1294 if (TypeToResolve) {
1295 UR_OUT(" * Resolving upreference for "
1296 << UpRefs[i].second->getDescription() << "\n";
1297 std::string OldName = TypeToResolve->getDescription());
1298 TypeToResolve->refineAbstractTypeTo(Ty);
1299 }
1300
1301 return Ty;
1302}
1303
1304//===----------------------------------------------------------------------===//
1305// RunVMAsmParser - Define an interface to this parser
1306//===----------------------------------------------------------------------===//
1307//
1308static Module* RunParser(Module * M);
1309
1310Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1311 set_scan_file(F);
1312
1313 CurFilename = Filename;
1314 return RunParser(new Module(CurFilename));
1315}
1316
1317Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1318 set_scan_string(AsmString);
1319
1320 CurFilename = "from_memory";
1321 if (M == NULL) {
1322 return RunParser(new Module (CurFilename));
1323 } else {
1324 return RunParser(M);
1325 }
1326}
1327
1328
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001329
1330/* Enabling traces. */
1331#ifndef YYDEBUG
1332# define YYDEBUG 0
1333#endif
1334
1335/* Enabling verbose error messages. */
1336#ifdef YYERROR_VERBOSE
1337# undef YYERROR_VERBOSE
1338# define YYERROR_VERBOSE 1
1339#else
1340# define YYERROR_VERBOSE 0
1341#endif
1342
1343/* Enabling the token table. */
1344#ifndef YYTOKEN_TABLE
1345# define YYTOKEN_TABLE 0
1346#endif
1347
1348#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1349typedef union YYSTYPE
1350#line 968 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
1351{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 llvm::Module *ModuleVal;
1353 llvm::Function *FunctionVal;
1354 llvm::BasicBlock *BasicBlockVal;
1355 llvm::TerminatorInst *TermInstVal;
1356 llvm::Instruction *InstVal;
1357 llvm::Constant *ConstVal;
1358
1359 const llvm::Type *PrimType;
1360 std::list<llvm::PATypeHolder> *TypeList;
1361 llvm::PATypeHolder *TypeVal;
1362 llvm::Value *ValueVal;
1363 std::vector<llvm::Value*> *ValueList;
1364 llvm::ArgListType *ArgList;
1365 llvm::TypeWithAttrs TypeWithAttrs;
1366 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001367 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368
1369 // Represent the RHS of PHI node
1370 std::list<std::pair<llvm::Value*,
1371 llvm::BasicBlock*> > *PHIList;
1372 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1373 std::vector<llvm::Constant*> *ConstVector;
1374
1375 llvm::GlobalValue::LinkageTypes Linkage;
1376 llvm::GlobalValue::VisibilityTypes Visibility;
1377 uint16_t ParamAttrs;
1378 llvm::APInt *APIntVal;
1379 int64_t SInt64Val;
1380 uint64_t UInt64Val;
1381 int SIntVal;
1382 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001383 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 bool BoolVal;
1385
1386 std::string *StrVal; // This memory must be deleted
1387 llvm::ValID ValIDVal;
1388
1389 llvm::Instruction::BinaryOps BinaryOpVal;
1390 llvm::Instruction::TermOps TermOpVal;
1391 llvm::Instruction::MemoryOps MemOpVal;
1392 llvm::Instruction::CastOps CastOpVal;
1393 llvm::Instruction::OtherOps OtherOpVal;
1394 llvm::ICmpInst::Predicate IPredicate;
1395 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001396}
1397/* Line 187 of yacc.c. */
1398#line 1399 "llvmAsmParser.tab.c"
1399 YYSTYPE;
1400# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1401# define YYSTYPE_IS_DECLARED 1
1402# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403#endif
1404
1405
1406
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001407/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001410/* Line 216 of yacc.c. */
1411#line 1412 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001412
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001413#ifdef short
1414# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415#endif
1416
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001417#ifdef YYTYPE_UINT8
1418typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001420typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421#endif
1422
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001423#ifdef YYTYPE_INT8
1424typedef YYTYPE_INT8 yytype_int8;
1425#elif (defined __STDC__ || defined __C99__FUNC__ \
1426 || defined __cplusplus || defined _MSC_VER)
1427typedef signed char yytype_int8;
1428#else
1429typedef short int yytype_int8;
1430#endif
1431
1432#ifdef YYTYPE_UINT16
1433typedef YYTYPE_UINT16 yytype_uint16;
1434#else
1435typedef unsigned short int yytype_uint16;
1436#endif
1437
1438#ifdef YYTYPE_INT16
1439typedef YYTYPE_INT16 yytype_int16;
1440#else
1441typedef short int yytype_int16;
1442#endif
1443
1444#ifndef YYSIZE_T
1445# ifdef __SIZE_TYPE__
1446# define YYSIZE_T __SIZE_TYPE__
1447# elif defined size_t
1448# define YYSIZE_T size_t
1449# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1450 || defined __cplusplus || defined _MSC_VER)
1451# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1452# define YYSIZE_T size_t
1453# else
1454# define YYSIZE_T unsigned int
1455# endif
1456#endif
1457
1458#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1459
1460#ifndef YY_
1461# if YYENABLE_NLS
1462# if ENABLE_NLS
1463# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1464# define YY_(msgid) dgettext ("bison-runtime", msgid)
1465# endif
1466# endif
1467# ifndef YY_
1468# define YY_(msgid) msgid
1469# endif
1470#endif
1471
1472/* Suppress unused-variable warnings by "using" E. */
1473#if ! defined lint || defined __GNUC__
1474# define YYUSE(e) ((void) (e))
1475#else
1476# define YYUSE(e) /* empty */
1477#endif
1478
1479/* Identity function, used to suppress warnings about constant conditions. */
1480#ifndef lint
1481# define YYID(n) (n)
1482#else
1483#if (defined __STDC__ || defined __C99__FUNC__ \
1484 || defined __cplusplus || defined _MSC_VER)
1485static int
1486YYID (int i)
1487#else
1488static int
1489YYID (i)
1490 int i;
1491#endif
1492{
1493 return i;
1494}
1495#endif
1496
1497#if ! defined yyoverflow || YYERROR_VERBOSE
1498
1499/* The parser invokes alloca or malloc; define the necessary symbols. */
1500
1501# ifdef YYSTACK_USE_ALLOCA
1502# if YYSTACK_USE_ALLOCA
1503# ifdef __GNUC__
1504# define YYSTACK_ALLOC __builtin_alloca
1505# elif defined __BUILTIN_VA_ARG_INCR
1506# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1507# elif defined _AIX
1508# define YYSTACK_ALLOC __alloca
1509# elif defined _MSC_VER
1510# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1511# define alloca _alloca
1512# else
1513# define YYSTACK_ALLOC alloca
1514# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1515 || defined __cplusplus || defined _MSC_VER)
1516# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1517# ifndef _STDLIB_H
1518# define _STDLIB_H 1
1519# endif
1520# endif
1521# endif
1522# endif
1523# endif
1524
1525# ifdef YYSTACK_ALLOC
1526 /* Pacify GCC's `empty if-body' warning. */
1527# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1528# ifndef YYSTACK_ALLOC_MAXIMUM
1529 /* The OS might guarantee only one guard page at the bottom of the stack,
1530 and a page size can be as small as 4096 bytes. So we cannot safely
1531 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1532 to allow for a few compiler-allocated temporary stack slots. */
1533# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1534# endif
1535# else
1536# define YYSTACK_ALLOC YYMALLOC
1537# define YYSTACK_FREE YYFREE
1538# ifndef YYSTACK_ALLOC_MAXIMUM
1539# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1540# endif
1541# if (defined __cplusplus && ! defined _STDLIB_H \
1542 && ! ((defined YYMALLOC || defined malloc) \
1543 && (defined YYFREE || defined free)))
1544# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1545# ifndef _STDLIB_H
1546# define _STDLIB_H 1
1547# endif
1548# endif
1549# ifndef YYMALLOC
1550# define YYMALLOC malloc
1551# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1552 || defined __cplusplus || defined _MSC_VER)
1553void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1554# endif
1555# endif
1556# ifndef YYFREE
1557# define YYFREE free
1558# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1559 || defined __cplusplus || defined _MSC_VER)
1560void free (void *); /* INFRINGES ON USER NAME SPACE */
1561# endif
1562# endif
1563# endif
1564#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1565
1566
1567#if (! defined yyoverflow \
1568 && (! defined __cplusplus \
1569 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1570
1571/* A type that is properly aligned for any stack member. */
1572union yyalloc
1573{
1574 yytype_int16 yyss;
1575 YYSTYPE yyvs;
1576 };
1577
1578/* The size of the maximum gap between one aligned stack and the next. */
1579# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1580
1581/* The size of an array large to enough to hold all stacks, each with
1582 N elements. */
1583# define YYSTACK_BYTES(N) \
1584 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1585 + YYSTACK_GAP_MAXIMUM)
1586
1587/* Copy COUNT objects from FROM to TO. The source and destination do
1588 not overlap. */
1589# ifndef YYCOPY
1590# if defined __GNUC__ && 1 < __GNUC__
1591# define YYCOPY(To, From, Count) \
1592 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1593# else
1594# define YYCOPY(To, From, Count) \
1595 do \
1596 { \
1597 YYSIZE_T yyi; \
1598 for (yyi = 0; yyi < (Count); yyi++) \
1599 (To)[yyi] = (From)[yyi]; \
1600 } \
1601 while (YYID (0))
1602# endif
1603# endif
1604
1605/* Relocate STACK from its old location to the new one. The
1606 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1607 elements in the stack, and YYPTR gives the new location of the
1608 stack. Advance YYPTR to a properly aligned location for the next
1609 stack. */
1610# define YYSTACK_RELOCATE(Stack) \
1611 do \
1612 { \
1613 YYSIZE_T yynewbytes; \
1614 YYCOPY (&yyptr->Stack, Stack, yysize); \
1615 Stack = &yyptr->Stack; \
1616 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1617 yyptr += yynewbytes / sizeof (*yyptr); \
1618 } \
1619 while (YYID (0))
1620
1621#endif
1622
1623/* YYFINAL -- State number of the termination state. */
1624#define YYFINAL 43
1625/* YYLAST -- Last index in YYTABLE. */
1626#define YYLAST 1754
1627
1628/* YYNTOKENS -- Number of terminals. */
1629#define YYNTOKENS 162
1630/* YYNNTS -- Number of nonterminals. */
1631#define YYNNTS 82
1632/* YYNRULES -- Number of rules. */
1633#define YYNRULES 314
1634/* YYNRULES -- Number of states. */
1635#define YYNSTATES 602
1636
1637/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1638#define YYUNDEFTOK 2
1639#define YYMAXUTOK 402
1640
1641#define YYTRANSLATE(YYX) \
1642 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1643
1644/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1645static const yytype_uint8 yytranslate[] =
1646{
1647 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1651 152, 153, 150, 2, 149, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 157, 148, 158, 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, 154, 151, 156, 2, 2, 2, 2, 2, 161,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 155, 2, 2, 159, 2, 160, 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, 2, 2, 2, 2,
1664 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1665 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1666 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1667 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1668 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1669 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1670 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1671 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1672 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1673 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1674 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1675 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1676 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1677 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1678 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1679 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1680 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1681 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1682 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1683 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1684 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1685 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1686 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1687 145, 146, 147
1688};
1689
1690#if YYDEBUG
1691/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1692 YYRHS. */
1693static const yytype_uint16 yyprhs[] =
1694{
1695 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1696 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1697 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1698 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1699 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1700 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1701 119, 121, 123, 125, 127, 129, 130, 133, 134, 136,
1702 138, 140, 141, 144, 146, 148, 150, 152, 154, 156,
1703 158, 160, 161, 163, 165, 167, 168, 170, 172, 173,
1704 175, 177, 179, 181, 182, 184, 186, 187, 189, 191,
1705 193, 195, 197, 200, 202, 204, 206, 208, 210, 212,
1706 214, 216, 218, 219, 222, 224, 226, 228, 230, 232,
1707 234, 235, 238, 239, 242, 243, 247, 250, 251, 253,
1708 254, 258, 260, 263, 265, 267, 269, 271, 273, 275,
1709 277, 279, 281, 284, 286, 289, 295, 301, 307, 313,
1710 317, 320, 326, 331, 334, 336, 338, 340, 344, 346,
1711 350, 352, 353, 355, 359, 364, 368, 372, 377, 382,
1712 386, 393, 399, 402, 405, 408, 411, 414, 417, 420,
1713 423, 426, 429, 432, 435, 442, 448, 457, 464, 471,
1714 479, 487, 494, 503, 512, 516, 518, 520, 522, 524,
1715 525, 528, 535, 537, 538, 540, 543, 544, 548, 549,
1716 553, 557, 561, 565, 566, 574, 575, 584, 585, 594,
1717 600, 603, 607, 609, 613, 617, 621, 625, 627, 628,
1718 634, 638, 640, 644, 646, 647, 657, 659, 661, 666,
1719 668, 670, 673, 677, 678, 680, 682, 684, 686, 688,
1720 690, 692, 694, 696, 700, 702, 708, 710, 712, 714,
1721 716, 718, 720, 723, 726, 729, 733, 736, 737, 739,
1722 742, 745, 749, 759, 769, 778, 793, 795, 797, 804,
1723 810, 813, 820, 828, 832, 836, 842, 848, 849, 850,
1724 854, 857, 859, 865, 871, 878, 885, 890, 897, 902,
1725 907, 914, 921, 924, 933, 935, 937, 938, 942, 949,
1726 953, 960, 963, 969, 977
1727};
1728
1729/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1730static const yytype_int16 yyrhs[] =
1731{
1732 206, 0, -1, 73, -1, 74, -1, 75, -1, 76,
1733 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1734 -1, 85, -1, 86, -1, 87, -1, 82, -1, 83,
1735 -1, 84, -1, 116, -1, 117, -1, 118, -1, 119,
1736 -1, 120, -1, 121, -1, 122, -1, 123, -1, 124,
1737 -1, 125, -1, 126, -1, 127, -1, 90, -1, 91,
1738 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1739 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1740 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1741 -1, 107, -1, 108, -1, 109, -1, 96, -1, 97,
1742 -1, 98, -1, 99, -1, 26, -1, 27, -1, 11,
1743 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1744 -1, 19, -1, 22, -1, 24, -1, 170, -1, -1,
1745 170, 148, -1, -1, 20, -1, 23, -1, 175, -1,
1746 -1, 173, 148, -1, 42, -1, 44, -1, 43, -1,
1747 45, -1, 47, -1, 46, -1, 48, -1, 50, -1,
1748 -1, 145, -1, 146, -1, 147, -1, -1, 46, -1,
1749 48, -1, -1, 42, -1, 43, -1, 44, -1, 47,
1750 -1, -1, 44, -1, 42, -1, -1, 61, -1, 62,
1751 -1, 63, -1, 64, -1, 65, -1, 60, 4, -1,
1752 135, -1, 117, -1, 134, -1, 118, -1, 137, -1,
1753 138, -1, 140, -1, 141, -1, 142, -1, -1, 184,
1754 183, -1, 136, -1, 139, -1, 135, -1, 134, -1,
1755 144, -1, 143, -1, -1, 186, 185, -1, -1, 53,
1756 4, -1, -1, 149, 53, 4, -1, 34, 22, -1,
1757 -1, 189, -1, -1, 149, 192, 191, -1, 189, -1,
1758 53, 4, -1, 11, -1, 12, -1, 13, -1, 16,
1759 -1, 15, -1, 14, -1, 17, -1, 49, -1, 193,
1760 -1, 194, 150, -1, 228, -1, 151, 4, -1, 194,
1761 152, 198, 153, 186, -1, 10, 152, 198, 153, 186,
1762 -1, 154, 4, 155, 194, 156, -1, 157, 4, 155,
1763 194, 158, -1, 159, 199, 160, -1, 159, 160, -1,
1764 157, 159, 199, 160, 158, -1, 157, 159, 160, 158,
1765 -1, 194, 184, -1, 194, -1, 10, -1, 195, -1,
1766 197, 149, 195, -1, 197, -1, 197, 149, 39, -1,
1767 39, -1, -1, 194, -1, 199, 149, 194, -1, 194,
1768 154, 202, 156, -1, 194, 154, 156, -1, 194, 161,
1769 22, -1, 194, 157, 202, 158, -1, 194, 159, 202,
1770 160, -1, 194, 159, 160, -1, 194, 157, 159, 202,
1771 160, 158, -1, 194, 157, 159, 160, 158, -1, 194,
1772 40, -1, 194, 41, -1, 194, 228, -1, 194, 201,
1773 -1, 194, 25, -1, 168, 3, -1, 168, 5, -1,
1774 168, 4, -1, 168, 6, -1, 11, 26, -1, 11,
1775 27, -1, 169, 9, -1, 165, 152, 200, 38, 194,
1776 153, -1, 115, 152, 200, 239, 153, -1, 129, 152,
1777 200, 149, 200, 149, 200, 153, -1, 163, 152, 200,
1778 149, 200, 153, -1, 164, 152, 200, 149, 200, 153,
1779 -1, 88, 166, 152, 200, 149, 200, 153, -1, 89,
1780 167, 152, 200, 149, 200, 153, -1, 131, 152, 200,
1781 149, 200, 153, -1, 132, 152, 200, 149, 200, 149,
1782 200, 153, -1, 133, 152, 200, 149, 200, 149, 200,
1783 153, -1, 202, 149, 200, -1, 200, -1, 32, -1,
1784 33, -1, 37, -1, -1, 196, 228, -1, 121, 152,
1785 205, 38, 194, 153, -1, 207, -1, -1, 208, -1,
1786 207, 208, -1, -1, 31, 209, 224, -1, -1, 30,
1787 210, 225, -1, 58, 57, 214, -1, 172, 18, 194,
1788 -1, 172, 18, 10, -1, -1, 174, 178, 204, 203,
1789 200, 211, 191, -1, -1, 174, 176, 178, 204, 203,
1790 200, 212, 191, -1, -1, 174, 177, 178, 204, 203,
1791 194, 213, 191, -1, 174, 178, 35, 181, 205, -1,
1792 51, 215, -1, 54, 148, 216, -1, 22, -1, 52,
1793 148, 22, -1, 66, 148, 22, -1, 154, 217, 156,
1794 -1, 217, 149, 22, -1, 22, -1, -1, 218, 149,
1795 194, 184, 171, -1, 194, 184, 171, -1, 218, -1,
1796 218, 149, 39, -1, 39, -1, -1, 182, 196, 173,
1797 152, 219, 153, 186, 190, 187, -1, 28, -1, 159,
1798 -1, 180, 178, 220, 221, -1, 29, -1, 160, -1,
1799 231, 223, -1, 179, 178, 220, -1, -1, 59, -1,
1800 3, -1, 4, -1, 9, -1, 26, -1, 27, -1,
1801 40, -1, 41, -1, 25, -1, 157, 202, 158, -1,
1802 201, -1, 57, 226, 22, 149, 22, -1, 7, -1,
1803 8, -1, 170, -1, 173, -1, 228, -1, 227, -1,
1804 194, 229, -1, 231, 232, -1, 222, 232, -1, 233,
1805 172, 234, -1, 233, 236, -1, -1, 21, -1, 67,
1806 230, -1, 67, 10, -1, 68, 17, 229, -1, 68,
1807 11, 229, 149, 17, 229, 149, 17, 229, -1, 69,
1808 168, 229, 149, 17, 229, 154, 235, 156, -1, 69,
1809 168, 229, 149, 17, 229, 154, 156, -1, 70, 182,
1810 196, 229, 152, 238, 153, 186, 38, 17, 229, 71,
1811 17, 229, -1, 71, -1, 72, -1, 235, 168, 227,
1812 149, 17, 229, -1, 168, 227, 149, 17, 229, -1,
1813 172, 241, -1, 194, 154, 229, 149, 229, 156, -1,
1814 237, 149, 154, 229, 149, 229, 156, -1, 194, 229,
1815 184, -1, 17, 229, 184, -1, 238, 149, 194, 229,
1816 184, -1, 238, 149, 17, 229, 184, -1, -1, -1,
1817 239, 149, 230, -1, 56, 55, -1, 55, -1, 163,
1818 194, 229, 149, 229, -1, 164, 194, 229, 149, 229,
1819 -1, 88, 166, 194, 229, 149, 229, -1, 89, 167,
1820 194, 229, 149, 229, -1, 165, 230, 38, 194, -1,
1821 129, 230, 149, 230, 149, 230, -1, 130, 230, 149,
1822 194, -1, 131, 230, 149, 230, -1, 132, 230, 149,
1823 230, 149, 230, -1, 133, 230, 149, 230, 149, 230,
1824 -1, 128, 237, -1, 240, 182, 196, 229, 152, 238,
1825 153, 186, -1, 243, -1, 36, -1, -1, 110, 194,
1826 188, -1, 110, 194, 149, 11, 229, 188, -1, 111,
1827 194, 188, -1, 111, 194, 149, 11, 229, 188, -1,
1828 112, 230, -1, 242, 113, 194, 229, 188, -1, 242,
1829 114, 230, 149, 194, 229, 188, -1, 115, 194, 229,
1830 239, -1
1831};
1832
1833/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1834static const yytype_uint16 yyrline[] =
1835{
1836 0, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128,
1837 1128, 1129, 1129, 1129, 1129, 1129, 1129, 1130, 1130, 1130,
1838 1130, 1130, 1130, 1131, 1131, 1131, 1131, 1131, 1131, 1134,
1839 1134, 1135, 1135, 1136, 1136, 1137, 1137, 1138, 1138, 1142,
1840 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146, 1146, 1147,
1841 1147, 1148, 1148, 1149, 1150, 1155, 1156, 1156, 1156, 1156,
1842 1156, 1158, 1158, 1158, 1159, 1159, 1163, 1167, 1172, 1172,
1843 1174, 1175, 1180, 1186, 1187, 1188, 1189, 1190, 1194, 1195,
1844 1196, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1213, 1214,
1845 1215, 1216, 1217, 1221, 1222, 1223, 1226, 1227, 1228, 1229,
1846 1230, 1231, 1232, 1239, 1240, 1241, 1242, 1243, 1244, 1245,
1847 1246, 1247, 1250, 1251, 1256, 1257, 1258, 1259, 1260, 1261,
1848 1264, 1265, 1272, 1273, 1279, 1280, 1288, 1296, 1297, 1302,
1849 1303, 1304, 1309, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
1850 1325, 1329, 1333, 1340, 1345, 1353, 1383, 1414, 1419, 1431,
1851 1441, 1445, 1455, 1462, 1469, 1476, 1481, 1486, 1493, 1494,
1852 1501, 1508, 1516, 1522, 1534, 1562, 1578, 1605, 1633, 1659,
1853 1679, 1705, 1725, 1737, 1744, 1810, 1820, 1830, 1836, 1846,
1854 1852, 1862, 1867, 1872, 1885, 1897, 1919, 1927, 1933, 1944,
1855 1949, 1954, 1960, 1966, 1975, 1979, 1987, 1987, 1990, 1990,
1856 1993, 2005, 2026, 2031, 2039, 2040, 2044, 2044, 2048, 2048,
1857 2051, 2054, 2078, 2089, 2089, 2100, 2099, 2109, 2108, 2119,
1858 2159, 2162, 2168, 2178, 2182, 2187, 2189, 2194, 2199, 2208,
1859 2218, 2229, 2233, 2242, 2251, 2256, 2377, 2377, 2379, 2388,
1860 2388, 2390, 2395, 2407, 2411, 2416, 2420, 2424, 2428, 2432,
1861 2436, 2440, 2444, 2448, 2473, 2477, 2487, 2491, 2495, 2500,
1862 2507, 2507, 2513, 2522, 2526, 2535, 2544, 2553, 2557, 2564,
1863 2568, 2572, 2577, 2587, 2606, 2615, 2695, 2699, 2706, 2717,
1864 2730, 2740, 2751, 2761, 2770, 2776, 2785, 2791, 2794, 2795,
1865 2802, 2806, 2811, 2827, 2844, 2858, 2872, 2884, 2892, 2899,
1866 2905, 2911, 2917, 2932, 3017, 3022, 3026, 3033, 3040, 3048,
1867 3055, 3063, 3071, 3085, 3102
1868};
1869#endif
1870
1871#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1872/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1873 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1874static const char *const yytname[] =
1875{
1876 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1877 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1878 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1879 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1880 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1881 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1882 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1883 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1884 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1885 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1886 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1887 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1888 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1889 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1890 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1891 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1892 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1893 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1894 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1895 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1896 "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN",
1897 "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "CONST", "PURE",
1898 "DEFAULT", "HIDDEN", "PROTECTED", "'='", "','", "'*'", "'\\\\'", "'('",
1899 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1900 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1901 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1902 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1903 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1904 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1905 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1906 "SectionString", "OptSection", "GlobalVarAttributes",
1907 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1908 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1909 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1910 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1911 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1912 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1913 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1914 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1915 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1916 "PHIList", "ParamList", "IndexList", "OptTailCall", "InstVal",
1917 "OptVolatile", "MemoryInst", 0
1918};
1919#endif
1920
1921# ifdef YYPRINT
1922/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1923 token YYLEX-NUM. */
1924static const yytype_uint16 yytoknum[] =
1925{
1926 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1927 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1928 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1929 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1930 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1931 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1932 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1933 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1934 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1935 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1936 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1937 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1938 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1939 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1940 395, 396, 397, 398, 399, 400, 401, 402, 61, 44,
1941 42, 92, 40, 41, 91, 120, 93, 60, 62, 123,
1942 125, 99
1943};
1944# endif
1945
1946/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1947static const yytype_uint8 yyr1[] =
1948{
1949 0, 162, 163, 163, 163, 163, 163, 163, 163, 163,
1950 163, 164, 164, 164, 164, 164, 164, 165, 165, 165,
1951 165, 165, 165, 165, 165, 165, 165, 165, 165, 166,
1952 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1953 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
1954 167, 167, 167, 167, 167, 168, 169, 169, 169, 169,
1955 169, 170, 170, 170, 171, 171, 172, 172, 173, 173,
1956 174, 174, 175, 176, 176, 176, 176, 176, 177, 177,
1957 177, 178, 178, 178, 178, 179, 179, 179, 180, 180,
1958 180, 180, 180, 181, 181, 181, 182, 182, 182, 182,
1959 182, 182, 182, 183, 183, 183, 183, 183, 183, 183,
1960 183, 183, 184, 184, 185, 185, 185, 185, 185, 185,
1961 186, 186, 187, 187, 188, 188, 189, 190, 190, 191,
1962 191, 192, 192, 193, 193, 193, 193, 193, 193, 193,
1963 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
1964 194, 194, 194, 195, 196, 196, 197, 197, 198, 198,
1965 198, 198, 199, 199, 200, 200, 200, 200, 200, 200,
1966 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
1967 200, 200, 200, 200, 201, 201, 201, 201, 201, 201,
1968 201, 201, 201, 201, 202, 202, 203, 203, 204, 204,
1969 205, 205, 206, 206, 207, 207, 209, 208, 210, 208,
1970 208, 208, 208, 211, 208, 212, 208, 213, 208, 208,
1971 208, 208, 214, 215, 215, 216, 217, 217, 217, 218,
1972 218, 219, 219, 219, 219, 220, 221, 221, 222, 223,
1973 223, 224, 225, 226, 226, 227, 227, 227, 227, 227,
1974 227, 227, 227, 227, 227, 227, 228, 228, 228, 228,
1975 229, 229, 230, 231, 231, 232, 233, 233, 233, 234,
1976 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
1977 236, 237, 237, 238, 238, 238, 238, 238, 239, 239,
1978 240, 240, 241, 241, 241, 241, 241, 241, 241, 241,
1979 241, 241, 241, 241, 241, 242, 242, 243, 243, 243,
1980 243, 243, 243, 243, 243
1981};
1982
1983/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1984static const yytype_uint8 yyr2[] =
1985{
1986 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1987 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1992 1, 1, 1, 1, 1, 0, 2, 0, 1, 1,
1993 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1994 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1995 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1996 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1997 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
1998 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1999 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2000 1, 1, 2, 1, 2, 5, 5, 5, 5, 3,
2001 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2002 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2003 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2004 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2005 7, 6, 8, 8, 3, 1, 1, 1, 1, 0,
2006 2, 6, 1, 0, 1, 2, 0, 3, 0, 3,
2007 3, 3, 3, 0, 7, 0, 8, 0, 8, 5,
2008 2, 3, 1, 3, 3, 3, 3, 1, 0, 5,
2009 3, 1, 3, 1, 0, 9, 1, 1, 4, 1,
2010 1, 2, 3, 0, 1, 1, 1, 1, 1, 1,
2011 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2012 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
2013 2, 3, 9, 9, 8, 14, 1, 1, 6, 5,
2014 2, 6, 7, 3, 3, 5, 5, 0, 0, 3,
2015 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
2016 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
2017 6, 2, 5, 7, 4
2018};
2019
2020/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2021 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2022 means the default is an error. */
2023static const yytype_uint16 yydefact[] =
2024{
2025 71, 61, 68, 62, 69, 63, 208, 206, 0, 0,
2026 0, 0, 0, 0, 81, 70, 0, 71, 204, 85,
2027 88, 0, 0, 220, 0, 0, 66, 0, 72, 73,
2028 75, 74, 76, 78, 77, 79, 80, 82, 83, 84,
2029 81, 81, 199, 1, 205, 86, 87, 81, 209, 89,
2030 90, 91, 92, 81, 267, 207, 267, 0, 0, 228,
2031 221, 222, 210, 256, 257, 212, 133, 134, 135, 138,
2032 137, 136, 139, 140, 0, 0, 0, 0, 258, 259,
2033 141, 211, 143, 199, 199, 93, 198, 0, 96, 96,
2034 268, 264, 67, 239, 240, 241, 263, 223, 224, 227,
2035 0, 161, 144, 0, 0, 0, 0, 150, 162, 0,
2036 142, 161, 0, 0, 95, 94, 0, 196, 197, 0,
2037 0, 97, 98, 99, 100, 101, 0, 242, 0, 306,
2038 266, 0, 225, 160, 112, 156, 158, 0, 0, 0,
2039 0, 0, 0, 149, 0, 0, 0, 155, 0, 154,
2040 0, 219, 133, 134, 135, 138, 137, 136, 0, 0,
2041 0, 213, 102, 0, 236, 237, 238, 305, 291, 0,
2042 0, 0, 0, 96, 276, 277, 2, 3, 4, 5,
2043 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
2044 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
2045 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
2046 0, 0, 0, 0, 0, 0, 0, 0, 265, 96,
2047 280, 0, 304, 226, 153, 0, 120, 0, 0, 152,
2048 0, 163, 120, 215, 217, 0, 200, 181, 182, 177,
2049 179, 178, 180, 183, 176, 172, 173, 0, 0, 0,
2050 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2051 0, 175, 174, 129, 0, 290, 270, 0, 269, 0,
2052 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2053 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2054 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2055 48, 0, 124, 124, 311, 0, 0, 302, 0, 0,
2056 0, 0, 0, 0, 0, 0, 0, 0, 0, 104,
2057 106, 105, 103, 107, 108, 109, 110, 111, 113, 159,
2058 157, 146, 147, 148, 151, 145, 129, 129, 0, 0,
2059 0, 0, 0, 0, 0, 0, 165, 195, 0, 0,
2060 0, 169, 0, 166, 0, 0, 0, 0, 214, 234,
2061 245, 246, 247, 252, 248, 249, 250, 251, 243, 0,
2062 254, 261, 260, 262, 0, 271, 0, 0, 0, 0,
2063 0, 307, 0, 309, 288, 0, 0, 0, 0, 0,
2064 0, 0, 0, 0, 0, 0, 0, 0, 117, 116,
2065 114, 115, 119, 118, 121, 216, 218, 0, 0, 0,
2066 288, 0, 0, 0, 0, 0, 164, 150, 162, 0,
2067 167, 168, 0, 0, 0, 0, 0, 131, 129, 233,
2068 112, 231, 0, 244, 0, 0, 0, 0, 0, 0,
2069 0, 0, 0, 0, 314, 0, 0, 0, 298, 299,
2070 0, 0, 0, 0, 296, 0, 124, 0, 0, 0,
2071 0, 0, 0, 0, 0, 0, 194, 171, 0, 0,
2072 0, 0, 126, 132, 130, 65, 0, 120, 0, 253,
2073 0, 0, 287, 0, 0, 124, 125, 124, 0, 0,
2074 0, 0, 0, 0, 292, 293, 287, 0, 312, 0,
2075 201, 0, 0, 185, 0, 0, 0, 0, 170, 0,
2076 0, 0, 64, 230, 232, 112, 127, 0, 0, 0,
2077 139, 0, 0, 294, 295, 308, 310, 289, 0, 0,
2078 297, 300, 301, 0, 124, 0, 0, 0, 191, 0,
2079 0, 187, 188, 184, 65, 128, 122, 255, 0, 0,
2080 112, 112, 0, 120, 281, 0, 120, 313, 189, 190,
2081 0, 0, 0, 229, 0, 235, 0, 274, 0, 0,
2082 284, 283, 139, 0, 0, 282, 303, 186, 192, 193,
2083 123, 272, 0, 273, 0, 112, 112, 0, 0, 0,
2084 286, 285, 0, 0, 0, 0, 279, 0, 0, 278,
2085 0, 275
2086};
2087
2088/* YYDEFGOTO[NTERM-NUM]. */
2089static const yytype_int16 yydefgoto[] =
2090{
2091 -1, 258, 259, 260, 284, 301, 158, 159, 78, 513,
2092 12, 79, 14, 15, 40, 41, 42, 47, 53, 116,
2093 126, 328, 224, 404, 331, 565, 381, 427, 546, 358,
2094 428, 80, 160, 135, 150, 136, 137, 109, 347, 370,
2095 348, 119, 87, 151, 16, 17, 18, 20, 19, 263,
2096 336, 337, 62, 23, 60, 100, 431, 432, 127, 166,
2097 54, 95, 55, 48, 434, 371, 82, 373, 268, 56,
2098 91, 92, 218, 569, 130, 307, 522, 444, 219, 220,
2099 221, 222
2100};
2101
2102/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2103 STATE-NUM. */
2104#define YYPACT_NINF -549
2105static const yytype_int16 yypact[] =
2106{
2107 322, -549, -549, -549, -549, -549, -549, -549, -18, -120,
2108 6, -117, 62, -60, 224, -549, 111, 464, -549, 103,
2109 184, -12, -7, -549, 21, 133, -549, 1309, -549, -549,
2110 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2111 140, 140, 211, -549, -549, -549, -549, 140, -549, -549,
2112 -549, -549, -549, 140, 139, -549, -14, 157, 174, 182,
2113 -549, -549, -549, -549, -549, 60, -549, -549, -549, -549,
2114 -549, -549, -549, -549, 215, 233, 2, 526, -549, -549,
2115 -549, 150, -549, 178, 178, 269, -549, 14, 274, 274,
2116 -549, -549, 134, -549, -549, -549, -549, -549, -549, -549,
2117 -23, 54, -549, 97, 105, 993, 60, -549, 150, -125,
2118 -549, 54, 14, 14, -549, -549, 1093, -549, -549, 1340,
2119 260, -549, -549, -549, -549, -549, 1358, -549, -17, 1584,
2120 -549, 251, -549, -549, 150, -549, 128, 146, 1380, 1380,
2121 145, -106, 1380, -549, 151, 1340, 1380, 60, 155, 150,
2122 231, -549, 101, 303, 305, 308, 312, 315, 229, 320,
2123 808, -549, -549, 187, -549, -549, -549, -549, -549, 275,
2124 1423, 85, 321, 274, -549, -549, -549, -549, -549, -549,
2125 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2126 -549, 461, 481, 1380, 1380, 1380, 1380, -549, -549, -549,
2127 -549, -549, -549, -549, -549, -549, -549, -549, -549, 1380,
2128 1380, 1380, 1380, 1380, 1380, 1380, 1380, 1380, -549, 274,
2129 -549, 110, -549, -549, -85, 1116, -549, -2, -33, -549,
2130 173, 150, -549, -549, 150, 1093, -549, -549, -549, -549,
2131 -549, -549, -549, -549, -549, -549, -549, 461, 481, 191,
2132 198, 199, 203, 204, 1156, 1534, 1033, 335, 206, 207,
2133 208, -549, -549, 217, 223, -549, 60, 649, -549, 785,
2134 785, -549, 785, 1358, -549, -549, -549, -549, -549, -549,
2135 -549, -549, -549, -549, 1380, -549, -549, -549, -549, -549,
2136 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2137 -549, 1380, 107, 113, -549, 649, 26, 218, 236, 237,
2138 238, 239, 240, 649, 649, 340, 1358, 1380, 1380, -549,
2139 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2140 -549, 162, -549, -549, -549, 162, 217, 217, 344, 242,
2141 243, 1340, 1340, 1340, 1340, 1340, -549, -549, -9, 1073,
2142 -50, -549, -63, -549, 1340, 1340, 1340, -11, -549, 1187,
2143 -549, -549, -549, -549, -549, -549, -549, -549, 333, 1340,
2144 -549, -549, -549, -549, 247, -549, 248, 785, 649, 649,
2145 7, -549, 34, -549, -549, 785, 244, 1380, 1380, 1380,
2146 1380, 1380, 256, 257, 1380, 785, 649, 258, -549, -549,
2147 -549, -549, -549, -549, -549, -549, -549, 1380, 1340, 1340,
2148 -549, 261, 264, 267, 268, 1340, -549, 263, 808, -51,
2149 -549, -549, 270, 273, 362, 396, 419, -549, 217, -549,
2150 150, 276, 271, -549, 405, -48, 411, 412, 280, 284,
2151 287, 785, 433, 785, 289, 290, 785, 293, 150, -549,
2152 294, 295, 785, 785, 150, 296, 297, 1380, 90, 298,
2153 300, 13, 1340, 1340, 1340, 1340, -549, -549, 299, 1340,
2154 1340, 1380, -549, -549, -549, -3, 1269, -549, 304, -549,
2155 785, 785, 1577, 785, 785, 297, -549, 297, 1380, 785,
2156 306, 1380, 1380, 1380, -549, -549, 1577, 401, -549, 649,
2157 -549, 1340, 1340, -549, 309, 310, 319, 323, -549, 316,
2158 318, 126, -549, -549, -549, 150, 38, 437, 324, 307,
2159 785, 649, 44, -549, -549, -549, -549, -549, 325, 785,
2160 -549, -549, -549, 53, 297, 327, 332, 1340, -549, 1340,
2161 1340, -549, -549, -549, -3, -549, 421, -549, 460, 1,
2162 -549, -549, 1595, -549, -549, 334, -549, -549, -549, -549,
2163 336, 338, 339, -549, 489, -549, 785, -549, 945, 3,
2164 -85, -85, 785, 649, 86, -549, 162, -549, -549, -549,
2165 -549, -549, 347, -549, 945, -549, -549, 484, 485, 356,
2166 -85, -85, 785, 785, 492, 439, -549, 785, 494, -549,
2167 785, -549
2168};
2169
2170/* YYPGOTO[NTERM-NUM]. */
2171static const yytype_int16 yypgoto[] =
2172{
2173 -549, 383, 384, 385, 272, 277, -170, -549, 0, -24,
2174 429, 8, -549, -549, -549, -549, 42, -549, -549, -549,
2175 -160, -549, -421, -549, -228, -549, -293, 11, -549, -310,
2176 -549, -549, -26, 341, -121, -549, 418, 425, -61, -157,
2177 -226, 9, 205, 326, -549, -549, 515, -549, -549, -549,
2178 -549, -549, -549, -549, -549, -549, -549, -549, 446, -549,
2179 -549, -549, -549, -549, -549, -548, -69, 121, -173, -549,
2180 491, -549, -549, -549, -549, -549, 67, 158, -549, -549,
2181 -549, -549
2182};
2183
2184/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2185 positive, shift that token. If negative, reduce the rule which
2186 number is the opposite. If zero, do what YYDEFACT says.
2187 If YYTABLE_NINF, syntax error. */
2188#define YYTABLE_NINF -204
2189static const yytype_int16 yytable[] =
2190{
2191 11, 81, 272, 261, 335, 163, 104, 90, 13, 475,
2192 383, 164, 271, 273, 271, 93, 1, 11, 441, 3,
2193 582, 5, 304, 425, 142, 13, 405, 406, 24, 350,
2194 352, 26, 319, 320, 21, 143, 589, 308, 309, 310,
2195 311, 312, 426, 142, 315, 443, 117, 118, 22, 321,
2196 322, 108, 323, 324, 230, 325, 326, 327, 161, 316,
2197 442, 63, 64, 25, 106, 66, 67, 68, 69, 70,
2198 71, 72, 425, 1, 2, 134, 3, 4, 5, 108,
2199 27, 236, 83, 84, 233, 134, 415, 442, 28, 88,
2200 149, 262, 11, 133, 544, 89, 269, 421, 415, 415,
2201 149, 415, 270, 73, -55, -55, -55, -55, 420, 468,
2202 479, 43, 227, 228, 319, 320, 231, 110, 474, 111,
2203 234, 145, 146, 419, 587, 333, 131, 237, 238, 570,
2204 571, 321, 322, 132, 323, 324, 57, 325, 326, 327,
2205 415, 58, 165, 435, 267, 397, 94, 416, 110, 45,
2206 111, 46, 377, 1, 332, 61, 3, 567, 5, 583,
2207 90, 105, 488, 498, 590, 591, 503, 302, 303, 267,
2208 305, 264, 398, 399, 400, 59, 110, 401, 111, 97,
2209 385, 402, 403, 306, 267, 267, 267, 267, 267, 313,
2210 314, 267, 525, 552, 526, 395, 98, 553, 372, 134,
2211 372, 372, 552, 372, 99, 74, 556, 2, 75, 149,
2212 4, 76, 101, 77, 447, 86, 449, 450, 451, 102,
2213 398, 399, 400, 317, 318, 401, 49, 50, 51, 402,
2214 403, 52, 239, 240, 241, 242, 372, 103, 63, 64,
2215 110, 557, 111, 500, 372, 372, 85, 149, 86, 516,
2216 1, 2, 138, 3, 4, 5, 380, 110, 378, 111,
2217 139, 261, 382, 110, 162, 111, 29, 30, 31, 32,
2218 33, 34, 35, 223, 36, 379, 110, 225, 111, 543,
2219 410, 411, 412, 413, 414, 37, 38, 39, 112, 113,
2220 149, 396, 267, 422, 423, 424, 398, 399, 400, 226,
2221 110, 401, 111, 229, 232, 402, 403, 235, 372, 372,
2222 372, 114, -56, 115, -57, 527, 372, -60, 530, 531,
2223 532, -59, -203, 418, -58, 574, 372, 372, 576, 243,
2224 265, 334, 271, 430, 120, 121, 122, 123, 124, 125,
2225 -67, 1, 2, 341, 3, 4, 5, 459, 460, 262,
2226 342, 343, 6, 7, 466, 344, 345, 353, 354, 355,
2227 356, 267, 448, 267, 267, 267, 357, 386, 454, 37,
2228 38, 39, 372, 8, 372, 359, 9, 372, 394, 568,
2229 10, 458, 407, 372, 372, 387, 388, 389, 390, 391,
2230 374, 375, 433, 376, 408, 409, 436, 437, 446, 584,
2231 471, 504, 505, 506, 507, 452, 453, 457, 509, 510,
2232 462, 372, 372, 463, 372, 372, 464, 465, 472, 469,
2233 372, 467, 470, 473, 477, 476, 384, 478, 480, 481,
2234 372, 499, 482, 483, 392, 393, 484, 486, 488, 489,
2235 535, 536, 491, 492, 493, 511, 497, 501, 496, 502,
2236 515, 372, 372, 517, 442, 529, 521, 508, 537, 547,
2237 372, 549, 267, 538, -202, 267, 267, 267, 539, 541,
2238 521, 542, 540, 548, 564, 512, 560, 566, 561, 562,
2239 558, 554, -67, 1, 2, 559, 3, 4, 5, 577,
2240 575, 578, 579, 580, 6, 7, 588, 372, 438, 439,
2241 440, 592, 593, 372, 372, 594, 445, 285, 286, 597,
2242 598, 600, 215, 216, 217, 8, 455, 456, 9, 339,
2243 563, 129, 10, 372, 372, 340, 573, 545, 372, 144,
2244 141, 372, 44, 63, 64, 128, 106, 66, 67, 68,
2245 69, 70, 71, 72, 512, 1, 2, 96, 3, 4,
2246 5, 274, 275, 276, 277, 278, 279, 280, 281, 282,
2247 283, 338, 485, 533, 487, 0, 330, 490, 461, 0,
2248 0, 0, 0, 494, 495, 73, 0, 287, 288, 289,
2249 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
2250 300, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2251 0, 518, 519, 0, 523, 524, 0, 0, 0, 0,
2252 528, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2253 534, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2255 0, 550, 551, 0, 0, 0, 0, 0, 0, 0,
2256 555, 0, 360, 361, 0, 0, 63, 64, 362, 0,
2257 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2258 0, 3, 4, 5, 363, 364, 365, 74, 0, 0,
2259 75, 0, 0, 76, 0, 77, 107, 581, 0, 366,
2260 367, 0, 0, 585, 586, 0, 0, 0, 0, 0,
2261 0, 0, 0, 0, 0, 0, 368, 0, 0, 0,
2262 0, 0, 0, 595, 596, 0, 0, 0, 599, 0,
2263 0, 601, 176, 177, 178, 179, 180, 181, 182, 183,
2264 184, 185, 186, 187, 188, 189, 190, 247, 248, 0,
2265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2267 0, 0, 0, 0, 249, 197, 198, 199, 200, 201,
2268 202, 203, 204, 205, 206, 207, 208, 0, 250, 0,
2269 251, 252, 253, 0, 0, 0, 0, 0, 360, 361,
2270 0, 0, 63, 64, 362, 0, 0, 0, 0, 110,
2271 0, 111, 0, 0, 1, 2, 369, 3, 4, 5,
2272 363, 364, 365, 0, 0, 63, 64, 0, 0, 0,
2273 0, 0, 0, 0, 0, 366, 367, 1, 2, 0,
2274 3, 4, 5, 244, 0, 0, 0, 0, 0, 0,
2275 0, 0, 368, 0, 0, 0, 0, 0, 245, 246,
2276 0, 0, 0, 0, 0, 0, 0, 0, 176, 177,
2277 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2278 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2279 0, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2280 185, 186, 187, 188, 189, 190, 247, 248, 0, 0,
2281 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2282 206, 207, 208, 0, 250, 0, 251, 252, 253, 0,
2283 0, 0, 0, 249, 197, 198, 199, 200, 201, 202,
2284 203, 204, 205, 206, 207, 208, 0, 250, 0, 251,
2285 252, 253, 369, 0, 0, 0, 0, 0, 360, 361,
2286 0, 0, 0, 0, 362, 0, 0, 0, 110, 0,
2287 111, 0, 254, 0, 0, 255, 0, 256, 0, 257,
2288 363, 364, 365, 0, 0, 0, 0, 0, 0, 0,
2289 0, 0, 0, 0, 0, 366, 367, 0, 0, 0,
2290 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2291 63, 64, 368, 106, 66, 67, 68, 69, 70, 71,
2292 72, 0, 1, 2, 0, 3, 4, 5, 176, 177,
2293 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2294 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2295 63, 64, 73, 106, 152, 153, 154, 155, 156, 157,
2296 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2297 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2298 206, 207, 208, 0, 250, 0, 251, 252, 253, 0,
2299 63, 64, 73, 106, 152, 153, 154, 155, 156, 157,
2300 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2301 63, 64, 369, 147, 66, 67, 68, 69, 70, 71,
2302 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2303 0, 0, 73, 63, 64, 0, 106, 66, 67, 68,
2304 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2305 5, 0, 73, 0, 74, 0, 0, 75, 0, 0,
2306 76, 0, 77, 140, 0, 329, 0, 0, 0, 0,
2307 0, 0, 0, 63, 64, 73, 106, 152, 153, 154,
2308 155, 156, 157, 72, 0, 1, 2, 0, 3, 4,
2309 5, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2310 76, 0, 77, 351, 63, 64, 0, 106, 66, 67,
2311 68, 69, 70, 71, 72, 73, 1, 2, 0, 3,
2312 4, 5, 0, 0, 148, 0, 0, 0, 0, 0,
2313 0, 0, 0, 0, 74, 0, 429, 75, 0, 0,
2314 76, 0, 77, 417, 0, 0, 73, 0, 0, 0,
2315 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2316 76, 0, 77, 0, 0, 0, 0, 0, 0, 0,
2317 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2318 75, 0, 0, 76, 0, 77, 63, 64, 0, 106,
2319 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2320 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 0, 74, 514, 0,
2322 75, 0, 346, 76, 0, 77, 63, 64, 73, 65,
2323 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2324 0, 3, 4, 5, 0, 0, 0, 0, 74, 0,
2325 0, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2326 106, 152, 153, 154, 155, 156, 157, 72, 73, 1,
2327 2, 0, 3, 4, 5, 63, 64, 0, 147, 66,
2328 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2329 3, 4, 5, 0, 0, 0, 0, 63, 64, 73,
2330 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2331 2, 0, 3, 4, 5, 0, 0, 73, 0, 0,
2332 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2333 74, 0, 0, 75, 0, 0, 76, 0, 77, 73,
2334 63, 64, 0, 266, 66, 67, 68, 69, 70, 71,
2335 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2337 74, 0, 0, 75, 0, 0, 76, 0, 77, 0,
2338 0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
2339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2340 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2341 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2342 0, 0, 75, 0, 0, 76, 0, 77, 0, 0,
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2345 0, 63, 64, 0, 106, 152, 153, 154, 155, 156,
2346 157, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2348 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2349 76, 0, 77, 73, 63, 64, 0, 106, 66, 67,
2350 68, 69, 70, 71, 520, 0, 1, 2, 0, 3,
2351 4, 5, 63, 64, 0, 106, 66, 67, 68, 69,
2352 70, 71, 572, 0, 1, 2, 0, 3, 4, 5,
2353 167, 0, 0, 0, 0, 0, 73, 0, 0, 0,
2354 0, 0, 0, 0, 0, 0, 0, 0, 0, 168,
2355 169, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2356 0, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2357 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2358 189, 190, 191, 192, 0, 0, 0, 0, 0, 0,
2359 0, 0, 0, 0, 0, 74, 0, 0, 75, 0,
2360 0, 76, 0, 349, 193, 194, 195, 0, 0, 196,
2361 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
2362 207, 208, 209, 210, 211, 212, 213, 214, 0, 0,
2363 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2364 0, 75, 0, 0, 76, 0, 77, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 74, 0, 0, 75,
2366 0, 0, 76, 0, 77
2367};
2368
2369static const yytype_int16 yycheck[] =
2370{
2371 0, 27, 172, 160, 232, 126, 4, 21, 0, 430,
2372 303, 28, 11, 173, 11, 29, 19, 17, 11, 22,
2373 568, 24, 195, 34, 149, 17, 336, 337, 148, 255,
2374 256, 148, 117, 118, 52, 160, 584, 210, 211, 212,
2375 213, 214, 53, 149, 217, 11, 32, 33, 66, 134,
2376 135, 77, 137, 138, 160, 140, 141, 142, 119, 219,
2377 53, 7, 8, 57, 10, 11, 12, 13, 14, 15,
2378 16, 17, 34, 19, 20, 101, 22, 23, 24, 105,
2379 18, 150, 40, 41, 145, 111, 149, 53, 148, 47,
2380 116, 160, 92, 39, 515, 53, 11, 160, 149, 149,
2381 126, 149, 17, 49, 3, 4, 5, 6, 158, 160,
2382 158, 0, 138, 139, 117, 118, 142, 150, 428, 152,
2383 146, 112, 113, 349, 38, 158, 149, 26, 27, 550,
2384 551, 134, 135, 156, 137, 138, 148, 140, 141, 142,
2385 149, 148, 159, 369, 170, 318, 160, 156, 150, 46,
2386 152, 48, 273, 19, 156, 22, 22, 156, 24, 156,
2387 21, 159, 149, 456, 585, 586, 153, 193, 194, 195,
2388 196, 163, 134, 135, 136, 154, 150, 139, 152, 22,
2389 154, 143, 144, 209, 210, 211, 212, 213, 214, 215,
2390 216, 217, 485, 149, 487, 316, 22, 153, 267, 225,
2391 269, 270, 149, 272, 22, 151, 153, 20, 154, 235,
2392 23, 157, 152, 159, 387, 37, 389, 390, 391, 4,
2393 134, 135, 136, 113, 114, 139, 42, 43, 44, 143,
2394 144, 47, 3, 4, 5, 6, 305, 4, 7, 8,
2395 150, 534, 152, 153, 313, 314, 35, 273, 37, 477,
2396 19, 20, 155, 22, 23, 24, 149, 150, 284, 152,
2397 155, 418, 149, 150, 4, 152, 42, 43, 44, 45,
2398 46, 47, 48, 22, 50, 301, 150, 149, 152, 153,
2399 341, 342, 343, 344, 345, 145, 146, 147, 83, 84,
2400 316, 317, 318, 354, 355, 356, 134, 135, 136, 153,
2401 150, 139, 152, 158, 153, 143, 144, 152, 377, 378,
2402 379, 42, 9, 44, 9, 488, 385, 9, 491, 492,
2403 493, 9, 0, 349, 9, 553, 395, 396, 556, 9,
2404 55, 158, 11, 359, 60, 61, 62, 63, 64, 65,
2405 18, 19, 20, 152, 22, 23, 24, 408, 409, 418,
2406 152, 152, 30, 31, 415, 152, 152, 22, 152, 152,
2407 152, 387, 388, 389, 390, 391, 149, 149, 394, 145,
2408 146, 147, 441, 51, 443, 152, 54, 446, 38, 549,
2409 58, 407, 38, 452, 453, 149, 149, 149, 149, 149,
2410 269, 270, 59, 272, 152, 152, 149, 149, 154, 569,
2411 38, 462, 463, 464, 465, 149, 149, 149, 469, 470,
2412 149, 480, 481, 149, 483, 484, 149, 149, 22, 149,
2413 489, 158, 149, 4, 153, 149, 305, 22, 17, 17,
2414 499, 457, 152, 149, 313, 314, 149, 4, 149, 149,
2415 501, 502, 149, 149, 149, 471, 149, 149, 152, 149,
2416 476, 520, 521, 149, 53, 149, 482, 158, 149, 22,
2417 529, 154, 488, 153, 0, 491, 492, 493, 149, 153,
2418 496, 153, 149, 149, 53, 475, 537, 17, 539, 540,
2419 153, 156, 18, 19, 20, 153, 22, 23, 24, 153,
2420 156, 153, 153, 4, 30, 31, 149, 566, 377, 378,
2421 379, 17, 17, 572, 573, 149, 385, 26, 27, 17,
2422 71, 17, 129, 129, 129, 51, 395, 396, 54, 247,
2423 544, 92, 58, 592, 593, 248, 552, 516, 597, 111,
2424 105, 600, 17, 7, 8, 89, 10, 11, 12, 13,
2425 14, 15, 16, 17, 544, 19, 20, 56, 22, 23,
2426 24, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2427 99, 235, 441, 496, 443, -1, 225, 446, 410, -1,
2428 -1, -1, -1, 452, 453, 49, -1, 96, 97, 98,
2429 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2430 109, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2431 -1, 480, 481, -1, 483, 484, -1, -1, -1, -1,
2432 489, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2433 499, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2434 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2435 -1, 520, 521, -1, -1, -1, -1, -1, -1, -1,
2436 529, -1, 3, 4, -1, -1, 7, 8, 9, -1,
2437 -1, -1, -1, -1, -1, -1, -1, -1, 19, 20,
2438 -1, 22, 23, 24, 25, 26, 27, 151, -1, -1,
2439 154, -1, -1, 157, -1, 159, 160, 566, -1, 40,
2440 41, -1, -1, 572, 573, -1, -1, -1, -1, -1,
2441 -1, -1, -1, -1, -1, -1, 57, -1, -1, -1,
2442 -1, -1, -1, 592, 593, -1, -1, -1, 597, -1,
2443 -1, 600, 73, 74, 75, 76, 77, 78, 79, 80,
2444 81, 82, 83, 84, 85, 86, 87, 88, 89, -1,
2445 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2446 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2447 -1, -1, -1, -1, 115, 116, 117, 118, 119, 120,
2448 121, 122, 123, 124, 125, 126, 127, -1, 129, -1,
2449 131, 132, 133, -1, -1, -1, -1, -1, 3, 4,
2450 -1, -1, 7, 8, 9, -1, -1, -1, -1, 150,
2451 -1, 152, -1, -1, 19, 20, 157, 22, 23, 24,
2452 25, 26, 27, -1, -1, 7, 8, -1, -1, -1,
2453 -1, -1, -1, -1, -1, 40, 41, 19, 20, -1,
2454 22, 23, 24, 25, -1, -1, -1, -1, -1, -1,
2455 -1, -1, 57, -1, -1, -1, -1, -1, 40, 41,
2456 -1, -1, -1, -1, -1, -1, -1, -1, 73, 74,
2457 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2458 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2459 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2460 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
2461 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2462 125, 126, 127, -1, 129, -1, 131, 132, 133, -1,
2463 -1, -1, -1, 115, 116, 117, 118, 119, 120, 121,
2464 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
2465 132, 133, 157, -1, -1, -1, -1, -1, 3, 4,
2466 -1, -1, -1, -1, 9, -1, -1, -1, 150, -1,
2467 152, -1, 154, -1, -1, 157, -1, 159, -1, 161,
2468 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2469 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2470 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2471 7, 8, 57, 10, 11, 12, 13, 14, 15, 16,
2472 17, -1, 19, 20, -1, 22, 23, 24, 73, 74,
2473 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2474 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2475 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
2476 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2477 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2478 125, 126, 127, -1, 129, -1, 131, 132, 133, -1,
2479 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
2480 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2481 7, 8, 157, 10, 11, 12, 13, 14, 15, 16,
2482 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2483 -1, -1, 49, 7, 8, -1, 10, 11, 12, 13,
2484 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2485 24, -1, 49, -1, 151, -1, -1, 154, -1, -1,
2486 157, -1, 159, 160, -1, 39, -1, -1, -1, -1,
2487 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
2488 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2489 24, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2490 157, -1, 159, 160, 7, 8, -1, 10, 11, 12,
2491 13, 14, 15, 16, 17, 49, 19, 20, -1, 22,
2492 23, 24, -1, -1, 121, -1, -1, -1, -1, -1,
2493 -1, -1, -1, -1, 151, -1, 39, 154, -1, -1,
2494 157, -1, 159, 160, -1, -1, 49, -1, -1, -1,
2495 -1, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2496 157, -1, 159, -1, -1, -1, -1, -1, -1, -1,
2497 -1, -1, -1, -1, -1, -1, -1, 151, -1, -1,
2498 154, -1, -1, 157, -1, 159, 7, 8, -1, 10,
2499 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2500 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2501 -1, -1, -1, -1, -1, -1, -1, 151, 39, -1,
2502 154, -1, 156, 157, -1, 159, 7, 8, 49, 10,
2503 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2504 -1, 22, 23, 24, -1, -1, -1, -1, 151, -1,
2505 -1, 154, -1, -1, 157, -1, 159, 7, 8, -1,
2506 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
2507 20, -1, 22, 23, 24, 7, 8, -1, 10, 11,
2508 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2509 22, 23, 24, -1, -1, -1, -1, 7, 8, 49,
2510 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2511 20, -1, 22, 23, 24, -1, -1, 49, -1, -1,
2512 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2513 151, -1, -1, 154, -1, -1, 157, -1, 159, 49,
2514 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2515 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2516 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2517 151, -1, -1, 154, -1, -1, 157, -1, 159, -1,
2518 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2519 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2520 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2521 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
2522 -1, -1, 154, -1, -1, 157, -1, 159, -1, -1,
2523 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2524 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2525 -1, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2526 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2527 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2528 -1, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2529 157, -1, 159, 49, 7, 8, -1, 10, 11, 12,
2530 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2531 23, 24, 7, 8, -1, 10, 11, 12, 13, 14,
2532 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2533 36, -1, -1, -1, -1, -1, 49, -1, -1, -1,
2534 -1, -1, -1, -1, -1, -1, -1, -1, -1, 55,
2535 56, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2536 -1, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2537 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2538 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
2539 -1, -1, -1, -1, -1, 151, -1, -1, 154, -1,
2540 -1, 157, -1, 159, 110, 111, 112, -1, -1, 115,
2541 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2542 126, 127, 128, 129, 130, 131, 132, 133, -1, -1,
2543 -1, -1, -1, -1, -1, -1, -1, -1, 151, -1,
2544 -1, 154, -1, -1, 157, -1, 159, -1, -1, -1,
2545 -1, -1, -1, -1, -1, -1, 151, -1, -1, 154,
2546 -1, -1, 157, -1, 159
2547};
2548
2549/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2550 symbol of state STATE-NUM. */
2551static const yytype_uint8 yystos[] =
2552{
2553 0, 19, 20, 22, 23, 24, 30, 31, 51, 54,
2554 58, 170, 172, 173, 174, 175, 206, 207, 208, 210,
2555 209, 52, 66, 215, 148, 57, 148, 18, 148, 42,
2556 43, 44, 45, 46, 47, 48, 50, 145, 146, 147,
2557 176, 177, 178, 0, 208, 46, 48, 179, 225, 42,
2558 43, 44, 47, 180, 222, 224, 231, 148, 148, 154,
2559 216, 22, 214, 7, 8, 10, 11, 12, 13, 14,
2560 15, 16, 17, 49, 151, 154, 157, 159, 170, 173,
2561 193, 194, 228, 178, 178, 35, 37, 204, 178, 178,
2562 21, 232, 233, 29, 160, 223, 232, 22, 22, 22,
2563 217, 152, 4, 4, 4, 159, 10, 160, 194, 199,
2564 150, 152, 204, 204, 42, 44, 181, 32, 33, 203,
2565 60, 61, 62, 63, 64, 65, 182, 220, 220, 172,
2566 236, 149, 156, 39, 194, 195, 197, 198, 155, 155,
2567 160, 199, 149, 160, 198, 203, 203, 10, 121, 194,
2568 196, 205, 11, 12, 13, 14, 15, 16, 168, 169,
2569 194, 200, 4, 196, 28, 159, 221, 36, 55, 56,
2570 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2571 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2572 87, 88, 89, 110, 111, 112, 115, 116, 117, 118,
2573 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2574 129, 130, 131, 132, 133, 163, 164, 165, 234, 240,
2575 241, 242, 243, 22, 184, 149, 153, 194, 194, 158,
2576 160, 194, 153, 200, 194, 152, 228, 26, 27, 3,
2577 4, 5, 6, 9, 25, 40, 41, 88, 89, 115,
2578 129, 131, 132, 133, 154, 157, 159, 161, 163, 164,
2579 165, 201, 228, 211, 173, 55, 10, 194, 230, 11,
2580 17, 11, 168, 182, 90, 91, 92, 93, 94, 95,
2581 96, 97, 98, 99, 166, 26, 27, 96, 97, 98,
2582 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2583 109, 167, 194, 194, 230, 194, 194, 237, 230, 230,
2584 230, 230, 230, 194, 194, 230, 182, 113, 114, 117,
2585 118, 134, 135, 137, 138, 140, 141, 142, 183, 39,
2586 195, 186, 156, 158, 158, 186, 212, 213, 205, 166,
2587 167, 152, 152, 152, 152, 152, 156, 200, 202, 159,
2588 202, 160, 202, 22, 152, 152, 152, 149, 191, 152,
2589 3, 4, 9, 25, 26, 27, 40, 41, 57, 157,
2590 201, 227, 228, 229, 229, 229, 229, 196, 194, 194,
2591 149, 188, 149, 188, 229, 154, 149, 149, 149, 149,
2592 149, 149, 229, 229, 38, 196, 194, 230, 134, 135,
2593 136, 139, 143, 144, 185, 191, 191, 38, 152, 152,
2594 200, 200, 200, 200, 200, 149, 156, 160, 194, 202,
2595 158, 160, 200, 200, 200, 34, 53, 189, 192, 39,
2596 194, 218, 219, 59, 226, 202, 149, 149, 229, 229,
2597 229, 11, 53, 11, 239, 229, 154, 230, 194, 230,
2598 230, 230, 149, 149, 194, 229, 229, 149, 194, 200,
2599 200, 239, 149, 149, 149, 149, 200, 158, 160, 149,
2600 149, 38, 22, 4, 191, 184, 149, 153, 22, 158,
2601 17, 17, 152, 149, 149, 229, 4, 229, 149, 149,
2602 229, 149, 149, 149, 229, 229, 152, 149, 188, 194,
2603 153, 149, 149, 153, 200, 200, 200, 200, 158, 200,
2604 200, 194, 170, 171, 39, 194, 186, 149, 229, 229,
2605 17, 194, 238, 229, 229, 188, 188, 230, 229, 149,
2606 230, 230, 230, 238, 229, 200, 200, 149, 153, 149,
2607 149, 153, 153, 153, 184, 189, 190, 22, 149, 154,
2608 229, 229, 149, 153, 156, 229, 153, 188, 153, 153,
2609 200, 200, 200, 171, 53, 187, 17, 156, 168, 235,
2610 184, 184, 17, 194, 186, 156, 186, 153, 153, 153,
2611 4, 229, 227, 156, 168, 229, 229, 38, 149, 227,
2612 184, 184, 17, 17, 149, 229, 229, 17, 71, 229,
2613 17, 229
2614};
David Greene9145dd22007-08-01 03:59:32 +00002615
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616#define yyerrok (yyerrstatus = 0)
2617#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002618#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002619#define YYEOF 0
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002620
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621#define YYACCEPT goto yyacceptlab
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002622#define YYABORT goto yyabortlab
2623#define YYERROR goto yyerrorlab
2624
2625
2626/* Like YYERROR except do call yyerror. This remains here temporarily
2627 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002629
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630#define YYFAIL goto yyerrlab
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002631
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002633
2634#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635do \
2636 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002637 { \
2638 yychar = (Token); \
2639 yylval = (Value); \
2640 yytoken = YYTRANSLATE (yychar); \
2641 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642 goto yybackup; \
2643 } \
2644 else \
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002645 { \
2646 yyerror (YY_("syntax error: cannot back up")); \
2647 YYERROR; \
2648 } \
2649while (YYID (0))
2650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651
2652#define YYTERROR 1
2653#define YYERRCODE 256
2654
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002655
2656/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2657 If N is 0, then set CURRENT to the empty location which ends
2658 the previous symbol: RHS[0] (always defined). */
2659
2660#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2661#ifndef YYLLOC_DEFAULT
2662# define YYLLOC_DEFAULT(Current, Rhs, N) \
2663 do \
2664 if (YYID (N)) \
2665 { \
2666 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2667 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2668 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2669 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2670 } \
2671 else \
2672 { \
2673 (Current).first_line = (Current).last_line = \
2674 YYRHSLOC (Rhs, 0).last_line; \
2675 (Current).first_column = (Current).last_column = \
2676 YYRHSLOC (Rhs, 0).last_column; \
2677 } \
2678 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002679#endif
2680
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002681
2682/* YY_LOCATION_PRINT -- Print the location on the stream.
2683 This macro was not mandated originally: define only if we know
2684 we won't break user code: when these are the locations we know. */
2685
2686#ifndef YY_LOCATION_PRINT
2687# if YYLTYPE_IS_TRIVIAL
2688# define YY_LOCATION_PRINT(File, Loc) \
2689 fprintf (File, "%d.%d-%d.%d", \
2690 (Loc).first_line, (Loc).first_column, \
2691 (Loc).last_line, (Loc).last_column)
2692# else
2693# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2694# endif
2695#endif
2696
2697
2698/* YYLEX -- calling `yylex' with the right arguments. */
2699
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700#ifdef YYLEX_PARAM
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002701# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002703# define YYLEX yylex ()
Dale Johannesen3afee192007-09-07 21:07:57 +00002704#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002705
2706/* Enable debugging if requested. */
2707#if YYDEBUG
2708
2709# ifndef YYFPRINTF
2710# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2711# define YYFPRINTF fprintf
2712# endif
2713
2714# define YYDPRINTF(Args) \
2715do { \
2716 if (yydebug) \
2717 YYFPRINTF Args; \
2718} while (YYID (0))
2719
2720# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2721do { \
2722 if (yydebug) \
2723 { \
2724 YYFPRINTF (stderr, "%s ", Title); \
2725 yy_symbol_print (stderr, \
2726 Type, Value); \
2727 YYFPRINTF (stderr, "\n"); \
2728 } \
2729} while (YYID (0))
2730
2731
2732/*--------------------------------.
2733| Print this symbol on YYOUTPUT. |
2734`--------------------------------*/
2735
2736/*ARGSUSED*/
2737#if (defined __STDC__ || defined __C99__FUNC__ \
2738 || defined __cplusplus || defined _MSC_VER)
2739static void
2740yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Dale Johannesen3afee192007-09-07 21:07:57 +00002741#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002742static void
2743yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2744 FILE *yyoutput;
2745 int yytype;
2746 YYSTYPE const * const yyvaluep;
Dale Johannesen3afee192007-09-07 21:07:57 +00002747#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002748{
2749 if (!yyvaluep)
2750 return;
2751# ifdef YYPRINT
2752 if (yytype < YYNTOKENS)
2753 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2754# else
2755 YYUSE (yyoutput);
2756# endif
2757 switch (yytype)
2758 {
2759 default:
2760 break;
2761 }
2762}
2763
2764
2765/*--------------------------------.
2766| Print this symbol on YYOUTPUT. |
2767`--------------------------------*/
2768
2769#if (defined __STDC__ || defined __C99__FUNC__ \
2770 || defined __cplusplus || defined _MSC_VER)
2771static void
2772yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2773#else
2774static void
2775yy_symbol_print (yyoutput, yytype, yyvaluep)
2776 FILE *yyoutput;
2777 int yytype;
2778 YYSTYPE const * const yyvaluep;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002779#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002780{
2781 if (yytype < YYNTOKENS)
2782 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2783 else
2784 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
David Greene48556392007-09-04 18:46:50 +00002785
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002786 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2787 YYFPRINTF (yyoutput, ")");
2788}
David Greene48556392007-09-04 18:46:50 +00002789
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002790/*------------------------------------------------------------------.
2791| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2792| TOP (included). |
2793`------------------------------------------------------------------*/
David Greene48556392007-09-04 18:46:50 +00002794
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002795#if (defined __STDC__ || defined __C99__FUNC__ \
2796 || defined __cplusplus || defined _MSC_VER)
2797static void
2798yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2799#else
2800static void
2801yy_stack_print (bottom, top)
2802 yytype_int16 *bottom;
2803 yytype_int16 *top;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002804#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002805{
2806 YYFPRINTF (stderr, "Stack now");
2807 for (; bottom <= top; ++bottom)
2808 YYFPRINTF (stderr, " %d", *bottom);
2809 YYFPRINTF (stderr, "\n");
2810}
David Greene48556392007-09-04 18:46:50 +00002811
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002812# define YY_STACK_PRINT(Bottom, Top) \
2813do { \
2814 if (yydebug) \
2815 yy_stack_print ((Bottom), (Top)); \
2816} while (YYID (0))
David Greene48556392007-09-04 18:46:50 +00002817
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002818
2819/*------------------------------------------------.
2820| Report that the YYRULE is going to be reduced. |
2821`------------------------------------------------*/
2822
2823#if (defined __STDC__ || defined __C99__FUNC__ \
2824 || defined __cplusplus || defined _MSC_VER)
2825static void
2826yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2827#else
2828static void
2829yy_reduce_print (yyvsp, yyrule)
2830 YYSTYPE *yyvsp;
2831 int yyrule;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002832#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002833{
2834 int yynrhs = yyr2[yyrule];
2835 int yyi;
2836 unsigned long int yylno = yyrline[yyrule];
2837 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2838 yyrule - 1, yylno);
2839 /* The symbols being reduced. */
2840 for (yyi = 0; yyi < yynrhs; yyi++)
2841 {
2842 fprintf (stderr, " $%d = ", yyi + 1);
2843 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2844 &(yyvsp[(yyi + 1) - (yynrhs)])
2845 );
2846 fprintf (stderr, "\n");
2847 }
2848}
Chandler Carruth563d4a42007-08-04 01:56:21 +00002849
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002850# define YY_REDUCE_PRINT(Rule) \
2851do { \
2852 if (yydebug) \
2853 yy_reduce_print (yyvsp, Rule); \
2854} while (YYID (0))
Chandler Carruth563d4a42007-08-04 01:56:21 +00002855
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002856/* Nonzero means print parse trace. It is left uninitialized so that
2857 multiple parsers can coexist. */
2858int yydebug;
2859#else /* !YYDEBUG */
2860# define YYDPRINTF(Args)
2861# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2862# define YY_STACK_PRINT(Bottom, Top)
2863# define YY_REDUCE_PRINT(Rule)
2864#endif /* !YYDEBUG */
2865
2866
2867/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868#ifndef YYINITDEPTH
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002869# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870#endif
2871
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002872/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2873 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002875 Do not make this value too large; the results are undefined if
2876 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2877 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002878
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879#ifndef YYMAXDEPTH
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002880# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002882
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002885#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002887# ifndef yystrlen
2888# if defined __GLIBC__ && defined _STRING_H
2889# define yystrlen strlen
2890# else
2891/* Return the length of YYSTR. */
2892#if (defined __STDC__ || defined __C99__FUNC__ \
2893 || defined __cplusplus || defined _MSC_VER)
2894static YYSIZE_T
2895yystrlen (const char *yystr)
Dale Johannesen3afee192007-09-07 21:07:57 +00002896#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002897static YYSIZE_T
2898yystrlen (yystr)
2899 const char *yystr;
2900#endif
2901{
2902 YYSIZE_T yylen;
2903 for (yylen = 0; yystr[yylen]; yylen++)
2904 continue;
2905 return yylen;
2906}
2907# endif
2908# endif
2909
2910# ifndef yystpcpy
2911# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2912# define yystpcpy stpcpy
2913# else
2914/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2915 YYDEST. */
2916#if (defined __STDC__ || defined __C99__FUNC__ \
2917 || defined __cplusplus || defined _MSC_VER)
2918static char *
2919yystpcpy (char *yydest, const char *yysrc)
2920#else
2921static char *
2922yystpcpy (yydest, yysrc)
2923 char *yydest;
2924 const char *yysrc;
2925#endif
2926{
2927 char *yyd = yydest;
2928 const char *yys = yysrc;
2929
2930 while ((*yyd++ = *yys++) != '\0')
2931 continue;
2932
2933 return yyd - 1;
2934}
2935# endif
2936# endif
2937
2938# ifndef yytnamerr
2939/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2940 quotes and backslashes, so that it's suitable for yyerror. The
2941 heuristic is that double-quoting is unnecessary unless the string
2942 contains an apostrophe, a comma, or backslash (other than
2943 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2944 null, do not copy; instead, return the length of what the result
2945 would have been. */
2946static YYSIZE_T
2947yytnamerr (char *yyres, const char *yystr)
2948{
2949 if (*yystr == '"')
2950 {
2951 YYSIZE_T yyn = 0;
2952 char const *yyp = yystr;
2953
2954 for (;;)
2955 switch (*++yyp)
2956 {
2957 case '\'':
2958 case ',':
2959 goto do_not_strip_quotes;
2960
2961 case '\\':
2962 if (*++yyp != '\\')
2963 goto do_not_strip_quotes;
2964 /* Fall through. */
2965 default:
2966 if (yyres)
2967 yyres[yyn] = *yyp;
2968 yyn++;
2969 break;
2970
2971 case '"':
2972 if (yyres)
2973 yyres[yyn] = '\0';
2974 return yyn;
2975 }
2976 do_not_strip_quotes: ;
2977 }
2978
2979 if (! yyres)
2980 return yystrlen (yystr);
2981
2982 return yystpcpy (yyres, yystr) - yyres;
2983}
2984# endif
2985
2986/* Copy into YYRESULT an error message about the unexpected token
2987 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2988 including the terminating null byte. If YYRESULT is null, do not
2989 copy anything; just return the number of bytes that would be
2990 copied. As a special case, return 0 if an ordinary "syntax error"
2991 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2992 size calculation. */
2993static YYSIZE_T
2994yysyntax_error (char *yyresult, int yystate, int yychar)
2995{
2996 int yyn = yypact[yystate];
2997
2998 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2999 return 0;
3000 else
3001 {
3002 int yytype = YYTRANSLATE (yychar);
3003 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3004 YYSIZE_T yysize = yysize0;
3005 YYSIZE_T yysize1;
3006 int yysize_overflow = 0;
3007 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3008 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3009 int yyx;
3010
3011# if 0
3012 /* This is so xgettext sees the translatable formats that are
3013 constructed on the fly. */
3014 YY_("syntax error, unexpected %s");
3015 YY_("syntax error, unexpected %s, expecting %s");
3016 YY_("syntax error, unexpected %s, expecting %s or %s");
3017 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3018 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3019# endif
3020 char *yyfmt;
3021 char const *yyf;
3022 static char const yyunexpected[] = "syntax error, unexpected %s";
3023 static char const yyexpecting[] = ", expecting %s";
3024 static char const yyor[] = " or %s";
3025 char yyformat[sizeof yyunexpected
3026 + sizeof yyexpecting - 1
3027 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3028 * (sizeof yyor - 1))];
3029 char const *yyprefix = yyexpecting;
3030
3031 /* Start YYX at -YYN if negative to avoid negative indexes in
3032 YYCHECK. */
3033 int yyxbegin = yyn < 0 ? -yyn : 0;
3034
3035 /* Stay within bounds of both yycheck and yytname. */
3036 int yychecklim = YYLAST - yyn + 1;
3037 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3038 int yycount = 1;
3039
3040 yyarg[0] = yytname[yytype];
3041 yyfmt = yystpcpy (yyformat, yyunexpected);
3042
3043 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3044 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3045 {
3046 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3047 {
3048 yycount = 1;
3049 yysize = yysize0;
3050 yyformat[sizeof yyunexpected - 1] = '\0';
3051 break;
3052 }
3053 yyarg[yycount++] = yytname[yyx];
3054 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3055 yysize_overflow |= (yysize1 < yysize);
3056 yysize = yysize1;
3057 yyfmt = yystpcpy (yyfmt, yyprefix);
3058 yyprefix = yyor;
3059 }
3060
3061 yyf = YY_(yyformat);
3062 yysize1 = yysize + yystrlen (yyf);
3063 yysize_overflow |= (yysize1 < yysize);
3064 yysize = yysize1;
3065
3066 if (yysize_overflow)
3067 return YYSIZE_MAXIMUM;
3068
3069 if (yyresult)
3070 {
3071 /* Avoid sprintf, as that infringes on the user's name space.
3072 Don't have undefined behavior even if the translation
3073 produced a string with the wrong number of "%s"s. */
3074 char *yyp = yyresult;
3075 int yyi = 0;
3076 while ((*yyp = *yyf) != '\0')
3077 {
3078 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3079 {
3080 yyp += yytnamerr (yyp, yyarg[yyi++]);
3081 yyf += 2;
3082 }
3083 else
3084 {
3085 yyp++;
3086 yyf++;
3087 }
3088 }
3089 }
3090 return yysize;
3091 }
3092}
3093#endif /* YYERROR_VERBOSE */
3094
3095
3096/*-----------------------------------------------.
3097| Release the memory associated to this symbol. |
3098`-----------------------------------------------*/
3099
3100/*ARGSUSED*/
3101#if (defined __STDC__ || defined __C99__FUNC__ \
3102 || defined __cplusplus || defined _MSC_VER)
3103static void
3104yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3105#else
3106static void
3107yydestruct (yymsg, yytype, yyvaluep)
3108 const char *yymsg;
3109 int yytype;
3110 YYSTYPE *yyvaluep;
3111#endif
3112{
3113 YYUSE (yyvaluep);
3114
3115 if (!yymsg)
3116 yymsg = "Deleting";
3117 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3118
3119 switch (yytype)
3120 {
3121
3122 default:
3123 break;
3124 }
3125}
3126
3127
3128/* Prevent warnings from -Wmissing-prototypes. */
3129
3130#ifdef YYPARSE_PARAM
3131#if defined __STDC__ || defined __cplusplus
3132int yyparse (void *YYPARSE_PARAM);
3133#else
3134int yyparse ();
3135#endif
3136#else /* ! YYPARSE_PARAM */
3137#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003138int yyparse (void);
Dale Johannesen3afee192007-09-07 21:07:57 +00003139#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003140int yyparse ();
Dale Johannesen3afee192007-09-07 21:07:57 +00003141#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003142#endif /* ! YYPARSE_PARAM */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003143
Chandler Carruth563d4a42007-08-04 01:56:21 +00003144
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003145
3146/* The look-ahead symbol. */
3147int yychar;
3148
3149/* The semantic value of the look-ahead symbol. */
3150YYSTYPE yylval;
3151
3152/* Number of syntax errors so far. */
3153int yynerrs;
3154
3155
3156
3157/*----------.
3158| yyparse. |
3159`----------*/
3160
3161#ifdef YYPARSE_PARAM
3162#if (defined __STDC__ || defined __C99__FUNC__ \
3163 || defined __cplusplus || defined _MSC_VER)
3164int
3165yyparse (void *YYPARSE_PARAM)
3166#else
3167int
3168yyparse (YYPARSE_PARAM)
3169 void *YYPARSE_PARAM;
3170#endif
3171#else /* ! YYPARSE_PARAM */
3172#if (defined __STDC__ || defined __C99__FUNC__ \
3173 || defined __cplusplus || defined _MSC_VER)
3174int
3175yyparse (void)
3176#else
3177int
3178yyparse ()
3179
Dale Johannesen3afee192007-09-07 21:07:57 +00003180#endif
3181#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003182{
3183
3184 int yystate;
3185 int yyn;
3186 int yyresult;
3187 /* Number of tokens to shift before error messages enabled. */
3188 int yyerrstatus;
3189 /* Look-ahead token as an internal (translated) token number. */
3190 int yytoken = 0;
3191#if YYERROR_VERBOSE
3192 /* Buffer for error messages, and its allocated size. */
3193 char yymsgbuf[128];
3194 char *yymsg = yymsgbuf;
3195 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Dale Johannesen3afee192007-09-07 21:07:57 +00003196#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00003197
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003198 /* Three stacks and their tools:
3199 `yyss': related to states,
3200 `yyvs': related to semantic values,
3201 `yyls': related to locations.
3202
3203 Refer to the stacks thru separate pointers, to allow yyoverflow
3204 to reallocate them elsewhere. */
3205
3206 /* The state stack. */
3207 yytype_int16 yyssa[YYINITDEPTH];
3208 yytype_int16 *yyss = yyssa;
3209 yytype_int16 *yyssp;
3210
3211 /* The semantic value stack. */
3212 YYSTYPE yyvsa[YYINITDEPTH];
3213 YYSTYPE *yyvs = yyvsa;
3214 YYSTYPE *yyvsp;
3215
3216
3217
3218#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3219
3220 YYSIZE_T yystacksize = YYINITDEPTH;
3221
3222 /* The variables used to return semantic value and location from the
3223 action routines. */
3224 YYSTYPE yyval;
3225
3226
3227 /* The number of symbols on the RHS of the reduced rule.
3228 Keep to zero when no symbol should be popped. */
3229 int yylen = 0;
3230
3231 YYDPRINTF ((stderr, "Starting parse\n"));
3232
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003233 yystate = 0;
3234 yyerrstatus = 0;
3235 yynerrs = 0;
3236 yychar = YYEMPTY; /* Cause a token to be read. */
3237
3238 /* Initialize stack pointers.
3239 Waste one element of value and location stack
3240 so that they stay on the same level as the state stack.
3241 The wasted elements are never initialized. */
3242
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003243 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003244 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003245
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003246 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003248/*------------------------------------------------------------.
3249| yynewstate -- Push a new state, which is found in yystate. |
3250`------------------------------------------------------------*/
3251 yynewstate:
3252 /* In all cases, when you get here, the value and location stacks
3253 have just been pushed. So pushing a state here evens the stacks. */
3254 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003256 yysetstate:
3257 *yyssp = yystate;
3258
3259 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003260 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003262 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003263
3264#ifdef yyoverflow
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003265 {
3266 /* Give user a chance to reallocate the stack. Use copies of
3267 these so that the &'s don't force the real ones into
3268 memory. */
3269 YYSTYPE *yyvs1 = yyvs;
3270 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003272
3273 /* Each stack pointer address is followed by the size of the
3274 data in use in that stack, in bytes. This used to be a
3275 conditional around just the two extra args, but that might
3276 be undefined if yyoverflow is a macro. */
3277 yyoverflow (YY_("memory exhausted"),
3278 &yyss1, yysize * sizeof (*yyssp),
3279 &yyvs1, yysize * sizeof (*yyvsp),
3280
3281 &yystacksize);
3282
3283 yyss = yyss1;
3284 yyvs = yyvs1;
3285 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286#else /* no yyoverflow */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003287# ifndef YYSTACK_RELOCATE
3288 goto yyexhaustedlab;
3289# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 /* Extend the stack our own way. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003291 if (YYMAXDEPTH <= yystacksize)
3292 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 yystacksize *= 2;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003294 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 yystacksize = YYMAXDEPTH;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003296
3297 {
3298 yytype_int16 *yyss1 = yyss;
3299 union yyalloc *yyptr =
3300 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3301 if (! yyptr)
3302 goto yyexhaustedlab;
3303 YYSTACK_RELOCATE (yyss);
3304 YYSTACK_RELOCATE (yyvs);
3305
3306# undef YYSTACK_RELOCATE
3307 if (yyss1 != yyssa)
3308 YYSTACK_FREE (yyss1);
3309 }
3310# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311#endif /* no yyoverflow */
3312
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003313 yyssp = yyss + yysize - 1;
3314 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003316
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003317 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3318 (unsigned long int) yystacksize));
3319
3320 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321 YYABORT;
3322 }
3323
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003324 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325
3326 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003328/*-----------.
3329| yybackup. |
3330`-----------*/
3331yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003333 /* Do appropriate processing given the current state. Read a
3334 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003335
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003336 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 yyn = yypact[yystate];
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003338 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 goto yydefault;
3340
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003341 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003342
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003343 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344 if (yychar == YYEMPTY)
3345 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003346 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003347 yychar = YYLEX;
3348 }
3349
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003350 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003352 yychar = yytoken = YYEOF;
3353 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354 }
3355 else
3356 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003357 yytoken = YYTRANSLATE (yychar);
3358 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003359 }
3360
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003361 /* If the proper action on seeing token YYTOKEN is to reduce or to
3362 detect an error, take that action. */
3363 yyn += yytoken;
3364 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 yyn = yytable[yyn];
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003367 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003368 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003369 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 goto yyerrlab;
3371 yyn = -yyn;
3372 goto yyreduce;
3373 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374
3375 if (yyn == YYFINAL)
3376 YYACCEPT;
3377
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003378 /* Count tokens shifted since error; after three, turn off error
3379 status. */
3380 if (yyerrstatus)
3381 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003382
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003383 /* Shift the look-ahead token. */
3384 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003385
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003386 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387 if (yychar != YYEOF)
3388 yychar = YYEMPTY;
3389
Chris Lattnerbb856a32007-08-06 21:00:46 +00003390 yystate = yyn;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003391 *++yyvsp = yylval;
3392
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 goto yynewstate;
3394
Dale Johannesen3afee192007-09-07 21:07:57 +00003395
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003396/*-----------------------------------------------------------.
3397| yydefault -- do the default action for the current state. |
3398`-----------------------------------------------------------*/
3399yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003400 yyn = yydefact[yystate];
3401 if (yyn == 0)
3402 goto yyerrlab;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003403 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003405
3406/*-----------------------------.
3407| yyreduce -- Do a reduction. |
3408`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003409yyreduce:
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003410 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003411 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003413 /* If YYLEN is nonzero, implement the default value of the action:
3414 `$$ = $1'.
3415
3416 Otherwise, the following line sets YYVAL to garbage.
3417 This behavior is undocumented and Bison
3418 users should not rely upon it. Assigning to YYVAL
3419 unconditionally makes the parser a bit smaller, and it avoids a
3420 GCC warning that YYVAL may be used uninitialized. */
3421 yyval = yyvsp[1-yylen];
3422
3423
3424 YY_REDUCE_PRINT (yyn);
3425 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003426 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003427 case 29:
3428#line 1134 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3429 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3430 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003431
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003432 case 30:
3433#line 1134 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3434 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3435 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003437 case 31:
3438#line 1135 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3439 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3440 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003441
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003442 case 32:
3443#line 1135 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3444 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3445 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003446
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003447 case 33:
3448#line 1136 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3449 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3450 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003452 case 34:
3453#line 1136 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3454 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3455 break;
3456
3457 case 35:
3458#line 1137 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3459 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3460 break;
3461
3462 case 36:
3463#line 1137 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3464 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3465 break;
3466
3467 case 37:
3468#line 1138 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3469 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3470 break;
3471
3472 case 38:
3473#line 1138 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3474 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3475 break;
3476
3477 case 39:
3478#line 1142 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3479 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3480 break;
3481
3482 case 40:
3483#line 1142 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3484 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3485 break;
3486
3487 case 41:
3488#line 1143 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3489 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3490 break;
3491
3492 case 42:
3493#line 1143 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3494 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3495 break;
3496
3497 case 43:
3498#line 1144 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3499 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3500 break;
3501
3502 case 44:
3503#line 1144 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3504 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3505 break;
3506
3507 case 45:
3508#line 1145 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3509 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3510 break;
3511
3512 case 46:
3513#line 1145 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3514 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3515 break;
3516
3517 case 47:
3518#line 1146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3519 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3520 break;
3521
3522 case 48:
3523#line 1146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3524 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3525 break;
3526
3527 case 49:
3528#line 1147 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3529 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3530 break;
3531
3532 case 50:
3533#line 1147 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3534 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3535 break;
3536
3537 case 51:
3538#line 1148 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3539 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3540 break;
3541
3542 case 52:
3543#line 1148 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3544 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3545 break;
3546
3547 case 53:
3548#line 1149 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3549 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3550 break;
3551
3552 case 54:
3553#line 1150 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3554 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3555 break;
3556
3557 case 65:
3558#line 1159 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3559 { (yyval.StrVal) = 0; ;}
3560 break;
3561
3562 case 66:
3563#line 1163 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3564 {
3565 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003566 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003567 ;}
3568 break;
3569
3570 case 67:
3571#line 1167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3572 {
3573 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003574 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003575 ;}
3576 break;
3577
3578 case 71:
3579#line 1175 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3580 {
3581 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003582 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003583 ;}
3584 break;
3585
3586 case 72:
3587#line 1180 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3588 {
3589 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003590 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003591 ;}
3592 break;
3593
3594 case 73:
3595#line 1186 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3596 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3597 break;
3598
3599 case 74:
3600#line 1187 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3601 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3602 break;
3603
3604 case 75:
3605#line 1188 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3606 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3607 break;
3608
3609 case 76:
3610#line 1189 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3611 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3612 break;
3613
3614 case 77:
3615#line 1190 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3616 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3617 break;
3618
3619 case 78:
3620#line 1194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3621 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3622 break;
3623
3624 case 79:
3625#line 1195 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3626 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3627 break;
3628
3629 case 80:
3630#line 1196 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3631 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3632 break;
3633
3634 case 81:
3635#line 1200 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3636 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3637 break;
3638
3639 case 82:
3640#line 1201 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3641 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3642 break;
3643
3644 case 83:
3645#line 1202 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3646 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3647 break;
3648
3649 case 84:
3650#line 1203 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3651 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3652 break;
3653
3654 case 85:
3655#line 1207 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3656 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3657 break;
3658
3659 case 86:
3660#line 1208 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3661 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3662 break;
3663
3664 case 87:
3665#line 1209 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3666 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3667 break;
3668
3669 case 88:
3670#line 1213 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3671 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3672 break;
3673
3674 case 89:
3675#line 1214 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3676 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3677 break;
3678
3679 case 90:
3680#line 1215 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3681 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3682 break;
3683
3684 case 91:
3685#line 1216 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3686 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3687 break;
3688
3689 case 92:
3690#line 1217 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3691 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3692 break;
3693
3694 case 93:
3695#line 1221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3696 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3697 break;
3698
3699 case 94:
3700#line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3701 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3702 break;
3703
3704 case 95:
3705#line 1223 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3706 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3707 break;
3708
3709 case 96:
3710#line 1226 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3711 { (yyval.UIntVal) = CallingConv::C; ;}
3712 break;
3713
3714 case 97:
3715#line 1227 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3716 { (yyval.UIntVal) = CallingConv::C; ;}
3717 break;
3718
3719 case 98:
3720#line 1228 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3721 { (yyval.UIntVal) = CallingConv::Fast; ;}
3722 break;
3723
3724 case 99:
3725#line 1229 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3726 { (yyval.UIntVal) = CallingConv::Cold; ;}
3727 break;
3728
3729 case 100:
3730#line 1230 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3731 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3732 break;
3733
3734 case 101:
3735#line 1231 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3736 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3737 break;
3738
3739 case 102:
3740#line 1232 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3741 {
3742 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003743 GEN_ERROR("Calling conv too large");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003744 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003745 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003746 ;}
3747 break;
3748
3749 case 103:
3750#line 1239 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3751 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3752 break;
3753
3754 case 104:
3755#line 1240 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3756 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3757 break;
3758
3759 case 105:
3760#line 1241 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3761 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3762 break;
3763
3764 case 106:
3765#line 1242 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3766 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3767 break;
3768
3769 case 107:
3770#line 1243 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3771 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3772 break;
3773
3774 case 108:
3775#line 1244 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3776 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3777 break;
3778
3779 case 109:
3780#line 1245 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3781 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3782 break;
3783
3784 case 110:
3785#line 1246 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3786 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3787 break;
3788
3789 case 111:
3790#line 1247 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3791 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3792 break;
3793
3794 case 112:
3795#line 1250 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3796 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3797 break;
3798
3799 case 113:
3800#line 1251 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3801 {
3802 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3803 ;}
3804 break;
3805
3806 case 114:
3807#line 1256 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3808 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3809 break;
3810
3811 case 115:
3812#line 1257 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3813 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3814 break;
3815
3816 case 116:
3817#line 1258 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3818 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3819 break;
3820
3821 case 117:
3822#line 1259 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3823 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3824 break;
3825
3826 case 118:
3827#line 1260 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3828 { (yyval.ParamAttrs) = ParamAttr::Pure; ;}
3829 break;
3830
3831 case 119:
3832#line 1261 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3833 { (yyval.ParamAttrs) = ParamAttr::Const; ;}
3834 break;
3835
3836 case 120:
3837#line 1264 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3838 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3839 break;
3840
3841 case 121:
3842#line 1265 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3843 {
3844 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3845 ;}
3846 break;
3847
3848 case 122:
3849#line 1272 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3850 { (yyval.UIntVal) = 0; ;}
3851 break;
3852
3853 case 123:
3854#line 1273 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3855 {
3856 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3857 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003858 GEN_ERROR("Alignment must be a power of two");
3859 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003860;}
3861 break;
3862
3863 case 124:
3864#line 1279 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3865 { (yyval.UIntVal) = 0; ;}
3866 break;
3867
3868 case 125:
3869#line 1280 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3870 {
3871 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3872 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003873 GEN_ERROR("Alignment must be a power of two");
3874 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003875;}
3876 break;
3877
3878 case 126:
3879#line 1288 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3880 {
3881 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3882 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003883 GEN_ERROR("Invalid character in section name");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003884 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003885 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003886;}
3887 break;
3888
3889 case 127:
3890#line 1296 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3891 { (yyval.StrVal) = 0; ;}
3892 break;
3893
3894 case 128:
3895#line 1297 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3896 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3897 break;
3898
3899 case 129:
3900#line 1302 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3901 {;}
3902 break;
3903
3904 case 130:
3905#line 1303 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3906 {;}
3907 break;
3908
3909 case 131:
3910#line 1304 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3911 {
3912 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3913 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003914 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003915 ;}
3916 break;
3917
3918 case 132:
3919#line 1309 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3920 {
3921 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003922 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003923 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003924 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003925 ;}
3926 break;
3927
3928 case 140:
3929#line 1325 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3930 {
3931 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003933 ;}
3934 break;
3935
3936 case 141:
3937#line 1329 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3938 {
3939 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003940 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003941 ;}
3942 break;
3943
3944 case 142:
3945#line 1333 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3946 { // Pointer type?
3947 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003949 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3950 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003951 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003952 ;}
3953 break;
3954
3955 case 143:
3956#line 1340 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3957 { // Named types are also simple types...
3958 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003959 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003960 (yyval.TypeVal) = new PATypeHolder(tmp);
3961 ;}
3962 break;
3963
3964 case 144:
3965#line 1345 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3966 { // Type UpReference
3967 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003968 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003969 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3970 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003971 UR_OUT("New Upreference!\n");
3972 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003973 ;}
3974 break;
3975
3976 case 145:
3977#line 1353 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
3978 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003979 std::vector<const Type*> Params;
3980 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003981 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3982 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003983 Attrs.push_back(X);
3984 }
3985 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003986 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003987 for (; I != E; ++I, ++index) {
3988 const Type *Ty = I->Ty->get();
3989 Params.push_back(Ty);
3990 if (Ty != Type::VoidTy)
3991 if (I->Attrs != ParamAttr::None) {
3992 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3993 Attrs.push_back(X);
3994 }
3995 }
3996 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3997 if (isVarArg) Params.pop_back();
3998
3999 ParamAttrsList *ActualAttrs = 0;
4000 if (!Attrs.empty())
4001 ActualAttrs = ParamAttrsList::get(Attrs);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004002 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
4003 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4004 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4005 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004006 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004007 ;}
4008 break;
4009
4010 case 146:
4011#line 1383 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4012 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004013 std::vector<const Type*> Params;
4014 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004015 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
4016 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004017 Attrs.push_back(X);
4018 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004019 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004020 unsigned index = 1;
4021 for ( ; I != E; ++I, ++index) {
4022 const Type* Ty = I->Ty->get();
4023 Params.push_back(Ty);
4024 if (Ty != Type::VoidTy)
4025 if (I->Attrs != ParamAttr::None) {
4026 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
4027 Attrs.push_back(X);
4028 }
4029 }
4030 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4031 if (isVarArg) Params.pop_back();
4032
4033 ParamAttrsList *ActualAttrs = 0;
4034 if (!Attrs.empty())
4035 ActualAttrs = ParamAttrsList::get(Attrs);
4036
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004037 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
4038 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4039 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004040 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004041 ;}
4042 break;
4043
4044 case 147:
4045#line 1414 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4046 { // Sized array type?
4047 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4048 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004049 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004050 ;}
4051 break;
4052
4053 case 148:
4054#line 1419 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4055 { // Vector type?
4056 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4057 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004058 GEN_ERROR("Unsigned result not equal to signed result");
4059 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4060 GEN_ERROR("Element type of a VectorType must be primitive");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004061 if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004062 GEN_ERROR("Vector length should be a power of 2");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004063 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4064 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004065 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004066 ;}
4067 break;
4068
4069 case 149:
4070#line 1431 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4071 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004072 std::vector<const Type*> Elements;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004073 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4074 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004075 Elements.push_back(*I);
4076
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004077 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4078 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004079 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004080 ;}
4081 break;
4082
4083 case 150:
4084#line 1441 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4085 { // Empty structure type?
4086 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004087 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004088 ;}
4089 break;
4090
4091 case 151:
4092#line 1445 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4093 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004094 std::vector<const Type*> Elements;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004095 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4096 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004097 Elements.push_back(*I);
4098
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004099 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4100 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004101 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004102 ;}
4103 break;
4104
4105 case 152:
4106#line 1455 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4107 { // Empty structure type?
4108 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004109 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004110 ;}
4111 break;
4112
4113 case 153:
4114#line 1462 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4115 {
4116 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4117 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
4118 ;}
4119 break;
4120
4121 case 154:
4122#line 1469 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4123 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004124 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004125 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4126 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004127 GEN_ERROR("LLVM functions cannot return aggregate types");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004128 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4129 ;}
4130 break;
4131
4132 case 155:
4133#line 1476 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4134 {
4135 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4136 ;}
4137 break;
4138
4139 case 156:
4140#line 1481 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4141 {
4142 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4143 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004144 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004145 ;}
4146 break;
4147
4148 case 157:
4149#line 1486 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4150 {
4151 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004152 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004153 ;}
4154 break;
4155
4156 case 159:
4157#line 1494 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4158 {
4159 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004160 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4161 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004162 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004163 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004164 ;}
4165 break;
4166
4167 case 160:
4168#line 1501 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4169 {
4170 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004171 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4172 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004173 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004174 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004175 ;}
4176 break;
4177
4178 case 161:
4179#line 1508 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4180 {
4181 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004182 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004183 ;}
4184 break;
4185
4186 case 162:
4187#line 1516 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4188 {
4189 (yyval.TypeList) = new std::list<PATypeHolder>();
4190 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4191 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004192 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004193 ;}
4194 break;
4195
4196 case 163:
4197#line 1522 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4198 {
4199 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4200 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004201 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004202 ;}
4203 break;
4204
4205 case 164:
4206#line 1534 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4207 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004208 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004209 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4210 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004211 if (ATy == 0)
4212 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004213 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004214 const Type *ETy = ATy->getElementType();
4215 int NumElements = ATy->getNumElements();
4216
4217 // Verify that we have the correct size...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004218 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004219 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004220 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004221 itostr(NumElements) + "");
4222
4223 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004224 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4225 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004226 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4227 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004228 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004229 }
4230
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004231 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4232 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004233 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004234 ;}
4235 break;
4236
4237 case 165:
4238#line 1562 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4239 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004240 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004241 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4242 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004243 if (ATy == 0)
4244 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004245 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004246
4247 int NumElements = ATy->getNumElements();
4248 if (NumElements != -1 && NumElements != 0)
4249 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4250 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004251 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4252 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004253 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004254 ;}
4255 break;
4256
4257 case 166:
4258#line 1578 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4259 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004260 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004261 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4262 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263 if (ATy == 0)
4264 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004265 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004266
4267 int NumElements = ATy->getNumElements();
4268 const Type *ETy = ATy->getElementType();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004269 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004271 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004272 " when array has size " + itostr(NumElements) + "");
4273 std::vector<Constant*> Vals;
4274 if (ETy == Type::Int8Ty) {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004275 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4276 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277 } else {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004278 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004279 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4280 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004281 delete (yyvsp[(3) - (3)].StrVal);
4282 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4283 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004284 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004285 ;}
4286 break;
4287
4288 case 167:
4289#line 1605 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4290 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004291 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004292 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4293 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004294 if (PTy == 0)
4295 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004296 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004297 const Type *ETy = PTy->getElementType();
4298 int NumElements = PTy->getNumElements();
4299
4300 // Verify that we have the correct size...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004301 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004302 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004303 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004304 itostr(NumElements) + "");
4305
4306 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004307 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4308 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004309 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4310 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004311 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004312 }
4313
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004314 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4315 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004316 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004317 ;}
4318 break;
4319
4320 case 168:
4321#line 1633 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4322 {
4323 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004324 if (STy == 0)
4325 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004326 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004327
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004328 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004329 GEN_ERROR("Illegal number of initializers for structure type");
4330
4331 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004332 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4333 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004334 GEN_ERROR("Expected type '" +
4335 STy->getElementType(i)->getDescription() +
4336 "' for element #" + utostr(i) +
4337 " of structure initializer");
4338
4339 // Check to ensure that Type is not packed
4340 if (STy->isPacked())
4341 GEN_ERROR("Unpacked Initializer to vector type '" +
4342 STy->getDescription() + "'");
4343
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004344 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4345 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004346 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004347 ;}
4348 break;
4349
4350 case 169:
4351#line 1659 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4352 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004353 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004354 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4355 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004356 if (STy == 0)
4357 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004358 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004359
4360 if (STy->getNumContainedTypes() != 0)
4361 GEN_ERROR("Illegal number of initializers for structure type");
4362
4363 // Check to ensure that Type is not packed
4364 if (STy->isPacked())
4365 GEN_ERROR("Unpacked Initializer to vector type '" +
4366 STy->getDescription() + "'");
4367
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004368 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4369 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004370 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004371 ;}
4372 break;
4373
4374 case 170:
4375#line 1679 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4376 {
4377 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004378 if (STy == 0)
4379 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004380 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004381
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004382 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004383 GEN_ERROR("Illegal number of initializers for structure type");
4384
4385 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004386 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4387 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004388 GEN_ERROR("Expected type '" +
4389 STy->getElementType(i)->getDescription() +
4390 "' for element #" + utostr(i) +
4391 " of structure initializer");
4392
4393 // Check to ensure that Type is packed
4394 if (!STy->isPacked())
4395 GEN_ERROR("Vector initializer to non-vector type '" +
4396 STy->getDescription() + "'");
4397
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004398 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4399 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004400 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004401 ;}
4402 break;
4403
4404 case 171:
4405#line 1705 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4406 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004407 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004408 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4409 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004410 if (STy == 0)
4411 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004412 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004413
4414 if (STy->getNumContainedTypes() != 0)
4415 GEN_ERROR("Illegal number of initializers for structure type");
4416
4417 // Check to ensure that Type is packed
4418 if (!STy->isPacked())
4419 GEN_ERROR("Vector initializer to non-vector type '" +
4420 STy->getDescription() + "'");
4421
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004422 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4423 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004424 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004425 ;}
4426 break;
4427
4428 case 172:
4429#line 1725 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4430 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004431 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004432 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4433 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004434 if (PTy == 0)
4435 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004436 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004437
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004438 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4439 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004440 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004441 ;}
4442 break;
4443
4444 case 173:
4445#line 1737 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4446 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004447 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004448 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4449 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4450 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004451 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004452 ;}
4453 break;
4454
4455 case 174:
4456#line 1744 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4457 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004458 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004459 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4460 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004461 if (Ty == 0)
4462 GEN_ERROR("Global const reference must be a pointer type");
4463
4464 // ConstExprs can exist in the body of a function, thus creating
4465 // GlobalValues whenever they refer to a variable. Because we are in
4466 // the context of a function, getExistingVal will search the functions
4467 // symbol table instead of the module symbol table for the global symbol,
4468 // which throws things all off. To get around this, we just tell
4469 // getExistingVal that we are at global scope here.
4470 //
4471 Function *SavedCurFn = CurFun.CurrentFunction;
4472 CurFun.CurrentFunction = 0;
4473
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004474 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004475 CHECK_FOR_ERROR
4476
4477 CurFun.CurrentFunction = SavedCurFn;
4478
4479 // If this is an initializer for a constant pointer, which is referencing a
4480 // (currently) undefined variable, create a stub now that shall be replaced
4481 // in the future with the right type of variable.
4482 //
4483 if (V == 0) {
4484 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4485 const PointerType *PT = cast<PointerType>(Ty);
4486
4487 // First check to see if the forward references value is already created!
4488 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004489 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004490
4491 if (I != CurModule.GlobalRefs.end()) {
4492 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004493 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004494 } else {
4495 std::string Name;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004496 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4497 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4498 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004499 GEN_ERROR("Invalid reference to global");
4500
4501 // Create the forward referenced global.
4502 GlobalValue *GV;
4503 if (const FunctionType *FTy =
4504 dyn_cast<FunctionType>(PT->getElementType())) {
4505 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
4506 CurModule.CurrentModule);
4507 } else {
4508 GV = new GlobalVariable(PT->getElementType(), false,
4509 GlobalValue::ExternalWeakLinkage, 0,
4510 Name, CurModule.CurrentModule);
4511 }
4512
4513 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004514 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004515 V = GV;
4516 }
4517 }
4518
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004519 (yyval.ConstVal) = cast<GlobalValue>(V);
4520 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004521 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004522 ;}
4523 break;
4524
4525 case 175:
4526#line 1810 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4527 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004528 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004529 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4530 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004531 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004532 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4533 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4534 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004535 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004536 ;}
4537 break;
4538
4539 case 176:
4540#line 1820 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4541 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004542 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4544 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004545 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4546 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004547 (yyval.ConstVal) = Constant::getNullValue(Ty);
4548 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004549 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004550 ;}
4551 break;
4552
4553 case 177:
4554#line 1830 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4555 { // integral constants
4556 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004557 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004558 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004559 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004560 ;}
4561 break;
4562
4563 case 178:
4564#line 1836 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4565 { // arbitrary precision integer constants
4566 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4567 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004568 GEN_ERROR("Constant value does not fit in type");
4569 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004570 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4571 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4572 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004573 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004574 ;}
4575 break;
4576
4577 case 179:
4578#line 1846 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4579 { // integral constants
4580 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004581 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004582 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004583 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004584 ;}
4585 break;
4586
4587 case 180:
4588#line 1852 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4589 { // arbitrary precision integer constants
4590 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4591 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004592 GEN_ERROR("Constant value does not fit in type");
4593 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004594 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4595 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4596 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004597 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004598 ;}
4599 break;
4600
4601 case 181:
4602#line 1862 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4603 { // Boolean constants
4604 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4605 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004606 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004607 ;}
4608 break;
4609
4610 case 182:
4611#line 1867 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4612 { // Boolean constants
4613 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4614 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004615 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004616 ;}
4617 break;
4618
4619 case 183:
4620#line 1872 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4621 { // Floating point constants
4622 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004623 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004624 // Lexer has no type info, so builds all float and double FP constants
4625 // as double. Fix this here. Long double is done right.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004626 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4627 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4628 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal));
4629 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004630 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004631 ;}
4632 break;
4633
4634 case 184:
4635#line 1885 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4636 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004637 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004638 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4639 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4640 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4641 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004642 GEN_ERROR("invalid cast opcode for cast from '" +
4643 Val->getType()->getDescription() + "' to '" +
4644 DestTy->getDescription() + "'");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004645 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4646 delete (yyvsp[(5) - (6)].TypeVal);
4647 ;}
4648 break;
4649
4650 case 185:
4651#line 1897 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4652 {
4653 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004654 GEN_ERROR("GetElementPtr requires a pointer operand");
4655
4656 const Type *IdxTy =
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004657 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004658 true);
4659 if (!IdxTy)
4660 GEN_ERROR("Index list invalid for constant getelementptr");
4661
4662 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004663 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4664 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004665 IdxVec.push_back(C);
4666 else
4667 GEN_ERROR("Indices to constant getelementptr must be constants");
4668
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004669 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004670
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004671 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004672 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004673 ;}
4674 break;
4675
4676 case 186:
4677#line 1919 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4678 {
4679 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004680 GEN_ERROR("Select condition must be of boolean type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004681 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004682 GEN_ERROR("Select operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004683 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004684 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004685 ;}
4686 break;
4687
4688 case 187:
4689#line 1927 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4690 {
4691 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004692 GEN_ERROR("Binary operator types must match");
4693 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004694 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4695 ;}
4696 break;
4697
4698 case 188:
4699#line 1933 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4700 {
4701 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004702 GEN_ERROR("Logical operator types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004703 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4704 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4705 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004706 GEN_ERROR("Logical operator requires integral operands");
4707 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004708 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004709 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004710 ;}
4711 break;
4712
4713 case 189:
4714#line 1944 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4715 {
4716 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004717 GEN_ERROR("icmp operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004718 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4719 ;}
4720 break;
4721
4722 case 190:
4723#line 1949 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4724 {
4725 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004726 GEN_ERROR("fcmp operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004727 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4728 ;}
4729 break;
4730
4731 case 191:
4732#line 1954 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4733 {
4734 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004735 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004736 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004737 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004738 ;}
4739 break;
4740
4741 case 192:
4742#line 1960 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4743 {
4744 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004745 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004746 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004747 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004748 ;}
4749 break;
4750
4751 case 193:
4752#line 1966 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4753 {
4754 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004755 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004756 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004757 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004758 ;}
4759 break;
4760
4761 case 194:
4762#line 1975 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4763 {
4764 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004765 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004766 ;}
4767 break;
4768
4769 case 195:
4770#line 1979 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4771 {
4772 (yyval.ConstVector) = new std::vector<Constant*>();
4773 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004774 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004775 ;}
4776 break;
4777
4778 case 196:
4779#line 1987 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4780 { (yyval.BoolVal) = false; ;}
4781 break;
4782
4783 case 197:
4784#line 1987 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4785 { (yyval.BoolVal) = true; ;}
4786 break;
4787
4788 case 198:
4789#line 1990 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4790 { (yyval.BoolVal) = true; ;}
4791 break;
4792
4793 case 199:
4794#line 1990 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4795 { (yyval.BoolVal) = false; ;}
4796 break;
4797
4798 case 200:
4799#line 1993 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4800 {
4801 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4802 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00004803 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004804 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4805 if (!Aliasee)
4806 GEN_ERROR("Aliases can be created only to global values");
4807
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004808 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004809 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004810 delete (yyvsp[(1) - (2)].TypeVal);
4811 ;}
4812 break;
4813
4814 case 201:
4815#line 2005 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4816 {
4817 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4818 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4819 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004820 GEN_ERROR("invalid cast opcode for cast from '" +
4821 Val->getType()->getDescription() + "' to '" +
4822 DestTy->getDescription() + "'");
4823
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004824 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004825 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004826 delete (yyvsp[(5) - (6)].TypeVal);
4827 ;}
4828 break;
4829
4830 case 202:
4831#line 2026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4832 {
4833 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer47470022007-07-31 14:41:17 +00004834 CurModule.ModuleDone();
4835 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004836 ;}
4837 break;
4838
4839 case 203:
4840#line 2031 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4841 {
4842 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004843 CurModule.ModuleDone();
4844 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004845 ;}
4846 break;
4847
4848 case 206:
4849#line 2044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4850 { CurFun.isDeclare = false; ;}
4851 break;
4852
4853 case 207:
4854#line 2044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4855 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004856 CurFun.FunctionDone();
4857 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004858 ;}
4859 break;
4860
4861 case 208:
4862#line 2048 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4863 { CurFun.isDeclare = true; ;}
4864 break;
4865
4866 case 209:
4867#line 2048 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4868 {
Reid Spencer47470022007-07-31 14:41:17 +00004869 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004870 ;}
4871 break;
4872
4873 case 210:
4874#line 2051 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4875 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004876 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004877 ;}
4878 break;
4879
4880 case 211:
4881#line 2054 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4882 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004883 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004884 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004885 // Eagerly resolve types. This is not an optimization, this is a
4886 // requirement that is due to the fact that we could have this:
4887 //
4888 // %list = type { %list * }
4889 // %list = type { %list * } ; repeated type decl
4890 //
4891 // If types are not resolved eagerly, then the two types will not be
4892 // determined to be the same type!
4893 //
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004894 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004895
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004896 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004897 CHECK_FOR_ERROR
4898 // If this is a named type that is not a redefinition, add it to the slot
4899 // table.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004900 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004901 }
4902
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004903 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004904 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004905 ;}
4906 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004907
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004908 case 212:
4909#line 2078 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4910 {
4911 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4912
4913 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004914 CHECK_FOR_ERROR
4915 // If this is a named type that is not a redefinition, add it to the slot
4916 // table.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004917 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004918 }
4919 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004920 ;}
4921 break;
4922
4923 case 213:
4924#line 2089 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4925 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004926 /* "Externally Visible" Linkage */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004927 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004928 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004929 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4930 (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 +00004931 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004932 ;}
4933 break;
4934
4935 case 214:
4936#line 2096 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4937 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004938 CurGV = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004939 ;}
4940 break;
4941
4942 case 215:
4943#line 2100 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4944 {
4945 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004946 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004947 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 +00004948 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004949 ;}
4950 break;
4951
4952 case 216:
4953#line 2105 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4954 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004955 CurGV = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004956 ;}
4957 break;
4958
4959 case 217:
4960#line 2109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4961 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004962 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004963 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4964 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 +00004965 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004966 delete (yyvsp[(6) - (6)].TypeVal);
4967 ;}
4968 break;
4969
4970 case 218:
4971#line 2115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4972 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004973 CurGV = 0;
4974 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004975 ;}
4976 break;
4977
4978 case 219:
4979#line 2119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
4980 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004981 std::string Name;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004982 if ((yyvsp[(1) - (5)].StrVal)) {
4983 Name = *(yyvsp[(1) - (5)].StrVal);
4984 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004985 }
4986 if (Name.empty())
4987 GEN_ERROR("Alias name cannot be empty");
4988
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004989 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004990 if (Aliasee == 0)
4991 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
4992
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004993 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004994 CurModule.CurrentModule);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004995 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004996 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00004997
4998
4999 // If there was a forward reference of this alias, resolve it now.
5000
5001 ValID ID;
5002 if (!Name.empty())
5003 ID = ValID::createGlobalName(Name);
5004 else
5005 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5006
5007 if (GlobalValue *FWGV =
5008 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5009 // Replace uses of the fwdref with the actual alias.
5010 FWGV->replaceAllUsesWith(GA);
5011 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5012 GV->eraseFromParent();
5013 else
5014 cast<Function>(FWGV)->eraseFromParent();
5015 }
5016 ID.destroy();
5017
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005018 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005019 ;}
5020 break;
5021
5022 case 220:
5023#line 2159 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5024 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005025 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005026 ;}
5027 break;
5028
5029 case 221:
5030#line 2162 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5031 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005032 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005033 ;}
5034 break;
5035
5036 case 222:
5037#line 2168 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5038 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005039 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5040 if (AsmSoFar.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005041 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005042 else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005043 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5044 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005045 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005046;}
5047 break;
5048
5049 case 223:
5050#line 2178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5051 {
5052 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5053 delete (yyvsp[(3) - (3)].StrVal);
5054 ;}
5055 break;
5056
5057 case 224:
5058#line 2182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5059 {
5060 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5061 delete (yyvsp[(3) - (3)].StrVal);
5062 ;}
5063 break;
5064
5065 case 226:
5066#line 2189 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5067 {
5068 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5069 delete (yyvsp[(3) - (3)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005070 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005071 ;}
5072 break;
5073
5074 case 227:
5075#line 2194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5076 {
5077 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5078 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005079 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005080 ;}
5081 break;
5082
5083 case 228:
5084#line 2199 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5085 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005086 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005087 ;}
5088 break;
5089
5090 case 229:
5091#line 2208 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5092 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005093 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005094 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5095 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005096 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005097 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5098 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5099 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005100 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005101 ;}
5102 break;
5103
5104 case 230:
5105#line 2218 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5106 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005107 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005108 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5109 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005110 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005111 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5112 (yyval.ArgList) = new ArgListType;
5113 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005114 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005115 ;}
5116 break;
5117
5118 case 231:
5119#line 2229 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5120 {
5121 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005122 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005123 ;}
5124 break;
5125
5126 case 232:
5127#line 2233 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5128 {
5129 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005130 struct ArgListEntry E;
5131 E.Ty = new PATypeHolder(Type::VoidTy);
5132 E.Name = 0;
5133 E.Attrs = ParamAttr::None;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005134 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005135 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005136 ;}
5137 break;
5138
5139 case 233:
5140#line 2242 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5141 {
5142 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005143 struct ArgListEntry E;
5144 E.Ty = new PATypeHolder(Type::VoidTy);
5145 E.Name = 0;
5146 E.Attrs = ParamAttr::None;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005147 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005148 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005149 ;}
5150 break;
5151
5152 case 234:
5153#line 2251 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5154 {
5155 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005156 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005157 ;}
5158 break;
5159
5160 case 235:
5161#line 2257 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5162 {
5163 std::string FunctionName(*(yyvsp[(3) - (9)].StrVal));
5164 delete (yyvsp[(3) - (9)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005165
5166 // Check the function result for abstractness if this is a define. We should
5167 // have no abstract types at this point
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005168 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
5169 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005170
5171 std::vector<const Type*> ParamTypeList;
5172 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005173 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
5174 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005175 Attrs.push_back(PAWI);
5176 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005177 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005178 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005179 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005180 const Type* Ty = I->Ty->get();
5181 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5182 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5183 ParamTypeList.push_back(Ty);
5184 if (Ty != Type::VoidTy)
5185 if (I->Attrs != ParamAttr::None) {
5186 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5187 Attrs.push_back(PAWI);
5188 }
5189 }
5190 }
5191
5192 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5193 if (isVarArg) ParamTypeList.pop_back();
5194
5195 ParamAttrsList *PAL = 0;
5196 if (!Attrs.empty())
5197 PAL = ParamAttrsList::get(Attrs);
5198
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005199 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005200 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005201 delete (yyvsp[(2) - (9)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005202
5203 ValID ID;
5204 if (!FunctionName.empty()) {
5205 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5206 } else {
5207 ID = ValID::createGlobalID(CurModule.Values.size());
5208 }
5209
5210 Function *Fn = 0;
5211 // See if this function was forward referenced. If so, recycle the object.
5212 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5213 // Move the function to the end of the list, from whereever it was
5214 // previously inserted.
5215 Fn = cast<Function>(FWRef);
5216 CurModule.CurrentModule->getFunctionList().remove(Fn);
5217 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5218 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5219 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
5220 if (Fn->getFunctionType() != FT) {
5221 // The existing function doesn't have the same type. This is an overload
5222 // error.
5223 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
5224 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5225 // Neither the existing or the current function is a declaration and they
5226 // have the same name and same type. Clearly this is a redefinition.
5227 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
5228 } if (Fn->isDeclaration()) {
5229 // Make sure to strip off any argument names so we can't get conflicts.
5230 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5231 AI != AE; ++AI)
5232 AI->setName("");
5233 }
5234 } else { // Not already defined?
5235 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5236 CurModule.CurrentModule);
5237
5238 InsertValue(Fn, CurModule.Values);
5239 }
5240
5241 CurFun.FunctionStart(Fn);
5242
5243 if (CurFun.isDeclare) {
5244 // If we have declaration, always overwrite linkage. This will allow us to
5245 // correctly handle cases, when pointer to function is passed as argument to
5246 // another function.
5247 Fn->setLinkage(CurFun.Linkage);
5248 Fn->setVisibility(CurFun.Visibility);
5249 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005250 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5251 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5252 if ((yyvsp[(8) - (9)].StrVal)) {
5253 Fn->setSection(*(yyvsp[(8) - (9)].StrVal));
5254 delete (yyvsp[(8) - (9)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005255 }
5256
5257 // Add all of the arguments we parsed to the function...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005258 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005259 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005260 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005261 "Not a varargs marker!");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005262 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5263 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005264 }
5265 Function::arg_iterator ArgIt = Fn->arg_begin();
5266 Function::arg_iterator ArgEnd = Fn->arg_end();
5267 unsigned Idx = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005268 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5269 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005270 delete I->Ty; // Delete the typeholder...
5271 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5272 CHECK_FOR_ERROR
5273 InsertValue(ArgIt);
5274 Idx++;
5275 }
5276
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005277 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005278 }
5279 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005280;}
5281 break;
5282
5283 case 238:
5284#line 2379 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5285 {
5286 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005287
5288 // Make sure that we keep track of the linkage type even if there was a
5289 // previous "declare".
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005290 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5291 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5292;}
5293 break;
5294
5295 case 241:
5296#line 2390 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5297 {
5298 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005299 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005300;}
5301 break;
5302
5303 case 242:
5304#line 2395 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5305 {
5306 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5307 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5308 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005309 CurFun.FunctionDone();
5310 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005311 ;}
5312 break;
5313
5314 case 243:
5315#line 2407 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5316 {
5317 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005318 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005319 ;}
5320 break;
5321
5322 case 244:
5323#line 2411 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5324 {
5325 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005326 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005327 ;}
5328 break;
5329
5330 case 245:
5331#line 2416 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5332 { // A reference to a direct constant
5333 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005334 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005335 ;}
5336 break;
5337
5338 case 246:
5339#line 2420 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5340 {
5341 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005342 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005343 ;}
5344 break;
5345
5346 case 247:
5347#line 2424 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5348 { // Perhaps it's an FP constant?
5349 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005350 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005351 ;}
5352 break;
5353
5354 case 248:
5355#line 2428 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5356 {
5357 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005358 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005359 ;}
5360 break;
5361
5362 case 249:
5363#line 2432 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5364 {
5365 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005366 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005367 ;}
5368 break;
5369
5370 case 250:
5371#line 2436 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5372 {
5373 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005374 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005375 ;}
5376 break;
5377
5378 case 251:
5379#line 2440 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5380 {
5381 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005382 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005383 ;}
5384 break;
5385
5386 case 252:
5387#line 2444 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5388 { // A vector zero constant.
5389 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005390 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005391 ;}
5392 break;
5393
5394 case 253:
5395#line 2448 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5396 { // Nonempty unsized packed vector
5397 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5398 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005399
5400 VectorType* pt = VectorType::get(ETy, NumElements);
5401 PATypeHolder* PTy = new PATypeHolder(
5402 HandleUpRefs(
5403 VectorType::get(
5404 ETy,
5405 NumElements)
5406 )
5407 );
5408
5409 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005410 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5411 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005412 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5413 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005414 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005415 }
5416
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005417 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5418 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005419 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005420 ;}
5421 break;
5422
5423 case 254:
5424#line 2473 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5425 {
5426 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005427 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005428 ;}
5429 break;
5430
5431 case 255:
5432#line 2477 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5433 {
5434 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5435 delete (yyvsp[(3) - (5)].StrVal);
5436 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005437 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005438 ;}
5439 break;
5440
5441 case 256:
5442#line 2487 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5443 { // Is it an integer reference...?
5444 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005445 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005446 ;}
5447 break;
5448
5449 case 257:
5450#line 2491 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5451 {
5452 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005453 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005454 ;}
5455 break;
5456
5457 case 258:
5458#line 2495 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5459 { // Is it a named reference...?
5460 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5461 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005462 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005463 ;}
5464 break;
5465
5466 case 259:
5467#line 2500 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5468 { // Is it a named reference...?
5469 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5470 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005471 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005472 ;}
5473 break;
5474
5475 case 262:
5476#line 2513 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5477 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005478 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005479 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5480 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5481 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005482 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005483 ;}
5484 break;
5485
5486 case 263:
5487#line 2522 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5488 {
5489 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005490 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005491 ;}
5492 break;
5493
5494 case 264:
5495#line 2526 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5496 { // Do not allow functions with 0 basic blocks
5497 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005498 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005499 ;}
5500 break;
5501
5502 case 265:
5503#line 2535 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5504 {
5505 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005506 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005507 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5508 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5509 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005510 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005511 ;}
5512 break;
5513
5514 case 266:
5515#line 2544 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5516 {
5517 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005518 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5519 if (CI2->getParent() == 0)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005520 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5521 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5522 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005523 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005524 ;}
5525 break;
5526
5527 case 267:
5528#line 2553 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5529 { // Empty space between instruction lists
5530 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005531 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005532 ;}
5533 break;
5534
5535 case 268:
5536#line 2557 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5537 { // Labelled (named) basic block
5538 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5539 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005540 CHECK_FOR_ERROR
5541
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005542 ;}
5543 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005544
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005545 case 269:
5546#line 2564 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5547 { // Return with a result...
5548 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5549 CHECK_FOR_ERROR
5550 ;}
5551 break;
5552
5553 case 270:
5554#line 2568 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5555 { // Return with no result...
5556 (yyval.TermInstVal) = new ReturnInst();
5557 CHECK_FOR_ERROR
5558 ;}
5559 break;
5560
5561 case 271:
5562#line 2572 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5563 { // Unconditional Branch...
5564 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5565 CHECK_FOR_ERROR
5566 (yyval.TermInstVal) = new BranchInst(tmpBB);
5567 ;}
5568 break;
5569
5570 case 272:
5571#line 2577 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5572 {
5573 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5574 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5575 CHECK_FOR_ERROR
5576 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5577 CHECK_FOR_ERROR
5578 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5579 CHECK_FOR_ERROR
5580 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5581 ;}
5582 break;
5583
5584 case 273:
5585#line 2587 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5586 {
5587 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5588 CHECK_FOR_ERROR
5589 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5590 CHECK_FOR_ERROR
5591 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5592 (yyval.TermInstVal) = S;
5593
5594 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5595 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005596 for (; I != E; ++I) {
5597 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5598 S->addCase(CI, I->second);
5599 else
5600 GEN_ERROR("Switch case is constant, but not a simple integer");
5601 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005602 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005603 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005604 ;}
5605 break;
5606
5607 case 274:
5608#line 2606 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5609 {
5610 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005611 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005612 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005613 CHECK_FOR_ERROR
5614 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005615 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005616 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005617 ;}
5618 break;
5619
5620 case 275:
5621#line 2616 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5622 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005623
5624 // Handle the short syntax
5625 const PointerType *PFTy = 0;
5626 const FunctionType *Ty = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005627 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005628 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5629 // Pull out the types of all of the arguments...
5630 std::vector<const Type*> ParamTypes;
5631 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005632 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5633 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005634 Attrs.push_back(PAWI);
5635 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005636 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005637 unsigned index = 1;
5638 for (; I != E; ++I, ++index) {
5639 const Type *Ty = I->Val->getType();
5640 if (Ty == Type::VoidTy)
5641 GEN_ERROR("Short call syntax cannot be used with varargs");
5642 ParamTypes.push_back(Ty);
5643 if (I->Attrs != ParamAttr::None) {
5644 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5645 Attrs.push_back(PAWI);
5646 }
5647 }
5648
5649 ParamAttrsList *PAL = 0;
5650 if (!Attrs.empty())
5651 PAL = ParamAttrsList::get(Attrs);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005652 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005653 PFTy = PointerType::get(Ty);
5654 }
5655
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005656 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005657
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005658 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005659 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005660 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005661 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005662 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005663 CHECK_FOR_ERROR
5664
5665 // Check the arguments
5666 ValueList Args;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005667 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005668 // Make sure no arguments is a good thing!
5669 if (Ty->getNumParams() != 0)
5670 GEN_ERROR("No arguments passed to a function that "
5671 "expects arguments");
5672 } else { // Has arguments?
5673 // Loop through FunctionType's arguments and ensure they are specified
5674 // correctly!
5675 FunctionType::param_iterator I = Ty->param_begin();
5676 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005677 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005678
5679 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5680 if (ArgI->Val->getType() != *I)
5681 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5682 (*I)->getDescription() + "'");
5683 Args.push_back(ArgI->Val);
5684 }
5685
5686 if (Ty->isVarArg()) {
5687 if (I == E)
5688 for (; ArgI != ArgE; ++ArgI)
5689 Args.push_back(ArgI->Val); // push the remaining varargs
5690 } else if (I != E || ArgI != ArgE)
5691 GEN_ERROR("Invalid number of parameters detected");
5692 }
5693
5694 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00005695 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005696 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5697 (yyval.TermInstVal) = II;
5698 delete (yyvsp[(6) - (14)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005699 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005700 ;}
5701 break;
5702
5703 case 276:
5704#line 2695 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5705 {
5706 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005707 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005708 ;}
5709 break;
5710
5711 case 277:
5712#line 2699 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5713 {
5714 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005715 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005716 ;}
5717 break;
5718
5719 case 278:
5720#line 2706 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5721 {
5722 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5723 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005724 CHECK_FOR_ERROR
5725 if (V == 0)
5726 GEN_ERROR("May only switch on a constant pool value");
5727
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005728 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005729 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005730 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5731 ;}
5732 break;
5733
5734 case 279:
5735#line 2717 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5736 {
5737 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5738 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005739 CHECK_FOR_ERROR
5740
5741 if (V == 0)
5742 GEN_ERROR("May only switch on a constant pool value");
5743
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005744 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005745 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005746 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5747 ;}
5748 break;
5749
5750 case 280:
5751#line 2730 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5752 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005753 // Is this definition named?? if so, assign the name...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005754 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005755 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005756 InsertValue((yyvsp[(2) - (2)].InstVal));
5757 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005758 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005759 ;}
5760 break;
5761
5762 case 281:
5763#line 2740 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5764 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005765 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005766 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5767 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5768 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005769 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005770 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005771 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005772 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5773 delete (yyvsp[(1) - (6)].TypeVal);
5774 ;}
5775 break;
5776
5777 case 282:
5778#line 2751 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5779 {
5780 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5781 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005782 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005783 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005784 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005785 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5786 ;}
5787 break;
5788
5789 case 283:
5790#line 2761 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5791 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005792 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005793 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005794 // Used for call and invoke instructions
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005795 (yyval.ParamList) = new ParamList();
5796 ParamListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5797 (yyval.ParamList)->push_back(E);
5798 delete (yyvsp[(1) - (3)].TypeVal);
5799 ;}
5800 break;
5801
5802 case 284:
5803#line 2770 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5804 {
Dale Johannesencfb19e62007-11-05 21:20:28 +00005805 // Labels are only valid in ASMs
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005806 (yyval.ParamList) = new ParamList();
5807 ParamListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getBBVal((yyvsp[(2) - (3)].ValIDVal));
5808 (yyval.ParamList)->push_back(E);
5809 ;}
5810 break;
5811
5812 case 285:
5813#line 2776 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5814 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005815 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005816 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5817 (yyval.ParamList) = (yyvsp[(1) - (5)].ParamList);
5818 ParamListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5819 (yyval.ParamList)->push_back(E);
5820 delete (yyvsp[(3) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005821 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005822 ;}
5823 break;
5824
5825 case 286:
5826#line 2785 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5827 {
5828 (yyval.ParamList) = (yyvsp[(1) - (5)].ParamList);
5829 ParamListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getBBVal((yyvsp[(4) - (5)].ValIDVal));
5830 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00005831 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005832 ;}
5833 break;
5834
5835 case 287:
5836#line 2791 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5837 { (yyval.ParamList) = new ParamList(); ;}
5838 break;
5839
5840 case 288:
5841#line 2794 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5842 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5843 break;
5844
5845 case 289:
5846#line 2795 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5847 {
5848 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5849 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005850 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005851 ;}
5852 break;
5853
5854 case 290:
5855#line 2802 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5856 {
5857 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005858 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005859 ;}
5860 break;
5861
5862 case 291:
5863#line 2806 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5864 {
5865 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005866 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005867 ;}
5868 break;
5869
5870 case 292:
5871#line 2811 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5872 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005873 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005874 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5875 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5876 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005877 GEN_ERROR(
5878 "Arithmetic operator requires integer, FP, or packed operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005879 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005880 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005881 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005882 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005883 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5884 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005885 GEN_ERROR("binary operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005886 delete (yyvsp[(2) - (5)].TypeVal);
5887 ;}
5888 break;
5889
5890 case 293:
5891#line 2827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5892 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005893 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005894 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5895 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5896 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5897 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005898 GEN_ERROR("Logical operator requires integral operands");
5899 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005900 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005901 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005902 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005903 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005904 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5905 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005906 GEN_ERROR("binary operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005907 delete (yyvsp[(2) - (5)].TypeVal);
5908 ;}
5909 break;
5910
5911 case 294:
5912#line 2844 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5913 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005914 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005915 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5916 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005917 GEN_ERROR("Vector types not supported by icmp instruction");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005918 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005919 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005920 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005921 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005922 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5923 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005924 GEN_ERROR("icmp operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005925 delete (yyvsp[(3) - (6)].TypeVal);
5926 ;}
5927 break;
5928
5929 case 295:
5930#line 2858 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5931 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005932 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005933 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5934 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005935 GEN_ERROR("Vector types not supported by fcmp instruction");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005936 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005937 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005938 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005939 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005940 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5941 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005942 GEN_ERROR("fcmp operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005943 delete (yyvsp[(3) - (6)].TypeVal);
5944 ;}
5945 break;
5946
5947 case 296:
5948#line 2872 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5949 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005950 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005951 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5952 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5953 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5954 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005955 GEN_ERROR("invalid cast opcode for cast from '" +
5956 Val->getType()->getDescription() + "' to '" +
5957 DestTy->getDescription() + "'");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005958 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5959 delete (yyvsp[(4) - (4)].TypeVal);
5960 ;}
5961 break;
5962
5963 case 297:
5964#line 2884 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5965 {
5966 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005967 GEN_ERROR("select condition must be boolean");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005968 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005969 GEN_ERROR("select value types should match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005970 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005971 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005972 ;}
5973 break;
5974
5975 case 298:
5976#line 2892 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5977 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005978 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005979 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5980 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5981 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005982 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005983 ;}
5984 break;
5985
5986 case 299:
5987#line 2899 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5988 {
5989 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005990 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005991 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005992 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005993 ;}
5994 break;
5995
5996 case 300:
5997#line 2905 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
5998 {
5999 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006000 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006001 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006002 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006003 ;}
6004 break;
6005
6006 case 301:
6007#line 2911 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6008 {
6009 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006010 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006011 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006012 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006013 ;}
6014 break;
6015
6016 case 302:
6017#line 2917 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6018 {
6019 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006020 if (!Ty->isFirstClassType())
6021 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006022 (yyval.InstVal) = new PHINode(Ty);
6023 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6024 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6025 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006026 GEN_ERROR("All elements of a PHI node must be of the same type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006027 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6028 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006029 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006030 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006031 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006032 ;}
6033 break;
6034
6035 case 303:
6036#line 2933 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6037 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006038
6039 // Handle the short syntax
6040 const PointerType *PFTy = 0;
6041 const FunctionType *Ty = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006042 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006043 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6044 // Pull out the types of all of the arguments...
6045 std::vector<const Type*> ParamTypes;
6046 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006047 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
6048 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006049 Attrs.push_back(PAWI);
6050 }
6051 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006052 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006053 for (; I != E; ++I, ++index) {
6054 const Type *Ty = I->Val->getType();
6055 if (Ty == Type::VoidTy)
6056 GEN_ERROR("Short call syntax cannot be used with varargs");
6057 ParamTypes.push_back(Ty);
6058 if (I->Attrs != ParamAttr::None) {
6059 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
6060 Attrs.push_back(PAWI);
6061 }
6062 }
6063
6064 ParamAttrsList *PAL = 0;
6065 if (!Attrs.empty())
6066 PAL = ParamAttrsList::get(Attrs);
6067
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006068 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006069 PFTy = PointerType::get(Ty);
6070 }
6071
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006072 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006073 CHECK_FOR_ERROR
6074
6075 // Check for call to invalid intrinsic to avoid crashing later.
6076 if (Function *theF = dyn_cast<Function>(V)) {
6077 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6078 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6079 !theF->getIntrinsicID(true))
6080 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6081 theF->getName() + "'");
6082 }
6083
6084 // Check the arguments
6085 ValueList Args;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006086 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006087 // Make sure no arguments is a good thing!
6088 if (Ty->getNumParams() != 0)
6089 GEN_ERROR("No arguments passed to a function that "
6090 "expects arguments");
6091 } else { // Has arguments?
6092 // Loop through FunctionType's arguments and ensure they are specified
6093 // correctly!
6094 //
6095 FunctionType::param_iterator I = Ty->param_begin();
6096 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006097 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006098
6099 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6100 if (ArgI->Val->getType() != *I)
6101 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6102 (*I)->getDescription() + "'");
6103 Args.push_back(ArgI->Val);
6104 }
6105 if (Ty->isVarArg()) {
6106 if (I == E)
6107 for (; ArgI != ArgE; ++ArgI)
6108 Args.push_back(ArgI->Val); // push the remaining varargs
6109 } else if (I != E || ArgI != ArgE)
6110 GEN_ERROR("Invalid number of parameters detected");
6111 }
6112 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00006113 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006114 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6115 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
6116 (yyval.InstVal) = CI;
6117 delete (yyvsp[(6) - (8)].ParamList);
6118 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006119 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006120 ;}
6121 break;
6122
6123 case 304:
6124#line 3017 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6125 {
6126 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006127 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006128 ;}
6129 break;
6130
6131 case 305:
6132#line 3022 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6133 {
6134 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006135 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006136 ;}
6137 break;
6138
6139 case 306:
6140#line 3026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6141 {
6142 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006143 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006144 ;}
6145 break;
6146
6147 case 307:
6148#line 3033 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6149 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006150 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006151 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6152 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6153 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006154 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006155 ;}
6156 break;
6157
6158 case 308:
6159#line 3040 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6160 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006161 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006162 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6163 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006164 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006165 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6166 delete (yyvsp[(2) - (6)].TypeVal);
6167 ;}
6168 break;
6169
6170 case 309:
6171#line 3048 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6172 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006173 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006174 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6175 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6176 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006177 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006178 ;}
6179 break;
6180
6181 case 310:
6182#line 3055 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6183 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006184 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006185 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6186 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006187 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006188 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6189 delete (yyvsp[(2) - (6)].TypeVal);
6190 ;}
6191 break;
6192
6193 case 311:
6194#line 3063 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6195 {
6196 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006197 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006198 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6199 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006200 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006201 ;}
6202 break;
6203
6204 case 312:
6205#line 3071 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6206 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006207 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006208 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6209 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006210 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006211 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6212 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006213 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006214 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6215 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006216 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006217 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6218 delete (yyvsp[(3) - (5)].TypeVal);
6219 ;}
6220 break;
6221
6222 case 313:
6223#line 3085 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6224 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006225 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006226 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6227 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006228 if (!PT)
6229 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006230 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006231 const Type *ElTy = PT->getElementType();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006232 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6233 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006234 "' into space of type '" + ElTy->getDescription() + "'");
6235
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006236 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006237 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006238 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6239 delete (yyvsp[(5) - (7)].TypeVal);
6240 ;}
6241 break;
6242
6243 case 314:
6244#line 3102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
6245 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006246 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006247 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6248 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006249 GEN_ERROR("getelementptr insn requires pointer operand");
6250
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006251 if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end(), true))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006252 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006253 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6254 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006255 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006256 (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6257 delete (yyvsp[(2) - (4)].TypeVal);
6258 delete (yyvsp[(4) - (4)].ValueList);
6259 ;}
6260 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006261
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006262
6263/* Line 1267 of yacc.c. */
6264#line 6265 "llvmAsmParser.tab.c"
6265 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00006266 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006267 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6268
6269 YYPOPSTACK (yylen);
6270 yylen = 0;
6271 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006272
6273 *++yyvsp = yyval;
6274
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006275
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006276 /* Now `shift' the result of the reduction. Determine what state
6277 that goes to, based on the state we popped back to and the rule
6278 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006279
6280 yyn = yyr1[yyn];
6281
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006282 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6283 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006284 yystate = yytable[yystate];
6285 else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006286 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006287
6288 goto yynewstate;
6289
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006290
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006291/*------------------------------------.
6292| yyerrlab -- here on detecting error |
6293`------------------------------------*/
6294yyerrlab:
6295 /* If not already recovering from an error, report this error. */
6296 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006297 {
6298 ++yynerrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006299#if ! YYERROR_VERBOSE
6300 yyerror (YY_("syntax error"));
6301#else
6302 {
6303 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6304 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6305 {
6306 YYSIZE_T yyalloc = 2 * yysize;
6307 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6308 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6309 if (yymsg != yymsgbuf)
6310 YYSTACK_FREE (yymsg);
6311 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6312 if (yymsg)
6313 yymsg_alloc = yyalloc;
6314 else
6315 {
6316 yymsg = yymsgbuf;
6317 yymsg_alloc = sizeof yymsgbuf;
6318 }
6319 }
Dale Johannesen3afee192007-09-07 21:07:57 +00006320
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006321 if (0 < yysize && yysize <= yymsg_alloc)
6322 {
6323 (void) yysyntax_error (yymsg, yystate, yychar);
6324 yyerror (yymsg);
6325 }
6326 else
6327 {
6328 yyerror (YY_("syntax error"));
6329 if (yysize != 0)
6330 goto yyexhaustedlab;
6331 }
6332 }
6333#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006334 }
6335
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006336
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006337
6338 if (yyerrstatus == 3)
6339 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006340 /* If just tried and failed to reuse look-ahead token after an
6341 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006342
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006343 if (yychar <= YYEOF)
6344 {
6345 /* Return failure if at end of input. */
6346 if (yychar == YYEOF)
6347 YYABORT;
6348 }
6349 else
6350 {
6351 yydestruct ("Error: discarding",
6352 yytoken, &yylval);
6353 yychar = YYEMPTY;
6354 }
6355 }
6356
6357 /* Else will try to reuse look-ahead token after shifting the error
6358 token. */
6359 goto yyerrlab1;
6360
6361
6362/*---------------------------------------------------.
6363| yyerrorlab -- error raised explicitly by YYERROR. |
6364`---------------------------------------------------*/
6365yyerrorlab:
6366
6367 /* Pacify compilers like GCC when the user code never invokes
6368 YYERROR and the label yyerrorlab therefore never appears in user
6369 code. */
6370 if (/*CONSTCOND*/ 0)
6371 goto yyerrorlab;
6372
6373 /* Do not reclaim the symbols of the rule which action triggered
6374 this YYERROR. */
6375 YYPOPSTACK (yylen);
6376 yylen = 0;
6377 YY_STACK_PRINT (yyss, yyssp);
6378 yystate = *yyssp;
6379 goto yyerrlab1;
6380
6381
6382/*-------------------------------------------------------------.
6383| yyerrlab1 -- common code for both syntax error and YYERROR. |
6384`-------------------------------------------------------------*/
6385yyerrlab1:
6386 yyerrstatus = 3; /* Each real token shifted decrements this. */
6387
6388 for (;;)
6389 {
6390 yyn = yypact[yystate];
6391 if (yyn != YYPACT_NINF)
6392 {
6393 yyn += YYTERROR;
6394 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6395 {
6396 yyn = yytable[yyn];
6397 if (0 < yyn)
6398 break;
6399 }
6400 }
6401
6402 /* Pop the current state because it cannot handle the error token. */
6403 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006404 YYABORT;
6405
Dale Johannesen3afee192007-09-07 21:07:57 +00006406
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006407 yydestruct ("Error: popping",
6408 yystos[yystate], yyvsp);
6409 YYPOPSTACK (1);
6410 yystate = *yyssp;
6411 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006412 }
6413
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006414 if (yyn == YYFINAL)
6415 YYACCEPT;
6416
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006417 *++yyvsp = yylval;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006418
6419
6420 /* Shift the error token. */
6421 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006422
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006423 yystate = yyn;
6424 goto yynewstate;
6425
David Greene48556392007-09-04 18:46:50 +00006426
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006427/*-------------------------------------.
6428| yyacceptlab -- YYACCEPT comes here. |
6429`-------------------------------------*/
6430yyacceptlab:
6431 yyresult = 0;
6432 goto yyreturn;
6433
6434/*-----------------------------------.
6435| yyabortlab -- YYABORT comes here. |
6436`-----------------------------------*/
6437yyabortlab:
6438 yyresult = 1;
6439 goto yyreturn;
6440
6441#ifndef yyoverflow
6442/*-------------------------------------------------.
6443| yyexhaustedlab -- memory exhaustion comes here. |
6444`-------------------------------------------------*/
6445yyexhaustedlab:
6446 yyerror (YY_("memory exhausted"));
6447 yyresult = 2;
6448 /* Fall through. */
David Greene48556392007-09-04 18:46:50 +00006449#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006450
6451yyreturn:
6452 if (yychar != YYEOF && yychar != YYEMPTY)
6453 yydestruct ("Cleanup: discarding lookahead",
6454 yytoken, &yylval);
6455 /* Do not reclaim the symbols of the rule which action triggered
6456 this YYABORT or YYACCEPT. */
6457 YYPOPSTACK (yylen);
6458 YY_STACK_PRINT (yyss, yyssp);
6459 while (yyssp != yyss)
6460 {
6461 yydestruct ("Cleanup: popping",
6462 yystos[*yyssp], yyvsp);
6463 YYPOPSTACK (1);
Dale Johannesen3afee192007-09-07 21:07:57 +00006464 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006465#ifndef yyoverflow
6466 if (yyss != yyssa)
6467 YYSTACK_FREE (yyss);
6468#endif
6469#if YYERROR_VERBOSE
6470 if (yymsg != yymsgbuf)
6471 YYSTACK_FREE (yymsg);
6472#endif
6473 /* Make sure YYID is used. */
6474 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006475}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006476
6477
6478#line 3119 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006479
6480
6481// common code from the two 'RunVMAsmParser' functions
6482static Module* RunParser(Module * M) {
6483
6484 llvmAsmlineno = 1; // Reset the current line number...
6485 CurModule.CurrentModule = M;
6486#if YYDEBUG
6487 yydebug = Debug;
6488#endif
6489
6490 // Check to make sure the parser succeeded
6491 if (yyparse()) {
6492 if (ParserResult)
6493 delete ParserResult;
6494 return 0;
6495 }
6496
6497 // Emit an error if there are any unresolved types left.
6498 if (!CurModule.LateResolveTypes.empty()) {
6499 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6500 if (DID.Type == ValID::LocalName) {
6501 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6502 } else {
6503 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6504 }
6505 if (ParserResult)
6506 delete ParserResult;
6507 return 0;
6508 }
6509
6510 // Emit an error if there are any unresolved values left.
6511 if (!CurModule.LateResolveValues.empty()) {
6512 Value *V = CurModule.LateResolveValues.back();
6513 std::map<Value*, std::pair<ValID, int> >::iterator I =
6514 CurModule.PlaceHolderInfo.find(V);
6515
6516 if (I != CurModule.PlaceHolderInfo.end()) {
6517 ValID &DID = I->second.first;
6518 if (DID.Type == ValID::LocalName) {
6519 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6520 } else {
6521 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6522 }
6523 if (ParserResult)
6524 delete ParserResult;
6525 return 0;
6526 }
6527 }
6528
6529 // Check to make sure that parsing produced a result
6530 if (!ParserResult)
6531 return 0;
6532
6533 // Reset ParserResult variable while saving its value for the result.
6534 Module *Result = ParserResult;
6535 ParserResult = 0;
6536
6537 return Result;
6538}
6539
6540void llvm::GenerateError(const std::string &message, int LineNo) {
6541 if (LineNo == -1) LineNo = llvmAsmlineno;
6542 // TODO: column number in exception
6543 if (TheParseError)
6544 TheParseError->setError(CurFilename, message, LineNo);
6545 TriggerError = 1;
6546}
6547
6548int yyerror(const char *ErrorMsg) {
6549 std::string where
6550 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6551 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
6552 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6553 if (yychar != YYEMPTY && yychar != 0)
6554 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6555 "'";
6556 GenerateError(errMsg);
6557 return 0;
6558}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006559