blob: 77ba03e10c9a9bfbfec5ece403a516ffb24eaf92 [file] [log] [blame]
Chris Lattner59363a32008-02-19 04:36:25 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Chris Lattner59363a32008-02-19 04:36:25 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Chris Lattner59363a32008-02-19 04:36:25 +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
Chris Lattner59363a32008-02-19 04:36:25 +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
Chris Lattner59363a32008-02-19 04:36:25 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Chris Lattner59363a32008-02-19 04:36:25 +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
Chris Lattner59363a32008-02-19 04:36:25 +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 ADDRSPACE = 309,
129 DEPLIBS = 310,
130 CALL = 311,
131 TAIL = 312,
132 ASM_TOK = 313,
133 MODULE = 314,
134 SIDEEFFECT = 315,
135 CC_TOK = 316,
136 CCC_TOK = 317,
137 FASTCC_TOK = 318,
138 COLDCC_TOK = 319,
139 X86_STDCALLCC_TOK = 320,
140 X86_FASTCALLCC_TOK = 321,
141 DATALAYOUT = 322,
142 RET = 323,
143 BR = 324,
144 SWITCH = 325,
145 INVOKE = 326,
146 UNWIND = 327,
147 UNREACHABLE = 328,
148 ADD = 329,
149 SUB = 330,
150 MUL = 331,
151 UDIV = 332,
152 SDIV = 333,
153 FDIV = 334,
154 UREM = 335,
155 SREM = 336,
156 FREM = 337,
157 AND = 338,
158 OR = 339,
159 XOR = 340,
160 SHL = 341,
161 LSHR = 342,
162 ASHR = 343,
163 ICMP = 344,
164 FCMP = 345,
165 EQ = 346,
166 NE = 347,
167 SLT = 348,
168 SGT = 349,
169 SLE = 350,
170 SGE = 351,
171 ULT = 352,
172 UGT = 353,
173 ULE = 354,
174 UGE = 355,
175 OEQ = 356,
176 ONE = 357,
177 OLT = 358,
178 OGT = 359,
179 OLE = 360,
180 OGE = 361,
181 ORD = 362,
182 UNO = 363,
183 UEQ = 364,
184 UNE = 365,
185 MALLOC = 366,
186 ALLOCA = 367,
187 FREE = 368,
188 LOAD = 369,
189 STORE = 370,
190 GETELEMENTPTR = 371,
191 TRUNC = 372,
192 ZEXT = 373,
193 SEXT = 374,
194 FPTRUNC = 375,
195 FPEXT = 376,
196 BITCAST = 377,
197 UITOFP = 378,
198 SITOFP = 379,
199 FPTOUI = 380,
200 FPTOSI = 381,
201 INTTOPTR = 382,
202 PTRTOINT = 383,
203 PHI_TOK = 384,
204 SELECT = 385,
205 VAARG = 386,
206 EXTRACTELEMENT = 387,
207 INSERTELEMENT = 388,
208 SHUFFLEVECTOR = 389,
209 SIGNEXT = 390,
210 ZEROEXT = 391,
211 NORETURN = 392,
212 INREG = 393,
213 SRET = 394,
214 NOUNWIND = 395,
215 NOALIAS = 396,
216 BYVAL = 397,
217 NEST = 398,
218 READNONE = 399,
219 READONLY = 400,
220 GC = 401,
221 DEFAULT = 402,
222 HIDDEN = 403,
223 PROTECTED = 404
224 };
225#endif
226/* Tokens. */
227#define ESINT64VAL 258
228#define EUINT64VAL 259
229#define ESAPINTVAL 260
230#define EUAPINTVAL 261
231#define LOCALVAL_ID 262
232#define GLOBALVAL_ID 263
233#define FPVAL 264
234#define VOID 265
235#define INTTYPE 266
236#define FLOAT 267
237#define DOUBLE 268
238#define X86_FP80 269
239#define FP128 270
240#define PPC_FP128 271
241#define LABEL 272
242#define TYPE 273
243#define LOCALVAR 274
244#define GLOBALVAR 275
245#define LABELSTR 276
246#define STRINGCONSTANT 277
247#define ATSTRINGCONSTANT 278
248#define PCTSTRINGCONSTANT 279
249#define ZEROINITIALIZER 280
250#define TRUETOK 281
251#define FALSETOK 282
252#define BEGINTOK 283
253#define ENDTOK 284
254#define DECLARE 285
255#define DEFINE 286
256#define GLOBAL 287
257#define CONSTANT 288
258#define SECTION 289
259#define ALIAS 290
260#define VOLATILE 291
261#define THREAD_LOCAL 292
262#define TO 293
263#define DOTDOTDOT 294
264#define NULL_TOK 295
265#define UNDEF 296
266#define INTERNAL 297
267#define LINKONCE 298
268#define WEAK 299
269#define APPENDING 300
270#define DLLIMPORT 301
271#define DLLEXPORT 302
272#define EXTERN_WEAK 303
273#define OPAQUE 304
274#define EXTERNAL 305
275#define TARGET 306
276#define TRIPLE 307
277#define ALIGN 308
278#define ADDRSPACE 309
279#define DEPLIBS 310
280#define CALL 311
281#define TAIL 312
282#define ASM_TOK 313
283#define MODULE 314
284#define SIDEEFFECT 315
285#define CC_TOK 316
286#define CCC_TOK 317
287#define FASTCC_TOK 318
288#define COLDCC_TOK 319
289#define X86_STDCALLCC_TOK 320
290#define X86_FASTCALLCC_TOK 321
291#define DATALAYOUT 322
292#define RET 323
293#define BR 324
294#define SWITCH 325
295#define INVOKE 326
296#define UNWIND 327
297#define UNREACHABLE 328
298#define ADD 329
299#define SUB 330
300#define MUL 331
301#define UDIV 332
302#define SDIV 333
303#define FDIV 334
304#define UREM 335
305#define SREM 336
306#define FREM 337
307#define AND 338
308#define OR 339
309#define XOR 340
310#define SHL 341
311#define LSHR 342
312#define ASHR 343
313#define ICMP 344
314#define FCMP 345
315#define EQ 346
316#define NE 347
317#define SLT 348
318#define SGT 349
319#define SLE 350
320#define SGE 351
321#define ULT 352
322#define UGT 353
323#define ULE 354
324#define UGE 355
325#define OEQ 356
326#define ONE 357
327#define OLT 358
328#define OGT 359
329#define OLE 360
330#define OGE 361
331#define ORD 362
332#define UNO 363
333#define UEQ 364
334#define UNE 365
335#define MALLOC 366
336#define ALLOCA 367
337#define FREE 368
338#define LOAD 369
339#define STORE 370
340#define GETELEMENTPTR 371
341#define TRUNC 372
342#define ZEXT 373
343#define SEXT 374
344#define FPTRUNC 375
345#define FPEXT 376
346#define BITCAST 377
347#define UITOFP 378
348#define SITOFP 379
349#define FPTOUI 380
350#define FPTOSI 381
351#define INTTOPTR 382
352#define PTRTOINT 383
353#define PHI_TOK 384
354#define SELECT 385
355#define VAARG 386
356#define EXTRACTELEMENT 387
357#define INSERTELEMENT 388
358#define SHUFFLEVECTOR 389
359#define SIGNEXT 390
360#define ZEROEXT 391
361#define NORETURN 392
362#define INREG 393
363#define SRET 394
364#define NOUNWIND 395
365#define NOALIAS 396
366#define BYVAL 397
367#define NEST 398
368#define READNONE 399
369#define READONLY 400
370#define GC 401
371#define DEFAULT 402
372#define HIDDEN 403
373#define PROTECTED 404
374
375
376
377
378/* Copy the first part of user declarations. */
379#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380
381#include "ParserInternals.h"
382#include "llvm/CallingConv.h"
383#include "llvm/InlineAsm.h"
384#include "llvm/Instructions.h"
385#include "llvm/Module.h"
386#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000387#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388#include "llvm/Support/GetElementPtrTypeIterator.h"
389#include "llvm/Support/CommandLine.h"
390#include "llvm/ADT/SmallVector.h"
391#include "llvm/ADT/STLExtras.h"
392#include "llvm/Support/MathExtras.h"
393#include "llvm/Support/Streams.h"
394#include <algorithm>
395#include <list>
396#include <map>
397#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398
399// The following is a gross hack. In order to rid the libAsmParser library of
400// exceptions, we have to have a way of getting the yyparse function to go into
401// an error situation. So, whenever we want an error to occur, the GenerateError
402// function (see bottom of file) sets TriggerError. Then, at the end of each
403// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
404// (a goto) to put YACC in error state. Furthermore, several calls to
405// GenerateError are made from inside productions and they must simulate the
406// previous exception behavior by exiting the production immediately. We have
407// replaced these with the GEN_ERROR macro which calls GeneratError and then
408// immediately invokes YYERROR. This would be so much cleaner if it was a
409// recursive descent parser.
410static bool TriggerError = false;
411#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
412#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
413
414int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
415int yylex(); // declaration" of xxx warnings.
416int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417using namespace llvm;
418
419static Module *ParserResult;
420
421// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
422// relating to upreferences in the input stream.
423//
424//#define DEBUG_UPREFS 1
425#ifdef DEBUG_UPREFS
426#define UR_OUT(X) cerr << X
427#else
428#define UR_OUT(X)
429#endif
430
431#define YYERROR_VERBOSE 1
432
433static GlobalVariable *CurGV;
434
435
436// This contains info used when building the body of a function. It is
437// destroyed when the function is completed.
438//
439typedef std::vector<Value *> ValueList; // Numbered defs
440
441static void
442ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
443
444static struct PerModuleInfo {
445 Module *CurrentModule;
446 ValueList Values; // Module level numbered definitions
447 ValueList LateResolveValues;
448 std::vector<PATypeHolder> Types;
449 std::map<ValID, PATypeHolder> LateResolveTypes;
450
451 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
452 /// how they were referenced and on which line of the input they came from so
453 /// that we can resolve them later and print error messages as appropriate.
454 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
455
456 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
457 // references to global values. Global values may be referenced before they
458 // are defined, and if so, the temporary object that they represent is held
459 // here. This is used for forward references of GlobalValues.
460 //
461 typedef std::map<std::pair<const PointerType *,
462 ValID>, GlobalValue*> GlobalRefsType;
463 GlobalRefsType GlobalRefs;
464
465 void ModuleDone() {
466 // If we could not resolve some functions at function compilation time
467 // (calls to functions before they are defined), resolve them now... Types
468 // are resolved when the constant pool has been completely parsed.
469 //
470 ResolveDefinitions(LateResolveValues);
471 if (TriggerError)
472 return;
473
474 // Check to make sure that all global value forward references have been
475 // resolved!
476 //
477 if (!GlobalRefs.empty()) {
478 std::string UndefinedReferences = "Unresolved global references exist:\n";
479
480 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
481 I != E; ++I) {
482 UndefinedReferences += " " + I->first.first->getDescription() + " " +
483 I->first.second.getName() + "\n";
484 }
485 GenerateError(UndefinedReferences);
486 return;
487 }
488
Chandler Carruth563d4a42007-08-04 01:56:21 +0000489 // Look for intrinsic functions and CallInst that need to be upgraded
490 for (Module::iterator FI = CurrentModule->begin(),
491 FE = CurrentModule->end(); FI != FE; )
492 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
493
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 Values.clear(); // Clear out function local definitions
495 Types.clear();
496 CurrentModule = 0;
497 }
498
499 // GetForwardRefForGlobal - Check to see if there is a forward reference
500 // for this global. If so, remove it from the GlobalRefs map and return it.
501 // If not, just return null.
502 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
503 // Check to see if there is a forward reference to this global variable...
504 // if there is, eliminate it and patch the reference to use the new def'n.
505 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
506 GlobalValue *Ret = 0;
507 if (I != GlobalRefs.end()) {
508 Ret = I->second;
509 GlobalRefs.erase(I);
510 }
511 return Ret;
512 }
513
514 bool TypeIsUnresolved(PATypeHolder* PATy) {
515 // If it isn't abstract, its resolved
516 const Type* Ty = PATy->get();
517 if (!Ty->isAbstract())
518 return false;
519 // Traverse the type looking for abstract types. If it isn't abstract then
520 // we don't need to traverse that leg of the type.
521 std::vector<const Type*> WorkList, SeenList;
522 WorkList.push_back(Ty);
523 while (!WorkList.empty()) {
524 const Type* Ty = WorkList.back();
525 SeenList.push_back(Ty);
526 WorkList.pop_back();
527 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
528 // Check to see if this is an unresolved type
529 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
530 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
531 for ( ; I != E; ++I) {
532 if (I->second.get() == OpTy)
533 return true;
534 }
535 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
536 const Type* TheTy = SeqTy->getElementType();
537 if (TheTy->isAbstract() && TheTy != Ty) {
538 std::vector<const Type*>::iterator I = SeenList.begin(),
539 E = SeenList.end();
540 for ( ; I != E; ++I)
541 if (*I == TheTy)
542 break;
543 if (I == E)
544 WorkList.push_back(TheTy);
545 }
546 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
547 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
548 const Type* TheTy = StrTy->getElementType(i);
549 if (TheTy->isAbstract() && TheTy != Ty) {
550 std::vector<const Type*>::iterator I = SeenList.begin(),
551 E = SeenList.end();
552 for ( ; I != E; ++I)
553 if (*I == TheTy)
554 break;
555 if (I == E)
556 WorkList.push_back(TheTy);
557 }
558 }
559 }
560 }
561 return false;
562 }
563} CurModule;
564
565static struct PerFunctionInfo {
566 Function *CurrentFunction; // Pointer to current function being created
567
568 ValueList Values; // Keep track of #'d definitions
569 unsigned NextValNum;
570 ValueList LateResolveValues;
571 bool isDeclare; // Is this function a forward declararation?
572 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
573 GlobalValue::VisibilityTypes Visibility;
574
575 /// BBForwardRefs - When we see forward references to basic blocks, keep
576 /// track of them here.
577 std::map<ValID, BasicBlock*> BBForwardRefs;
578
579 inline PerFunctionInfo() {
580 CurrentFunction = 0;
581 isDeclare = false;
582 Linkage = GlobalValue::ExternalLinkage;
583 Visibility = GlobalValue::DefaultVisibility;
584 }
585
586 inline void FunctionStart(Function *M) {
587 CurrentFunction = M;
588 NextValNum = 0;
589 }
590
591 void FunctionDone() {
592 // Any forward referenced blocks left?
593 if (!BBForwardRefs.empty()) {
594 GenerateError("Undefined reference to label " +
595 BBForwardRefs.begin()->second->getName());
596 return;
597 }
598
599 // Resolve all forward references now.
600 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
601
602 Values.clear(); // Clear out function local definitions
603 BBForwardRefs.clear();
604 CurrentFunction = 0;
605 isDeclare = false;
606 Linkage = GlobalValue::ExternalLinkage;
607 Visibility = GlobalValue::DefaultVisibility;
608 }
609} CurFun; // Info for the current function...
610
611static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
612
613
614//===----------------------------------------------------------------------===//
615// Code to handle definitions of all the types
616//===----------------------------------------------------------------------===//
617
618static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
619 // Things that have names or are void typed don't get slot numbers
620 if (V->hasName() || (V->getType() == Type::VoidTy))
621 return;
622
623 // In the case of function values, we have to allow for the forward reference
624 // of basic blocks, which are included in the numbering. Consequently, we keep
625 // track of the next insertion location with NextValNum. When a BB gets
626 // inserted, it could change the size of the CurFun.Values vector.
627 if (&ValueTab == &CurFun.Values) {
628 if (ValueTab.size() <= CurFun.NextValNum)
629 ValueTab.resize(CurFun.NextValNum+1);
630 ValueTab[CurFun.NextValNum++] = V;
631 return;
632 }
633 // For all other lists, its okay to just tack it on the back of the vector.
634 ValueTab.push_back(V);
635}
636
637static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
638 switch (D.Type) {
639 case ValID::LocalID: // Is it a numbered definition?
640 // Module constants occupy the lowest numbered slots...
641 if (D.Num < CurModule.Types.size())
642 return CurModule.Types[D.Num];
643 break;
644 case ValID::LocalName: // Is it a named definition?
645 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
646 D.destroy(); // Free old strdup'd memory...
647 return N;
648 }
649 break;
650 default:
651 GenerateError("Internal parser error: Invalid symbol type reference");
652 return 0;
653 }
654
655 // If we reached here, we referenced either a symbol that we don't know about
656 // or an id number that hasn't been read yet. We may be referencing something
657 // forward, so just create an entry to be resolved later and get to it...
658 //
659 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
660
661
662 if (inFunctionScope()) {
663 if (D.Type == ValID::LocalName) {
664 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
665 return 0;
666 } else {
667 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
668 return 0;
669 }
670 }
671
672 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
673 if (I != CurModule.LateResolveTypes.end())
674 return I->second;
675
676 Type *Typ = OpaqueType::get();
677 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
678 return Typ;
679 }
680
681// getExistingVal - Look up the value specified by the provided type and
682// the provided ValID. If the value exists and has already been defined, return
683// it. Otherwise return null.
684//
685static Value *getExistingVal(const Type *Ty, const ValID &D) {
686 if (isa<FunctionType>(Ty)) {
687 GenerateError("Functions are not values and "
688 "must be referenced as pointers");
689 return 0;
690 }
691
692 switch (D.Type) {
693 case ValID::LocalID: { // Is it a numbered definition?
694 // Check that the number is within bounds.
695 if (D.Num >= CurFun.Values.size())
696 return 0;
697 Value *Result = CurFun.Values[D.Num];
698 if (Ty != Result->getType()) {
699 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
700 Result->getType()->getDescription() + "' does not match "
701 "expected type, '" + Ty->getDescription() + "'");
702 return 0;
703 }
704 return Result;
705 }
706 case ValID::GlobalID: { // Is it a numbered definition?
707 if (D.Num >= CurModule.Values.size())
708 return 0;
709 Value *Result = CurModule.Values[D.Num];
710 if (Ty != Result->getType()) {
711 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
712 Result->getType()->getDescription() + "' does not match "
713 "expected type, '" + Ty->getDescription() + "'");
714 return 0;
715 }
716 return Result;
717 }
718
719 case ValID::LocalName: { // Is it a named definition?
720 if (!inFunctionScope())
721 return 0;
722 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
723 Value *N = SymTab.lookup(D.getName());
724 if (N == 0)
725 return 0;
726 if (N->getType() != Ty)
727 return 0;
728
729 D.destroy(); // Free old strdup'd memory...
730 return N;
731 }
732 case ValID::GlobalName: { // Is it a named definition?
733 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
734 Value *N = SymTab.lookup(D.getName());
735 if (N == 0)
736 return 0;
737 if (N->getType() != Ty)
738 return 0;
739
740 D.destroy(); // Free old strdup'd memory...
741 return N;
742 }
743
744 // Check to make sure that "Ty" is an integral type, and that our
745 // value will fit into the specified type...
746 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner59363a32008-02-19 04:36:25 +0000747 if (!isa<IntegerType>(Ty) ||
748 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 GenerateError("Signed integral constant '" +
750 itostr(D.ConstPool64) + "' is invalid for type '" +
751 Ty->getDescription() + "'");
752 return 0;
753 }
754 return ConstantInt::get(Ty, D.ConstPool64, true);
755
756 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000757 if (isa<IntegerType>(Ty) &&
758 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner59363a32008-02-19 04:36:25 +0000760
761 if (!isa<IntegerType>(Ty) ||
762 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
763 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
764 "' is invalid or out of range for type '" +
765 Ty->getDescription() + "'");
766 return 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 }
Chris Lattner59363a32008-02-19 04:36:25 +0000768 // This is really a signed reference. Transmogrify.
769 return ConstantInt::get(Ty, D.ConstPool64, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770
771 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000772 if (!Ty->isFloatingPoint() ||
773 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 GenerateError("FP constant invalid for type");
775 return 0;
776 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000777 // Lexer has no type info, so builds all float and double FP constants
778 // as double. Fix this here. Long double does not need this.
779 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
780 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000781 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
782 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783
784 case ValID::ConstNullVal: // Is it a null value?
785 if (!isa<PointerType>(Ty)) {
786 GenerateError("Cannot create a a non pointer null");
787 return 0;
788 }
789 return ConstantPointerNull::get(cast<PointerType>(Ty));
790
791 case ValID::ConstUndefVal: // Is it an undef value?
792 return UndefValue::get(Ty);
793
794 case ValID::ConstZeroVal: // Is it a zero value?
795 return Constant::getNullValue(Ty);
796
797 case ValID::ConstantVal: // Fully resolved constant?
798 if (D.ConstantValue->getType() != Ty) {
799 GenerateError("Constant expression type different from required type");
800 return 0;
801 }
802 return D.ConstantValue;
803
804 case ValID::InlineAsmVal: { // Inline asm expression
805 const PointerType *PTy = dyn_cast<PointerType>(Ty);
806 const FunctionType *FTy =
807 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
808 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
809 GenerateError("Invalid type for asm constraint string");
810 return 0;
811 }
812 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
813 D.IAD->HasSideEffects);
814 D.destroy(); // Free InlineAsmDescriptor.
815 return IA;
816 }
817 default:
818 assert(0 && "Unhandled case!");
819 return 0;
820 } // End of switch
821
822 assert(0 && "Unhandled case!");
823 return 0;
824}
825
826// getVal - This function is identical to getExistingVal, except that if a
827// value is not already defined, it "improvises" by creating a placeholder var
828// that looks and acts just like the requested variable. When the value is
829// defined later, all uses of the placeholder variable are replaced with the
830// real thing.
831//
832static Value *getVal(const Type *Ty, const ValID &ID) {
833 if (Ty == Type::LabelTy) {
834 GenerateError("Cannot use a basic block here");
835 return 0;
836 }
837
838 // See if the value has already been defined.
839 Value *V = getExistingVal(Ty, ID);
840 if (V) return V;
841 if (TriggerError) return 0;
842
843 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
844 GenerateError("Invalid use of a composite type");
845 return 0;
846 }
847
848 // If we reached here, we referenced either a symbol that we don't know about
849 // or an id number that hasn't been read yet. We may be referencing something
850 // forward, so just create an entry to be resolved later and get to it...
851 //
852 switch (ID.Type) {
853 case ValID::GlobalName:
854 case ValID::GlobalID: {
855 const PointerType *PTy = dyn_cast<PointerType>(Ty);
856 if (!PTy) {
857 GenerateError("Invalid type for reference to global" );
858 return 0;
859 }
860 const Type* ElTy = PTy->getElementType();
861 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
862 V = new Function(FTy, GlobalValue::ExternalLinkage);
863 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000864 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
865 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 break;
867 }
868 default:
869 V = new Argument(Ty);
870 }
871
872 // Remember where this forward reference came from. FIXME, shouldn't we try
873 // to recycle these things??
874 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000875 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
877 if (inFunctionScope())
878 InsertValue(V, CurFun.LateResolveValues);
879 else
880 InsertValue(V, CurModule.LateResolveValues);
881 return V;
882}
883
884/// defineBBVal - This is a definition of a new basic block with the specified
885/// identifier which must be the same as CurFun.NextValNum, if its numeric.
886static BasicBlock *defineBBVal(const ValID &ID) {
887 assert(inFunctionScope() && "Can't get basic block at global scope!");
888
889 BasicBlock *BB = 0;
890
891 // First, see if this was forward referenced
892
893 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
894 if (BBI != CurFun.BBForwardRefs.end()) {
895 BB = BBI->second;
896 // The forward declaration could have been inserted anywhere in the
897 // function: insert it into the correct place now.
898 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
899 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
900
901 // We're about to erase the entry, save the key so we can clean it up.
902 ValID Tmp = BBI->first;
903
904 // Erase the forward ref from the map as its no longer "forward"
905 CurFun.BBForwardRefs.erase(ID);
906
907 // The key has been removed from the map but so we don't want to leave
908 // strdup'd memory around so destroy it too.
909 Tmp.destroy();
910
911 // If its a numbered definition, bump the number and set the BB value.
912 if (ID.Type == ValID::LocalID) {
913 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
914 InsertValue(BB);
915 }
916
917 ID.destroy();
918 return BB;
919 }
920
921 // We haven't seen this BB before and its first mention is a definition.
922 // Just create it and return it.
923 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
924 BB = new BasicBlock(Name, CurFun.CurrentFunction);
925 if (ID.Type == ValID::LocalID) {
926 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
927 InsertValue(BB);
928 }
929
930 ID.destroy(); // Free strdup'd memory
931 return BB;
932}
933
934/// getBBVal - get an existing BB value or create a forward reference for it.
935///
936static BasicBlock *getBBVal(const ValID &ID) {
937 assert(inFunctionScope() && "Can't get basic block at global scope!");
938
939 BasicBlock *BB = 0;
940
941 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
942 if (BBI != CurFun.BBForwardRefs.end()) {
943 BB = BBI->second;
944 } if (ID.Type == ValID::LocalName) {
945 std::string Name = ID.getName();
946 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
947 if (N)
948 if (N->getType()->getTypeID() == Type::LabelTyID)
949 BB = cast<BasicBlock>(N);
950 else
951 GenerateError("Reference to label '" + Name + "' is actually of type '"+
952 N->getType()->getDescription() + "'");
953 } else if (ID.Type == ValID::LocalID) {
954 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
955 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
956 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
957 else
958 GenerateError("Reference to label '%" + utostr(ID.Num) +
959 "' is actually of type '"+
960 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
961 }
962 } else {
963 GenerateError("Illegal label reference " + ID.getName());
964 return 0;
965 }
966
967 // If its already been defined, return it now.
968 if (BB) {
969 ID.destroy(); // Free strdup'd memory.
970 return BB;
971 }
972
973 // Otherwise, this block has not been seen before, create it.
974 std::string Name;
975 if (ID.Type == ValID::LocalName)
976 Name = ID.getName();
977 BB = new BasicBlock(Name, CurFun.CurrentFunction);
978
979 // Insert it in the forward refs map.
980 CurFun.BBForwardRefs[ID] = BB;
981
982 return BB;
983}
984
985
986//===----------------------------------------------------------------------===//
987// Code to handle forward references in instructions
988//===----------------------------------------------------------------------===//
989//
990// This code handles the late binding needed with statements that reference
991// values not defined yet... for example, a forward branch, or the PHI node for
992// a loop body.
993//
994// This keeps a table (CurFun.LateResolveValues) of all such forward references
995// and back patchs after we are done.
996//
997
998// ResolveDefinitions - If we could not resolve some defs at parsing
999// time (forward branches, phi functions for loops, etc...) resolve the
1000// defs now...
1001//
1002static void
1003ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1004 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1005 while (!LateResolvers.empty()) {
1006 Value *V = LateResolvers.back();
1007 LateResolvers.pop_back();
1008
1009 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1010 CurModule.PlaceHolderInfo.find(V);
1011 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1012
1013 ValID &DID = PHI->second.first;
1014
1015 Value *TheRealValue = getExistingVal(V->getType(), DID);
1016 if (TriggerError)
1017 return;
1018 if (TheRealValue) {
1019 V->replaceAllUsesWith(TheRealValue);
1020 delete V;
1021 CurModule.PlaceHolderInfo.erase(PHI);
1022 } else if (FutureLateResolvers) {
1023 // Functions have their unresolved items forwarded to the module late
1024 // resolver table
1025 InsertValue(V, *FutureLateResolvers);
1026 } else {
1027 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1028 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1029 "' of type '" + V->getType()->getDescription() + "'",
1030 PHI->second.second);
1031 return;
1032 } else {
1033 GenerateError("Reference to an invalid definition: #" +
1034 itostr(DID.Num) + " of type '" +
1035 V->getType()->getDescription() + "'",
1036 PHI->second.second);
1037 return;
1038 }
1039 }
1040 }
1041 LateResolvers.clear();
1042}
1043
1044// ResolveTypeTo - A brand new type was just declared. This means that (if
1045// name is not null) things referencing Name can be resolved. Otherwise, things
1046// refering to the number can be resolved. Do this now.
1047//
1048static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1049 ValID D;
1050 if (Name)
1051 D = ValID::createLocalName(*Name);
1052 else
1053 D = ValID::createLocalID(CurModule.Types.size());
1054
1055 std::map<ValID, PATypeHolder>::iterator I =
1056 CurModule.LateResolveTypes.find(D);
1057 if (I != CurModule.LateResolveTypes.end()) {
1058 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1059 CurModule.LateResolveTypes.erase(I);
1060 }
1061}
1062
1063// setValueName - Set the specified value to the name given. The name may be
1064// null potentially, in which case this is a noop. The string passed in is
1065// assumed to be a malloc'd string buffer, and is free'd by this function.
1066//
1067static void setValueName(Value *V, std::string *NameStr) {
1068 if (!NameStr) return;
1069 std::string Name(*NameStr); // Copy string
1070 delete NameStr; // Free old string
1071
1072 if (V->getType() == Type::VoidTy) {
1073 GenerateError("Can't assign name '" + Name+"' to value with void type");
1074 return;
1075 }
1076
1077 assert(inFunctionScope() && "Must be in function scope!");
1078 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1079 if (ST.lookup(Name)) {
1080 GenerateError("Redefinition of value '" + Name + "' of type '" +
1081 V->getType()->getDescription() + "'");
1082 return;
1083 }
1084
1085 // Set the name.
1086 V->setName(Name);
1087}
1088
1089/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1090/// this is a declaration, otherwise it is a definition.
1091static GlobalVariable *
1092ParseGlobalVariable(std::string *NameStr,
1093 GlobalValue::LinkageTypes Linkage,
1094 GlobalValue::VisibilityTypes Visibility,
1095 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +00001096 Constant *Initializer, bool IsThreadLocal,
1097 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 if (isa<FunctionType>(Ty)) {
1099 GenerateError("Cannot declare global vars of function type");
1100 return 0;
1101 }
1102
Christopher Lamb0a243582007-12-11 09:02:08 +00001103 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104
1105 std::string Name;
1106 if (NameStr) {
1107 Name = *NameStr; // Copy string
1108 delete NameStr; // Free old string
1109 }
1110
1111 // See if this global value was forward referenced. If so, recycle the
1112 // object.
1113 ValID ID;
1114 if (!Name.empty()) {
1115 ID = ValID::createGlobalName(Name);
1116 } else {
1117 ID = ValID::createGlobalID(CurModule.Values.size());
1118 }
1119
1120 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1121 // Move the global to the end of the list, from whereever it was
1122 // previously inserted.
1123 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1124 CurModule.CurrentModule->getGlobalList().remove(GV);
1125 CurModule.CurrentModule->getGlobalList().push_back(GV);
1126 GV->setInitializer(Initializer);
1127 GV->setLinkage(Linkage);
1128 GV->setVisibility(Visibility);
1129 GV->setConstant(isConstantGlobal);
1130 GV->setThreadLocal(IsThreadLocal);
1131 InsertValue(GV, CurModule.Values);
1132 return GV;
1133 }
1134
1135 // If this global has a name
1136 if (!Name.empty()) {
1137 // if the global we're parsing has an initializer (is a definition) and
1138 // has external linkage.
1139 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1140 // If there is already a global with external linkage with this name
1141 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1142 // If we allow this GVar to get created, it will be renamed in the
1143 // symbol table because it conflicts with an existing GVar. We can't
1144 // allow redefinition of GVars whose linking indicates that their name
1145 // must stay the same. Issue the error.
1146 GenerateError("Redefinition of global variable named '" + Name +
1147 "' of type '" + Ty->getDescription() + "'");
1148 return 0;
1149 }
1150 }
1151
1152 // Otherwise there is no existing GV to use, create one now.
1153 GlobalVariable *GV =
1154 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +00001155 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 GV->setVisibility(Visibility);
1157 InsertValue(GV, CurModule.Values);
1158 return GV;
1159}
1160
1161// setTypeName - Set the specified type to the name given. The name may be
1162// null potentially, in which case this is a noop. The string passed in is
1163// assumed to be a malloc'd string buffer, and is freed by this function.
1164//
1165// This function returns true if the type has already been defined, but is
1166// allowed to be redefined in the specified context. If the name is a new name
1167// for the type plane, it is inserted and false is returned.
1168static bool setTypeName(const Type *T, std::string *NameStr) {
1169 assert(!inFunctionScope() && "Can't give types function-local names!");
1170 if (NameStr == 0) return false;
1171
1172 std::string Name(*NameStr); // Copy string
1173 delete NameStr; // Free old string
1174
1175 // We don't allow assigning names to void type
1176 if (T == Type::VoidTy) {
1177 GenerateError("Can't assign name '" + Name + "' to the void type");
1178 return false;
1179 }
1180
1181 // Set the type name, checking for conflicts as we do so.
1182 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1183
1184 if (AlreadyExists) { // Inserting a name that is already defined???
1185 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1186 assert(Existing && "Conflict but no matching type?!");
1187
1188 // There is only one case where this is allowed: when we are refining an
1189 // opaque type. In this case, Existing will be an opaque type.
1190 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1191 // We ARE replacing an opaque type!
1192 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1193 return true;
1194 }
1195
1196 // Otherwise, this is an attempt to redefine a type. That's okay if
1197 // the redefinition is identical to the original. This will be so if
1198 // Existing and T point to the same Type object. In this one case we
1199 // allow the equivalent redefinition.
1200 if (Existing == T) return true; // Yes, it's equal.
1201
1202 // Any other kind of (non-equivalent) redefinition is an error.
1203 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1204 T->getDescription() + "'");
1205 }
1206
1207 return false;
1208}
1209
1210//===----------------------------------------------------------------------===//
1211// Code for handling upreferences in type names...
1212//
1213
1214// TypeContains - Returns true if Ty directly contains E in it.
1215//
1216static bool TypeContains(const Type *Ty, const Type *E) {
1217 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1218 E) != Ty->subtype_end();
1219}
1220
1221namespace {
1222 struct UpRefRecord {
1223 // NestingLevel - The number of nesting levels that need to be popped before
1224 // this type is resolved.
1225 unsigned NestingLevel;
1226
1227 // LastContainedTy - This is the type at the current binding level for the
1228 // type. Every time we reduce the nesting level, this gets updated.
1229 const Type *LastContainedTy;
1230
1231 // UpRefTy - This is the actual opaque type that the upreference is
1232 // represented with.
1233 OpaqueType *UpRefTy;
1234
1235 UpRefRecord(unsigned NL, OpaqueType *URTy)
1236 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1237 };
1238}
1239
1240// UpRefs - A list of the outstanding upreferences that need to be resolved.
1241static std::vector<UpRefRecord> UpRefs;
1242
1243/// HandleUpRefs - Every time we finish a new layer of types, this function is
1244/// called. It loops through the UpRefs vector, which is a list of the
1245/// currently active types. For each type, if the up reference is contained in
1246/// the newly completed type, we decrement the level count. When the level
1247/// count reaches zero, the upreferenced type is the type that is passed in:
1248/// thus we can complete the cycle.
1249///
1250static PATypeHolder HandleUpRefs(const Type *ty) {
1251 // If Ty isn't abstract, or if there are no up-references in it, then there is
1252 // nothing to resolve here.
1253 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1254
1255 PATypeHolder Ty(ty);
1256 UR_OUT("Type '" << Ty->getDescription() <<
1257 "' newly formed. Resolving upreferences.\n" <<
1258 UpRefs.size() << " upreferences active!\n");
1259
1260 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1261 // to zero), we resolve them all together before we resolve them to Ty. At
1262 // the end of the loop, if there is anything to resolve to Ty, it will be in
1263 // this variable.
1264 OpaqueType *TypeToResolve = 0;
1265
1266 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1267 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1268 << UpRefs[i].second->getDescription() << ") = "
1269 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1270 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1271 // Decrement level of upreference
1272 unsigned Level = --UpRefs[i].NestingLevel;
1273 UpRefs[i].LastContainedTy = Ty;
1274 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1275 if (Level == 0) { // Upreference should be resolved!
1276 if (!TypeToResolve) {
1277 TypeToResolve = UpRefs[i].UpRefTy;
1278 } else {
1279 UR_OUT(" * Resolving upreference for "
1280 << UpRefs[i].second->getDescription() << "\n";
1281 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1282 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1283 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1284 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1285 }
1286 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1287 --i; // Do not skip the next element...
1288 }
1289 }
1290 }
1291
1292 if (TypeToResolve) {
1293 UR_OUT(" * Resolving upreference for "
1294 << UpRefs[i].second->getDescription() << "\n";
1295 std::string OldName = TypeToResolve->getDescription());
1296 TypeToResolve->refineAbstractTypeTo(Ty);
1297 }
1298
1299 return Ty;
1300}
1301
1302//===----------------------------------------------------------------------===//
1303// RunVMAsmParser - Define an interface to this parser
1304//===----------------------------------------------------------------------===//
1305//
1306static Module* RunParser(Module * M);
1307
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001308Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1309 InitLLLexer(MB);
1310 Module *M = RunParser(new Module(LLLgetFilename()));
1311 FreeLexer();
1312 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313}
1314
1315
Chris Lattner59363a32008-02-19 04:36:25 +00001316
1317/* Enabling traces. */
1318#ifndef YYDEBUG
1319# define YYDEBUG 0
1320#endif
1321
1322/* Enabling verbose error messages. */
1323#ifdef YYERROR_VERBOSE
1324# undef YYERROR_VERBOSE
1325# define YYERROR_VERBOSE 1
1326#else
1327# define YYERROR_VERBOSE 0
1328#endif
1329
1330/* Enabling the token table. */
1331#ifndef YYTOKEN_TABLE
1332# define YYTOKEN_TABLE 0
1333#endif
1334
1335#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1336typedef union YYSTYPE
1337#line 951 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
1338{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 llvm::Module *ModuleVal;
1340 llvm::Function *FunctionVal;
1341 llvm::BasicBlock *BasicBlockVal;
1342 llvm::TerminatorInst *TermInstVal;
1343 llvm::Instruction *InstVal;
1344 llvm::Constant *ConstVal;
1345
1346 const llvm::Type *PrimType;
1347 std::list<llvm::PATypeHolder> *TypeList;
1348 llvm::PATypeHolder *TypeVal;
1349 llvm::Value *ValueVal;
1350 std::vector<llvm::Value*> *ValueList;
1351 llvm::ArgListType *ArgList;
1352 llvm::TypeWithAttrs TypeWithAttrs;
1353 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001354 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355
1356 // Represent the RHS of PHI node
1357 std::list<std::pair<llvm::Value*,
1358 llvm::BasicBlock*> > *PHIList;
1359 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1360 std::vector<llvm::Constant*> *ConstVector;
1361
1362 llvm::GlobalValue::LinkageTypes Linkage;
1363 llvm::GlobalValue::VisibilityTypes Visibility;
1364 uint16_t ParamAttrs;
1365 llvm::APInt *APIntVal;
1366 int64_t SInt64Val;
1367 uint64_t UInt64Val;
1368 int SIntVal;
1369 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001370 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 bool BoolVal;
1372
1373 std::string *StrVal; // This memory must be deleted
1374 llvm::ValID ValIDVal;
1375
1376 llvm::Instruction::BinaryOps BinaryOpVal;
1377 llvm::Instruction::TermOps TermOpVal;
1378 llvm::Instruction::MemoryOps MemOpVal;
1379 llvm::Instruction::CastOps CastOpVal;
1380 llvm::Instruction::OtherOps OtherOpVal;
1381 llvm::ICmpInst::Predicate IPredicate;
1382 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner59363a32008-02-19 04:36:25 +00001383}
1384/* Line 193 of yacc.c. */
1385#line 1386 "llvmAsmParser.tab.c"
1386 YYSTYPE;
1387# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1388# define YYSTYPE_IS_DECLARED 1
1389# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390#endif
1391
1392
1393
Chris Lattner59363a32008-02-19 04:36:25 +00001394/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396
Chris Lattner59363a32008-02-19 04:36:25 +00001397/* Line 216 of yacc.c. */
1398#line 1399 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001399
Chris Lattner59363a32008-02-19 04:36:25 +00001400#ifdef short
1401# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402#endif
1403
Chris Lattner59363a32008-02-19 04:36:25 +00001404#ifdef YYTYPE_UINT8
1405typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406#else
Chris Lattner59363a32008-02-19 04:36:25 +00001407typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408#endif
1409
Chris Lattner59363a32008-02-19 04:36:25 +00001410#ifdef YYTYPE_INT8
1411typedef YYTYPE_INT8 yytype_int8;
1412#elif (defined __STDC__ || defined __C99__FUNC__ \
1413 || defined __cplusplus || defined _MSC_VER)
1414typedef signed char yytype_int8;
1415#else
1416typedef short int yytype_int8;
1417#endif
1418
1419#ifdef YYTYPE_UINT16
1420typedef YYTYPE_UINT16 yytype_uint16;
1421#else
1422typedef unsigned short int yytype_uint16;
1423#endif
1424
1425#ifdef YYTYPE_INT16
1426typedef YYTYPE_INT16 yytype_int16;
1427#else
1428typedef short int yytype_int16;
1429#endif
1430
1431#ifndef YYSIZE_T
1432# ifdef __SIZE_TYPE__
1433# define YYSIZE_T __SIZE_TYPE__
1434# elif defined size_t
1435# define YYSIZE_T size_t
1436# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1437 || defined __cplusplus || defined _MSC_VER)
1438# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1439# define YYSIZE_T size_t
1440# else
1441# define YYSIZE_T unsigned int
1442# endif
1443#endif
1444
1445#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1446
1447#ifndef YY_
1448# if defined YYENABLE_NLS && YYENABLE_NLS
1449# if ENABLE_NLS
1450# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1451# define YY_(msgid) dgettext ("bison-runtime", msgid)
1452# endif
1453# endif
1454# ifndef YY_
1455# define YY_(msgid) msgid
1456# endif
1457#endif
1458
1459/* Suppress unused-variable warnings by "using" E. */
1460#if ! defined lint || defined __GNUC__
1461# define YYUSE(e) ((void) (e))
1462#else
1463# define YYUSE(e) /* empty */
1464#endif
1465
1466/* Identity function, used to suppress warnings about constant conditions. */
1467#ifndef lint
1468# define YYID(n) (n)
1469#else
1470#if (defined __STDC__ || defined __C99__FUNC__ \
1471 || defined __cplusplus || defined _MSC_VER)
1472static int
1473YYID (int i)
1474#else
1475static int
1476YYID (i)
1477 int i;
1478#endif
1479{
1480 return i;
1481}
1482#endif
1483
1484#if ! defined yyoverflow || YYERROR_VERBOSE
1485
1486/* The parser invokes alloca or malloc; define the necessary symbols. */
1487
1488# ifdef YYSTACK_USE_ALLOCA
1489# if YYSTACK_USE_ALLOCA
1490# ifdef __GNUC__
1491# define YYSTACK_ALLOC __builtin_alloca
1492# elif defined __BUILTIN_VA_ARG_INCR
1493# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1494# elif defined _AIX
1495# define YYSTACK_ALLOC __alloca
1496# elif defined _MSC_VER
1497# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1498# define alloca _alloca
1499# else
1500# define YYSTACK_ALLOC alloca
1501# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1502 || defined __cplusplus || defined _MSC_VER)
1503# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1504# ifndef _STDLIB_H
1505# define _STDLIB_H 1
1506# endif
1507# endif
1508# endif
1509# endif
1510# endif
1511
1512# ifdef YYSTACK_ALLOC
1513 /* Pacify GCC's `empty if-body' warning. */
1514# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1515# ifndef YYSTACK_ALLOC_MAXIMUM
1516 /* The OS might guarantee only one guard page at the bottom of the stack,
1517 and a page size can be as small as 4096 bytes. So we cannot safely
1518 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1519 to allow for a few compiler-allocated temporary stack slots. */
1520# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1521# endif
1522# else
1523# define YYSTACK_ALLOC YYMALLOC
1524# define YYSTACK_FREE YYFREE
1525# ifndef YYSTACK_ALLOC_MAXIMUM
1526# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1527# endif
1528# if (defined __cplusplus && ! defined _STDLIB_H \
1529 && ! ((defined YYMALLOC || defined malloc) \
1530 && (defined YYFREE || defined free)))
1531# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1532# ifndef _STDLIB_H
1533# define _STDLIB_H 1
1534# endif
1535# endif
1536# ifndef YYMALLOC
1537# define YYMALLOC malloc
1538# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1539 || defined __cplusplus || defined _MSC_VER)
1540void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1541# endif
1542# endif
1543# ifndef YYFREE
1544# define YYFREE free
1545# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1546 || defined __cplusplus || defined _MSC_VER)
1547void free (void *); /* INFRINGES ON USER NAME SPACE */
1548# endif
1549# endif
1550# endif
1551#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1552
1553
1554#if (! defined yyoverflow \
1555 && (! defined __cplusplus \
1556 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1557
1558/* A type that is properly aligned for any stack member. */
1559union yyalloc
1560{
1561 yytype_int16 yyss;
1562 YYSTYPE yyvs;
1563 };
1564
1565/* The size of the maximum gap between one aligned stack and the next. */
1566# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1567
1568/* The size of an array large to enough to hold all stacks, each with
1569 N elements. */
1570# define YYSTACK_BYTES(N) \
1571 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1572 + YYSTACK_GAP_MAXIMUM)
1573
1574/* Copy COUNT objects from FROM to TO. The source and destination do
1575 not overlap. */
1576# ifndef YYCOPY
1577# if defined __GNUC__ && 1 < __GNUC__
1578# define YYCOPY(To, From, Count) \
1579 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1580# else
1581# define YYCOPY(To, From, Count) \
1582 do \
1583 { \
1584 YYSIZE_T yyi; \
1585 for (yyi = 0; yyi < (Count); yyi++) \
1586 (To)[yyi] = (From)[yyi]; \
1587 } \
1588 while (YYID (0))
1589# endif
1590# endif
1591
1592/* Relocate STACK from its old location to the new one. The
1593 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1594 elements in the stack, and YYPTR gives the new location of the
1595 stack. Advance YYPTR to a properly aligned location for the next
1596 stack. */
1597# define YYSTACK_RELOCATE(Stack) \
1598 do \
1599 { \
1600 YYSIZE_T yynewbytes; \
1601 YYCOPY (&yyptr->Stack, Stack, yysize); \
1602 Stack = &yyptr->Stack; \
1603 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1604 yyptr += yynewbytes / sizeof (*yyptr); \
1605 } \
1606 while (YYID (0))
1607
1608#endif
1609
1610/* YYFINAL -- State number of the termination state. */
1611#define YYFINAL 43
1612/* YYLAST -- Last index in YYTABLE. */
1613#define YYLAST 1988
1614
1615/* YYNTOKENS -- Number of terminals. */
1616#define YYNTOKENS 164
1617/* YYNNTS -- Number of nonterminals. */
1618#define YYNNTS 84
1619/* YYNRULES -- Number of rules. */
1620#define YYNRULES 318
1621/* YYNRULES -- Number of states. */
1622#define YYNSTATES 619
1623
1624/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1625#define YYUNDEFTOK 2
1626#define YYMAXUTOK 404
1627
1628#define YYTRANSLATE(YYX) \
1629 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1630
1631/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1632static const yytype_uint8 yytranslate[] =
1633{
1634 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1638 150, 151, 154, 2, 153, 2, 2, 2, 2, 2,
1639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1640 159, 152, 160, 2, 2, 2, 2, 2, 2, 2,
1641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1643 2, 156, 155, 158, 2, 2, 2, 2, 2, 163,
1644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 157, 2, 2, 161, 2, 162, 2, 2, 2, 2,
1647 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1660 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1661 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1662 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1663 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1664 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1665 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1666 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1667 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1668 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1669 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1670 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1671 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1672 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1673 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1674 145, 146, 147, 148, 149
1675};
1676
1677#if YYDEBUG
1678/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1679 YYRHS. */
1680static const yytype_uint16 yyprhs[] =
1681{
1682 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1683 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1684 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1685 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1686 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1687 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1688 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
1689 140, 142, 144, 146, 147, 150, 152, 154, 156, 158,
1690 160, 162, 164, 166, 167, 169, 171, 173, 174, 176,
1691 178, 179, 181, 183, 185, 187, 188, 190, 192, 193,
1692 195, 197, 199, 201, 203, 206, 208, 210, 212, 214,
1693 216, 218, 220, 222, 224, 225, 228, 230, 232, 234,
1694 236, 238, 240, 241, 244, 245, 248, 249, 252, 253,
1695 257, 260, 261, 263, 264, 268, 270, 273, 275, 277,
1696 279, 281, 283, 285, 287, 289, 291, 295, 297, 300,
1697 306, 312, 318, 324, 328, 331, 337, 342, 345, 347,
1698 349, 351, 355, 357, 361, 363, 364, 366, 370, 375,
1699 379, 383, 388, 393, 397, 404, 410, 413, 416, 419,
1700 422, 425, 428, 431, 434, 437, 440, 443, 446, 453,
1701 459, 468, 475, 482, 490, 498, 505, 514, 523, 527,
1702 529, 531, 533, 535, 536, 539, 546, 548, 549, 551,
1703 554, 555, 559, 560, 564, 568, 572, 576, 577, 586,
1704 587, 597, 598, 608, 614, 617, 621, 623, 627, 631,
1705 635, 639, 641, 642, 648, 652, 654, 658, 660, 661,
1706 672, 674, 676, 681, 683, 685, 688, 692, 693, 695,
1707 697, 699, 701, 703, 705, 707, 709, 711, 715, 717,
1708 723, 725, 727, 729, 731, 733, 735, 738, 741, 744,
1709 748, 751, 752, 754, 757, 760, 764, 774, 784, 793,
1710 808, 810, 812, 819, 825, 828, 835, 843, 848, 853,
1711 860, 867, 868, 869, 873, 876, 878, 884, 890, 897,
1712 904, 909, 916, 921, 926, 933, 940, 943, 952, 954,
1713 956, 957, 961, 968, 972, 979, 982, 988, 996
1714};
1715
1716/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1717static const yytype_int16 yyrhs[] =
1718{
1719 210, 0, -1, 74, -1, 75, -1, 76, -1, 77,
1720 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1721 -1, 86, -1, 87, -1, 88, -1, 83, -1, 84,
1722 -1, 85, -1, 117, -1, 118, -1, 119, -1, 120,
1723 -1, 121, -1, 122, -1, 123, -1, 124, -1, 125,
1724 -1, 126, -1, 127, -1, 128, -1, 91, -1, 92,
1725 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1726 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1727 -1, 103, -1, 104, -1, 105, -1, 106, -1, 107,
1728 -1, 108, -1, 109, -1, 110, -1, 97, -1, 98,
1729 -1, 99, -1, 100, -1, 26, -1, 27, -1, 11,
1730 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1731 -1, 19, -1, 22, -1, 24, -1, 172, -1, -1,
1732 54, 150, 4, 151, -1, -1, 172, 152, -1, -1,
1733 20, -1, 23, -1, 178, -1, -1, 176, 152, -1,
1734 42, -1, 44, -1, 43, -1, 45, -1, 47, -1,
1735 46, -1, 48, -1, 50, -1, -1, 147, -1, 148,
1736 -1, 149, -1, -1, 46, -1, 48, -1, -1, 42,
1737 -1, 43, -1, 44, -1, 47, -1, -1, 44, -1,
1738 42, -1, -1, 62, -1, 63, -1, 64, -1, 65,
1739 -1, 66, -1, 61, 4, -1, 136, -1, 118, -1,
1740 135, -1, 119, -1, 138, -1, 139, -1, 141, -1,
1741 142, -1, 143, -1, -1, 187, 186, -1, 137, -1,
1742 140, -1, 136, -1, 135, -1, 144, -1, 145, -1,
1743 -1, 189, 188, -1, -1, 146, 22, -1, -1, 53,
1744 4, -1, -1, 153, 53, 4, -1, 34, 22, -1,
1745 -1, 193, -1, -1, 153, 196, 195, -1, 193, -1,
1746 53, 4, -1, 11, -1, 12, -1, 13, -1, 16,
1747 -1, 15, -1, 14, -1, 17, -1, 49, -1, 197,
1748 -1, 198, 174, 154, -1, 232, -1, 155, 4, -1,
1749 198, 150, 202, 151, 189, -1, 10, 150, 202, 151,
1750 189, -1, 156, 4, 157, 198, 158, -1, 159, 4,
1751 157, 198, 160, -1, 161, 203, 162, -1, 161, 162,
1752 -1, 159, 161, 203, 162, 160, -1, 159, 161, 162,
1753 160, -1, 198, 187, -1, 198, -1, 10, -1, 199,
1754 -1, 201, 153, 199, -1, 201, -1, 201, 153, 39,
1755 -1, 39, -1, -1, 198, -1, 203, 153, 198, -1,
1756 198, 156, 206, 158, -1, 198, 156, 158, -1, 198,
1757 163, 22, -1, 198, 159, 206, 160, -1, 198, 161,
1758 206, 162, -1, 198, 161, 162, -1, 198, 159, 161,
1759 206, 162, 160, -1, 198, 159, 161, 162, 160, -1,
1760 198, 40, -1, 198, 41, -1, 198, 232, -1, 198,
1761 205, -1, 198, 25, -1, 170, 3, -1, 170, 5,
1762 -1, 170, 4, -1, 170, 6, -1, 11, 26, -1,
1763 11, 27, -1, 171, 9, -1, 167, 150, 204, 38,
1764 198, 151, -1, 116, 150, 204, 243, 151, -1, 130,
1765 150, 204, 153, 204, 153, 204, 151, -1, 165, 150,
1766 204, 153, 204, 151, -1, 166, 150, 204, 153, 204,
1767 151, -1, 89, 168, 150, 204, 153, 204, 151, -1,
1768 90, 169, 150, 204, 153, 204, 151, -1, 132, 150,
1769 204, 153, 204, 151, -1, 133, 150, 204, 153, 204,
1770 153, 204, 151, -1, 134, 150, 204, 153, 204, 153,
1771 204, 151, -1, 206, 153, 204, -1, 204, -1, 32,
1772 -1, 33, -1, 37, -1, -1, 200, 232, -1, 122,
1773 150, 209, 38, 198, 151, -1, 211, -1, -1, 212,
1774 -1, 211, 212, -1, -1, 31, 213, 228, -1, -1,
1775 30, 214, 229, -1, 59, 58, 218, -1, 175, 18,
1776 198, -1, 175, 18, 10, -1, -1, 177, 181, 208,
1777 207, 204, 174, 215, 195, -1, -1, 177, 179, 181,
1778 208, 207, 204, 174, 216, 195, -1, -1, 177, 180,
1779 181, 208, 207, 198, 174, 217, 195, -1, 177, 181,
1780 35, 184, 209, -1, 51, 219, -1, 55, 152, 220,
1781 -1, 22, -1, 52, 152, 22, -1, 67, 152, 22,
1782 -1, 156, 221, 158, -1, 221, 153, 22, -1, 22,
1783 -1, -1, 222, 153, 198, 187, 173, -1, 198, 187,
1784 173, -1, 222, -1, 222, 153, 39, -1, 39, -1,
1785 -1, 185, 200, 176, 150, 223, 151, 189, 194, 191,
1786 190, -1, 28, -1, 161, -1, 183, 181, 224, 225,
1787 -1, 29, -1, 162, -1, 235, 227, -1, 182, 181,
1788 224, -1, -1, 60, -1, 3, -1, 4, -1, 9,
1789 -1, 26, -1, 27, -1, 40, -1, 41, -1, 25,
1790 -1, 159, 206, 160, -1, 205, -1, 58, 230, 22,
1791 153, 22, -1, 7, -1, 8, -1, 172, -1, 176,
1792 -1, 232, -1, 231, -1, 198, 233, -1, 235, 236,
1793 -1, 226, 236, -1, 237, 175, 238, -1, 237, 240,
1794 -1, -1, 21, -1, 68, 234, -1, 68, 10, -1,
1795 69, 17, 233, -1, 69, 11, 233, 153, 17, 233,
1796 153, 17, 233, -1, 70, 170, 233, 153, 17, 233,
1797 156, 239, 158, -1, 70, 170, 233, 153, 17, 233,
1798 156, 158, -1, 71, 185, 200, 233, 150, 242, 151,
1799 189, 38, 17, 233, 72, 17, 233, -1, 72, -1,
1800 73, -1, 239, 170, 231, 153, 17, 233, -1, 170,
1801 231, 153, 17, 233, -1, 175, 245, -1, 198, 156,
1802 233, 153, 233, 158, -1, 241, 153, 156, 233, 153,
1803 233, 158, -1, 198, 187, 233, 187, -1, 17, 187,
1804 233, 187, -1, 242, 153, 198, 187, 233, 187, -1,
1805 242, 153, 17, 187, 233, 187, -1, -1, -1, 243,
1806 153, 234, -1, 57, 56, -1, 56, -1, 165, 198,
1807 233, 153, 233, -1, 166, 198, 233, 153, 233, -1,
1808 89, 168, 198, 233, 153, 233, -1, 90, 169, 198,
1809 233, 153, 233, -1, 167, 234, 38, 198, -1, 130,
1810 234, 153, 234, 153, 234, -1, 131, 234, 153, 198,
1811 -1, 132, 234, 153, 234, -1, 133, 234, 153, 234,
1812 153, 234, -1, 134, 234, 153, 234, 153, 234, -1,
1813 129, 241, -1, 244, 185, 200, 233, 150, 242, 151,
1814 189, -1, 247, -1, 36, -1, -1, 111, 198, 192,
1815 -1, 111, 198, 153, 11, 233, 192, -1, 112, 198,
1816 192, -1, 112, 198, 153, 11, 233, 192, -1, 113,
1817 234, -1, 246, 114, 198, 233, 192, -1, 246, 115,
1818 234, 153, 198, 233, 192, -1, 116, 198, 233, 243,
1819 -1
1820};
1821
1822/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1823static const yytype_uint16 yyrline[] =
1824{
1825 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1826 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1827 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117,
1828 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125,
1829 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130,
1830 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1139, 1139,
1831 1139, 1141, 1141, 1141, 1142, 1142, 1144, 1145, 1149, 1153,
1832 1158, 1158, 1160, 1161, 1166, 1172, 1173, 1174, 1175, 1176,
1833 1180, 1181, 1182, 1186, 1187, 1188, 1189, 1193, 1194, 1195,
1834 1199, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1212, 1213,
1835 1214, 1215, 1216, 1217, 1218, 1225, 1226, 1227, 1228, 1229,
1836 1230, 1231, 1232, 1233, 1236, 1237, 1242, 1243, 1244, 1245,
1837 1246, 1247, 1250, 1251, 1256, 1257, 1264, 1265, 1271, 1272,
1838 1281, 1289, 1290, 1295, 1296, 1297, 1302, 1315, 1315, 1315,
1839 1315, 1315, 1315, 1315, 1318, 1322, 1326, 1333, 1338, 1346,
1840 1376, 1401, 1406, 1416, 1426, 1430, 1440, 1447, 1456, 1463,
1841 1468, 1473, 1480, 1481, 1488, 1495, 1503, 1509, 1521, 1549,
1842 1565, 1592, 1620, 1646, 1666, 1692, 1712, 1724, 1731, 1797,
1843 1807, 1817, 1823, 1833, 1839, 1849, 1854, 1859, 1872, 1884,
1844 1906, 1914, 1920, 1931, 1936, 1941, 1947, 1953, 1962, 1966,
1845 1974, 1974, 1977, 1977, 1980, 1992, 2013, 2018, 2026, 2027,
1846 2031, 2031, 2035, 2035, 2038, 2041, 2065, 2077, 2076, 2088,
1847 2087, 2097, 2096, 2107, 2147, 2150, 2156, 2166, 2170, 2175,
1848 2177, 2182, 2187, 2196, 2206, 2217, 2221, 2230, 2239, 2244,
1849 2378, 2378, 2380, 2389, 2389, 2391, 2396, 2408, 2412, 2417,
1850 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2449, 2474, 2478,
1851 2488, 2492, 2496, 2501, 2508, 2508, 2514, 2523, 2527, 2536,
1852 2545, 2554, 2558, 2565, 2569, 2573, 2578, 2588, 2607, 2616,
1853 2707, 2711, 2718, 2729, 2742, 2752, 2763, 2773, 2784, 2792,
1854 2802, 2809, 2812, 2813, 2820, 2824, 2829, 2845, 2862, 2876,
1855 2890, 2902, 2910, 2917, 2923, 2929, 2935, 2950, 3048, 3053,
1856 3057, 3064, 3071, 3079, 3086, 3094, 3102, 3116, 3133
1857};
1858#endif
1859
1860#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1861/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1862 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1863static const char *const yytname[] =
1864{
1865 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1866 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1867 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1868 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1869 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1870 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1871 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1872 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1873 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1874 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1875 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1876 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
1877 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1878 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1879 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE",
1880 "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE",
1881 "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC",
1882 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT",
1883 "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI",
1884 "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "VAARG",
1885 "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT",
1886 "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST",
1887 "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN", "PROTECTED", "'('",
1888 "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'",
1889 "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps",
1890 "IPredicates", "FPredicates", "IntType", "FPType", "LocalName",
1891 "OptLocalName", "OptAddrSpace", "OptLocalAssign", "GlobalName",
1892 "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1893 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1894 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1895 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign",
1896 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
1897 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1898 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1899 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1900 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1901 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1902 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1903 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1904 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1905 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1906 "PHIList", "ParamList", "IndexList", "OptTailCall", "InstVal",
1907 "OptVolatile", "MemoryInst", 0
1908};
1909#endif
1910
1911# ifdef YYPRINT
1912/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1913 token YYLEX-NUM. */
1914static const yytype_uint16 yytoknum[] =
1915{
1916 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1917 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1918 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1919 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1920 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1921 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1922 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1923 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1924 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1925 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1926 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1927 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1928 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1929 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1930 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
1931 40, 41, 61, 44, 42, 92, 91, 120, 93, 60,
1932 62, 123, 125, 99
1933};
1934# endif
1935
1936/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1937static const yytype_uint8 yyr1[] =
1938{
1939 0, 164, 165, 165, 165, 165, 165, 165, 165, 165,
1940 165, 166, 166, 166, 166, 166, 166, 167, 167, 167,
1941 167, 167, 167, 167, 167, 167, 167, 167, 167, 168,
1942 168, 168, 168, 168, 168, 168, 168, 168, 168, 169,
1943 169, 169, 169, 169, 169, 169, 169, 169, 169, 169,
1944 169, 169, 169, 169, 169, 170, 171, 171, 171, 171,
1945 171, 172, 172, 172, 173, 173, 174, 174, 175, 175,
1946 176, 176, 177, 177, 178, 179, 179, 179, 179, 179,
1947 180, 180, 180, 181, 181, 181, 181, 182, 182, 182,
1948 183, 183, 183, 183, 183, 184, 184, 184, 185, 185,
1949 185, 185, 185, 185, 185, 186, 186, 186, 186, 186,
1950 186, 186, 186, 186, 187, 187, 188, 188, 188, 188,
1951 188, 188, 189, 189, 190, 190, 191, 191, 192, 192,
1952 193, 194, 194, 195, 195, 196, 196, 197, 197, 197,
1953 197, 197, 197, 197, 198, 198, 198, 198, 198, 198,
1954 198, 198, 198, 198, 198, 198, 198, 199, 200, 200,
1955 201, 201, 202, 202, 202, 202, 203, 203, 204, 204,
1956 204, 204, 204, 204, 204, 204, 204, 204, 204, 204,
1957 204, 204, 204, 204, 204, 204, 204, 204, 205, 205,
1958 205, 205, 205, 205, 205, 205, 205, 205, 206, 206,
1959 207, 207, 208, 208, 209, 209, 210, 210, 211, 211,
1960 213, 212, 214, 212, 212, 212, 212, 215, 212, 216,
1961 212, 217, 212, 212, 212, 212, 218, 219, 219, 220,
1962 221, 221, 221, 222, 222, 223, 223, 223, 223, 224,
1963 225, 225, 226, 227, 227, 228, 229, 230, 230, 231,
1964 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
1965 232, 232, 232, 232, 233, 233, 234, 235, 235, 236,
1966 237, 237, 237, 238, 238, 238, 238, 238, 238, 238,
1967 238, 238, 239, 239, 240, 241, 241, 242, 242, 242,
1968 242, 242, 243, 243, 244, 244, 245, 245, 245, 245,
1969 245, 245, 245, 245, 245, 245, 245, 245, 245, 246,
1970 246, 247, 247, 247, 247, 247, 247, 247, 247
1971};
1972
1973/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1974static const yytype_uint8 yyr2[] =
1975{
1976 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1977 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1978 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1979 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1980 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1981 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1982 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
1983 1, 1, 1, 0, 2, 1, 1, 1, 1, 1,
1984 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,
1985 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1986 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
1987 1, 1, 1, 1, 0, 2, 1, 1, 1, 1,
1988 1, 1, 0, 2, 0, 2, 0, 2, 0, 3,
1989 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 3, 1, 2, 5,
1991 5, 5, 5, 3, 2, 5, 4, 2, 1, 1,
1992 1, 3, 1, 3, 1, 0, 1, 3, 4, 3,
1993 3, 4, 4, 3, 6, 5, 2, 2, 2, 2,
1994 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1995 8, 6, 6, 7, 7, 6, 8, 8, 3, 1,
1996 1, 1, 1, 0, 2, 6, 1, 0, 1, 2,
1997 0, 3, 0, 3, 3, 3, 3, 0, 8, 0,
1998 9, 0, 9, 5, 2, 3, 1, 3, 3, 3,
1999 3, 1, 0, 5, 3, 1, 3, 1, 0, 10,
2000 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
2001 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
2002 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
2003 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
2004 1, 1, 6, 5, 2, 6, 7, 4, 4, 6,
2005 6, 0, 0, 3, 2, 1, 5, 5, 6, 6,
2006 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
2007 0, 3, 6, 3, 6, 2, 5, 7, 4
2008};
2009
2010/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2011 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2012 means the default is an error. */
2013static const yytype_uint16 yydefact[] =
2014{
2015 73, 61, 70, 62, 71, 63, 212, 210, 0, 0,
2016 0, 0, 0, 0, 83, 72, 0, 73, 208, 87,
2017 90, 0, 0, 224, 0, 0, 68, 0, 74, 75,
2018 77, 76, 78, 80, 79, 81, 82, 84, 85, 86,
2019 83, 83, 203, 1, 209, 88, 89, 83, 213, 91,
2020 92, 93, 94, 83, 271, 211, 271, 0, 0, 232,
2021 225, 226, 214, 260, 261, 216, 137, 138, 139, 142,
2022 141, 140, 143, 144, 0, 0, 0, 0, 262, 263,
2023 145, 215, 147, 203, 203, 95, 202, 0, 98, 98,
2024 272, 268, 69, 243, 244, 245, 267, 227, 228, 231,
2025 0, 165, 148, 0, 0, 0, 0, 154, 166, 0,
2026 0, 165, 0, 0, 0, 97, 96, 0, 200, 201,
2027 0, 0, 99, 100, 101, 102, 103, 0, 246, 0,
2028 310, 270, 0, 229, 164, 114, 160, 162, 0, 0,
2029 0, 0, 0, 0, 153, 0, 0, 146, 0, 0,
2030 159, 0, 158, 0, 223, 137, 138, 139, 142, 141,
2031 140, 0, 0, 67, 67, 104, 0, 240, 241, 242,
2032 309, 295, 0, 0, 0, 0, 98, 280, 281, 2,
2033 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
2034 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
2035 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
2036 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
2037 0, 269, 98, 284, 0, 308, 230, 157, 0, 122,
2038 67, 67, 156, 0, 167, 0, 122, 67, 67, 0,
2039 204, 185, 186, 181, 183, 182, 184, 187, 180, 176,
2040 177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2041 0, 0, 0, 0, 0, 179, 178, 217, 0, 294,
2042 274, 67, 273, 0, 0, 55, 0, 0, 29, 30,
2043 31, 32, 33, 34, 35, 36, 37, 38, 0, 53,
2044 54, 49, 50, 51, 52, 39, 40, 41, 42, 43,
2045 44, 45, 46, 47, 48, 0, 128, 128, 315, 67,
2046 67, 306, 0, 0, 0, 0, 0, 67, 67, 0,
2047 0, 0, 0, 106, 108, 107, 105, 109, 110, 111,
2048 112, 113, 115, 163, 161, 150, 151, 152, 155, 66,
2049 149, 219, 221, 0, 0, 0, 0, 0, 0, 0,
2050 0, 169, 199, 0, 0, 0, 173, 0, 170, 0,
2051 0, 0, 133, 238, 249, 250, 251, 256, 252, 253,
2052 254, 255, 247, 0, 258, 265, 264, 266, 0, 275,
2053 0, 0, 67, 67, 0, 311, 0, 313, 292, 0,
2054 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2055 67, 0, 119, 118, 116, 117, 120, 121, 123, 133,
2056 133, 0, 0, 0, 292, 0, 0, 0, 0, 0,
2057 168, 154, 166, 0, 171, 172, 0, 0, 0, 0,
2058 218, 237, 114, 235, 0, 248, 0, 0, 0, 0,
2059 0, 0, 0, 0, 0, 0, 318, 0, 0, 0,
2060 302, 303, 0, 0, 0, 0, 300, 0, 128, 0,
2061 220, 222, 67, 0, 0, 0, 0, 0, 0, 0,
2062 198, 175, 0, 0, 0, 0, 0, 0, 135, 133,
2063 65, 0, 122, 0, 257, 0, 0, 291, 0, 0,
2064 128, 129, 128, 0, 0, 0, 0, 0, 0, 296,
2065 297, 291, 0, 316, 67, 205, 0, 0, 189, 0,
2066 0, 0, 0, 174, 0, 0, 67, 130, 136, 134,
2067 64, 234, 236, 114, 131, 0, 0, 0, 114, 114,
2068 0, 298, 299, 312, 314, 293, 0, 0, 301, 304,
2069 305, 0, 128, 0, 0, 0, 195, 0, 0, 191,
2070 192, 188, 65, 132, 126, 259, 0, 0, 0, 0,
2071 122, 0, 285, 0, 122, 317, 193, 194, 0, 0,
2072 0, 233, 0, 124, 0, 278, 0, 0, 106, 108,
2073 114, 114, 0, 114, 114, 286, 307, 190, 196, 197,
2074 127, 0, 239, 276, 0, 277, 0, 288, 287, 0,
2075 0, 0, 125, 0, 0, 0, 114, 114, 0, 0,
2076 0, 290, 289, 283, 0, 0, 282, 0, 279
2077};
2078
2079/* YYDEFGOTO[NTERM-NUM]. */
2080static const yytype_int16 yydefgoto[] =
2081{
2082 -1, 262, 263, 264, 288, 305, 161, 162, 78, 521,
2083 112, 12, 79, 14, 15, 40, 41, 42, 47, 53,
2084 117, 127, 332, 227, 408, 335, 592, 573, 385, 478,
2085 554, 430, 479, 80, 163, 136, 153, 137, 138, 109,
2086 352, 374, 353, 120, 87, 154, 16, 17, 18, 20,
2087 19, 362, 409, 410, 62, 23, 60, 100, 433, 434,
2088 128, 169, 54, 95, 55, 48, 436, 375, 82, 377,
2089 272, 56, 91, 92, 221, 577, 131, 311, 530, 446,
2090 222, 223, 224, 225
2091};
2092
2093/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2094 STATE-NUM. */
2095#define YYPACT_NINF -544
2096static const yytype_int16 yypact[] =
2097{
2098 291, -544, -544, -544, -544, -544, -544, -544, -9, -121,
2099 -14, -80, 72, -50, 19, -544, 110, 423, -544, 113,
2100 13, -37, -33, -544, -16, 121, -544, 1532, -544, -544,
2101 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2102 128, 128, 160, -544, -544, -544, -544, 128, -544, -544,
2103 -544, -544, -544, 128, 133, -544, 3, 183, 189, 192,
2104 -544, -544, -544, -544, -544, 32, -544, -544, -544, -544,
2105 -544, -544, -544, -544, 215, 218, 1, 509, -544, -544,
2106 -544, -18, -544, 190, 190, 184, -544, 260, 219, 219,
2107 -544, -544, 199, -544, -544, -544, -544, -544, -544, -544,
2108 -53, 1055, -544, 86, 102, 748, 32, -544, -18, -108,
2109 118, 1055, 109, 260, 260, -544, -544, 1298, -544, -544,
2110 1572, 267, -544, -544, -544, -544, -544, 1630, -544, -17,
2111 1854, -544, 256, -544, -544, -18, -544, 136, 135, 1648,
2112 1648, 137, -85, 1648, -544, 300, 157, -544, 1572, 1648,
2113 32, 162, -18, 74, -544, 44, 307, 311, 324, 334,
2114 335, 236, 336, 1110, 293, -544, 101, -544, -544, -544,
2115 -544, -544, 292, 1688, 63, 338, 219, -544, -544, -544,
2116 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2117 -544, -544, -544, -544, 392, 1194, 1648, 1648, 1648, 1648,
2118 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2119 -544, -544, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648,
2120 1648, -544, 219, -544, 49, -544, -544, 269, 1377, -544,
2121 -42, -38, -544, 197, -18, 200, -544, 293, -13, 1298,
2122 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2123 -544, 392, 1194, 202, 209, 212, 213, 214, 1417, 1728,
2124 788, 348, 221, 223, 224, -544, -544, -544, 226, -544,
2125 32, 699, -544, 837, 837, -544, 837, 1630, -544, -544,
2126 -544, -544, -544, -544, -544, -544, -544, -544, 1648, -544,
2127 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2128 -544, -544, -544, -544, -544, 1648, -8, -2, -544, 699,
2129 -15, 222, 227, 229, 230, 239, 245, 699, 699, 339,
2130 1630, 1648, 1648, -544, -544, -544, -544, -544, -544, -544,
2131 -544, -544, -544, -544, -544, 120, -544, -544, -544, -544,
2132 120, -544, 109, 340, 249, 250, 1572, 1572, 1572, 1572,
2133 1572, -544, -544, -47, 1010, -4, -544, -75, -544, 1572,
2134 1572, 1572, 248, 1457, -544, -544, -544, -544, -544, -544,
2135 -544, -544, 329, 1572, -544, -544, -544, -544, 262, -544,
2136 263, 837, 699, 699, 23, -544, 31, -544, -544, 837,
2137 246, 1648, 1648, 1648, 1648, 1648, 264, 265, 1648, 837,
2138 699, 266, -544, -544, -544, -544, -544, -544, -544, 248,
2139 248, 1648, 1572, 1572, -544, 273, 274, 275, 276, 1572,
2140 -544, 271, 965, -67, -544, -544, 283, 284, 371, 6,
2141 -544, -544, -18, 285, 288, -544, 398, 16, 427, 431,
2142 301, 297, 299, 837, 452, 837, 305, 310, 837, 312,
2143 -18, -544, 313, 323, 837, 837, -18, 314, 326, 1648,
2144 -544, -544, 34, 328, 343, 154, 1572, 1572, 1572, 1572,
2145 -544, -544, 317, 1572, 1572, 1648, 438, 489, -544, 248,
2146 131, 1475, -544, 344, -544, 837, 837, 1746, 837, 837,
2147 326, -544, 326, 1648, 837, 345, 1648, 1648, 1648, -544,
2148 -544, 1746, 448, -544, 699, -544, 1572, 1572, -544, 351,
2149 354, 353, 356, -544, 360, 361, 79, -544, -544, -544,
2150 -544, -544, -544, -18, -6, 485, 362, 357, 29, -18,
2151 173, -544, -544, -544, -544, -544, 369, 837, -544, -544,
2152 -544, 176, 326, 363, 379, 1572, -544, 1572, 1572, -544,
2153 -544, -544, 131, -544, 481, -544, 521, -1, 558, 558,
2154 -544, 1803, -544, 381, -544, -544, -544, -544, 389, 391,
2155 394, -544, 539, 400, 837, -544, 1249, 2, 397, 399,
2156 -544, -544, 80, 29, -18, -544, 120, -544, -544, -544,
2157 -544, 526, -544, -544, 401, -544, 1249, 269, 269, 538,
2158 558, 558, -544, 540, 403, 837, -544, -544, 837, 542,
2159 488, 269, 269, -544, 837, 546, -544, 837, -544
2160};
2161
2162/* YYPGOTO[NTERM-NUM]. */
2163static const yytype_int16 yypgoto[] =
2164{
2165 -544, 434, 439, 440, 320, 316, -171, -544, 0, 22,
2166 -134, 483, 9, -544, -544, -544, -544, 191, -544, -544,
2167 -544, -149, -544, -403, -544, -230, -544, -544, -284, 52,
2168 -544, -372, -544, -544, -26, 358, -119, -544, 468, 482,
2169 -113, -161, -245, 225, 257, 350, -544, -544, 573, -544,
2170 -544, -544, -544, -544, -544, -544, -544, -544, -544, -544,
2171 502, -544, -544, -544, -544, -544, -544, -543, -64, 14,
2172 -195, -544, 536, -544, -544, -544, -544, -544, 92, 180,
2173 -544, -544, -544, -544
2174};
2175
2176/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2177 positive, shift that token. If negative, reduce the rule which
2178 number is the opposite. If zero, do what YYDEFACT says.
2179 If YYTABLE_NINF, syntax error. */
2180#define YYTABLE_NINF -208
2181static const yytype_int16 yytable[] =
2182{
2183 11, 81, 265, 308, 276, 104, 340, 164, 166, 13,
2184 275, 167, 110, 275, 355, 357, 110, 11, 312, 313,
2185 314, 315, 316, 387, 90, 319, 13, 277, 476, 480,
2186 267, 24, 93, 594, 443, 237, 110, 460, 461, 110,
2187 476, 110, 445, 21, 25, 143, 110, -55, -55, -55,
2188 -55, 108, 110, 604, 144, 49, 50, 51, 22, 477,
2189 52, 29, 30, 31, 32, 33, 34, 35, 143, 36,
2190 241, 242, 26, 320, 273, 135, 444, 233, 419, 108,
2191 274, 63, 64, -143, 444, 135, 419, 425, 110, 240,
2192 27, 152, 11, 1, 2, 472, 3, 4, 5, 266,
2193 132, 152, 28, 341, 342, 133, 419, 519, 111, 423,
2194 43, 420, 111, 230, 231, 57, 336, 234, 599, 58,
2195 552, 2, 337, 238, 4, 558, 559, 401, 437, 402,
2196 403, 404, 111, 110, 405, 111, -67, 111, 406, 407,
2197 59, 389, 111, 61, 168, 384, -67, 271, 111, 419,
2198 1, 386, -67, 3, 90, 5, 424, 575, 381, 45,
2199 595, 46, 105, 321, 322, 94, 37, 38, 39, 419,
2200 306, 307, 271, 309, 503, 268, 484, 597, 598, -143,
2201 600, 601, 101, -143, 111, 505, 310, 271, 271, 271,
2202 271, 271, 317, 318, 271, 85, 449, 86, 451, 452,
2203 453, 399, 135, 611, 612, 97, 533, 376, 534, 376,
2204 376, 98, 376, 152, 99, 402, 403, 404, 1, 102,
2205 405, 3, 103, 5, 406, 407, 115, 86, 116, 111,
2206 551, 83, 84, 414, 415, 416, 417, 418, 88, 243,
2207 244, 245, 246, 139, 89, 376, 426, 427, 428, 323,
2208 324, 152, 524, 376, 376, 402, 403, 404, 565, 140,
2209 405, 265, 382, 147, 406, 407, 325, 326, 145, 327,
2210 328, 165, 329, 330, 331, 37, 38, 39, 226, 383,
2211 121, 122, 123, 124, 125, 126, 229, 378, 379, 228,
2212 380, -207, 118, 119, 152, 400, 271, 232, 535, 463,
2213 464, 538, 539, 540, 235, 508, 470, 493, 236, -69,
2214 1, 2, 239, 3, 4, 5, -56, 376, 376, 376,
2215 -57, 6, 7, 388, 560, 376, 561, 564, 422, 561,
2216 582, 396, 397, -60, 586, 376, 376, 432, 148, 149,
2217 113, 114, 8, -59, -58, 247, 9, 110, 269, 275,
2218 10, 339, 346, 509, 510, 511, 512, 338, 266, 347,
2219 514, 515, 348, 349, 350, 271, 450, 271, 271, 271,
2220 358, 359, 456, 360, 361, 390, 363, 398, 411, 376,
2221 391, 376, 392, 393, 376, 462, 576, 323, 324, 435,
2222 376, 376, 394, 543, 544, 440, 441, 442, 395, 412,
2223 413, 429, 448, 447, 325, 326, 596, 327, 328, 475,
2224 329, 330, 331, 457, 458, 438, 439, 454, 455, 459,
2225 483, 376, 376, -206, 376, 376, 466, 467, 468, 469,
2226 376, 471, 568, 504, 569, 570, 473, 474, 481, 482,
2227 376, -69, 1, 2, 485, 3, 4, 5, 486, 516,
2228 488, 487, 489, 6, 7, 523, 491, 490, 493, 492,
2229 517, 529, 495, 494, 501, 496, 497, 271, 499, 500,
2230 271, 271, 271, 376, 8, 529, 498, 513, 9, 502,
2231 520, 506, 10, 278, 279, 280, 281, 282, 283, 284,
2232 285, 286, 287, 518, 376, 376, 507, 525, 537, 526,
2233 527, 444, 531, 532, 545, 546, 547, 555, 536, 548,
2234 376, 549, 550, 557, 566, 556, 63, 64, 542, 106,
2235 66, 67, 68, 69, 70, 71, 72, 562, 1, 2,
2236 567, 3, 4, 5, 572, 584, 376, 376, 574, 585,
2237 587, 376, 588, 590, 376, 589, 591, -18, 602, -19,
2238 376, 563, 520, 376, 603, 605, 609, 608, 73, 614,
2239 615, 364, 365, 617, 218, 63, 64, 366, 345, 219,
2240 220, 344, 580, 581, 571, 130, 553, 1, 2, 146,
2241 3, 4, 5, 367, 368, 369, 334, 142, 593, 343,
2242 44, 129, 96, 541, 465, 0, 0, 0, 370, 371,
2243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2244 0, 0, 0, 0, 606, 607, 372, 0, 0, 610,
2245 0, 0, 613, 0, 0, 0, 0, 0, 616, 0,
2246 0, 618, 179, 180, 181, 182, 183, 184, 185, 186,
2247 187, 188, 189, 190, 191, 192, 193, 251, 252, 0,
2248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2249 0, 0, 0, 0, 74, 75, 0, 0, 76, 0,
2250 77, 107, 0, 0, 253, 200, 578, 579, 203, 204,
2251 205, 206, 207, 208, 209, 210, 211, 0, 254, 0,
2252 255, 256, 257, 325, 326, 0, 327, 328, 0, 329,
2253 330, 331, 364, 365, 0, 0, 63, 64, 366, 0,
2254 0, 0, 0, 0, 0, 0, 0, 373, 1, 2,
2255 0, 3, 4, 5, 367, 368, 369, 0, 0, 0,
2256 0, 0, 0, 0, 0, 0, 0, 0, 0, 370,
2257 371, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2258 0, 0, 0, 110, 0, 63, 64, 372, 106, 66,
2259 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2260 3, 4, 5, 179, 180, 181, 182, 183, 184, 185,
2261 186, 187, 188, 189, 190, 191, 192, 193, 251, 252,
2262 0, 0, 0, 0, 0, 63, 64, 73, 106, 155,
2263 156, 157, 158, 159, 160, 72, 0, 1, 2, 0,
2264 3, 4, 5, 0, 0, 253, 200, 201, 202, 203,
2265 204, 205, 206, 207, 208, 209, 210, 211, 0, 254,
2266 0, 255, 256, 257, 0, 0, 0, 73, 0, 0,
2267 364, 365, 0, 0, 63, 64, 366, 0, 0, 111,
2268 0, 0, 0, 0, 0, 0, 1, 2, 373, 3,
2269 4, 5, 367, 368, 369, 0, 0, 0, 0, 0,
2270 0, 0, 0, 0, 0, 0, 0, 370, 371, 0,
2271 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2272 0, 0, 0, 0, 0, 372, 0, 0, 0, 0,
2273 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2274 141, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2275 188, 189, 190, 191, 192, 193, 251, 252, 0, 0,
2276 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2277 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2278 356, 0, 0, 253, 200, 201, 202, 203, 204, 205,
2279 206, 207, 208, 209, 210, 211, 0, 254, 0, 255,
2280 256, 257, 63, 64, 0, 0, 0, 0, 0, 0,
2281 0, 0, 0, 0, 1, 2, 0, 3, 4, 5,
2282 248, 0, 0, 0, 0, 0, 373, 0, 0, 0,
2283 0, 0, 0, 0, 0, 249, 250, 0, 0, 0,
2284 0, 0, 0, 0, 0, 0, 0, 63, 64, 110,
2285 106, 155, 156, 157, 158, 159, 160, 72, 0, 1,
2286 2, 0, 3, 4, 5, 0, 0, 0, 0, 179,
2287 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2288 190, 191, 192, 193, 251, 252, 0, 0, 0, 73,
2289 0, 0, 63, 64, 0, 106, 66, 67, 68, 69,
2290 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2291 0, 253, 200, 201, 202, 203, 204, 205, 206, 207,
2292 208, 209, 210, 211, 134, 254, 0, 255, 256, 257,
2293 0, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2294 0, 0, 0, 0, 0, 111, 0, 63, 64, -67,
2295 0, 258, 0, 0, 259, 0, 260, 0, 261, 1,
2296 2, 0, 3, 4, 5, 248, 0, 0, 0, 0,
2297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2298 249, 250, 0, 0, 0, 0, 0, 0, 0, 0,
2299 0, 0, 0, 0, 110, 74, 75, 0, 0, 76,
2300 0, 77, 421, 0, 0, 0, 0, 0, 0, 0,
2301 0, 0, 0, 0, 179, 180, 181, 182, 183, 184,
2302 185, 186, 187, 188, 189, 190, 191, 192, 193, 251,
2303 252, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2304 74, 75, 0, 0, 76, 0, 77, 0, 0, 0,
2305 289, 290, 0, 0, 0, 0, 253, 200, 201, 202,
2306 203, 204, 205, 206, 207, 208, 209, 210, 211, 0,
2307 254, 0, 255, 256, 257, 0, 0, 0, 0, 0,
2308 0, 0, 364, 365, 0, 0, 0, 0, 366, 0,
2309 111, 0, 0, 0, 0, 0, 258, 0, 0, 259,
2310 0, 260, 0, 261, 367, 368, 369, 0, 0, 0,
2311 0, 0, 0, 0, 0, 0, 0, 0, 0, 370,
2312 371, 291, 292, 293, 294, 295, 296, 297, 298, 299,
2313 300, 301, 302, 303, 304, 63, 64, 372, 150, 66,
2314 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2315 3, 4, 5, 179, 180, 181, 182, 183, 184, 185,
2316 186, 187, 188, 189, 190, 191, 192, 193, 251, 252,
2317 0, 0, 0, 0, 0, 0, 0, 73, 0, 0,
2318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2319 0, 0, 0, 0, 0, 253, 200, 201, 202, 203,
2320 204, 205, 206, 207, 208, 209, 210, 211, 0, 254,
2321 0, 255, 256, 257, 63, 64, 0, 106, 66, 67,
2322 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2323 4, 5, 0, 0, 0, 0, 0, 0, 373, 0,
2324 0, 0, 0, 0, 0, 0, 333, 0, 0, 0,
2325 151, 0, 0, 0, 63, 64, 73, 106, 155, 156,
2326 157, 158, 159, 160, 72, 0, 1, 2, 0, 3,
2327 4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
2328 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2329 0, 0, 0, 0, 63, 64, 73, 106, 66, 67,
2330 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2331 4, 5, 63, 64, 0, 106, 66, 67, 68, 69,
2332 70, 71, 72, 0, 1, 2, 431, 3, 4, 5,
2333 0, 0, 0, 0, 0, 0, 73, 0, 0, 0,
2334 0, 0, 0, 0, 522, 0, 0, 0, 0, 0,
2335 0, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2336 0, 0, 74, 75, 0, 0, 76, 0, 77, 63,
2337 64, 0, 65, 66, 67, 68, 69, 70, 71, 72,
2338 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2340 0, 0, 74, 75, 0, 351, 76, 0, 77, 63,
2341 64, 73, 106, 155, 156, 157, 158, 159, 160, 72,
2342 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 0, 74, 75, 0, 0, 76, 0, 77, 0,
2345 0, 73, 0, 0, 0, 0, 0, 0, 0, 0,
2346 74, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2347 150, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2348 2, 0, 3, 4, 5, 63, 64, 0, 106, 66,
2349 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2350 3, 4, 5, 0, 0, 0, 0, 0, 0, 73,
2351 0, 0, 0, 0, 0, 0, 0, 74, 75, 0,
2352 0, 76, 0, 77, 0, 63, 64, 73, 270, 66,
2353 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2354 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2355 0, 0, 0, 0, 0, 0, 0, 74, 75, 0,
2356 0, 76, 0, 77, 0, 63, 64, 73, 106, 155,
2357 156, 157, 158, 159, 160, 72, 0, 1, 2, 0,
2358 3, 4, 5, 63, 64, 0, 106, 66, 67, 68,
2359 69, 70, 71, 528, 0, 1, 2, 0, 3, 4,
2360 5, 0, 0, 0, 0, 0, 0, 73, 0, 0,
2361 0, 0, 0, 0, 0, 74, 75, 0, 0, 76,
2362 0, 77, 0, 0, 0, 73, 0, 0, 0, 0,
2363 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2364 63, 64, 0, 106, 66, 67, 68, 69, 70, 71,
2365 583, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2366 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2367 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2368 0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
2369 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2371 0, 0, 0, 74, 75, 0, 0, 76, 0, 354,
2372 170, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2373 0, 74, 75, 0, 0, 76, 0, 77, 0, 0,
2374 171, 172, 0, 0, 0, 0, 0, 0, 0, 0,
2375 0, 0, 173, 174, 175, 176, 177, 178, 179, 180,
2376 181, 182, 183, 184, 185, 186, 187, 188, 189, 190,
2377 191, 192, 193, 194, 195, 0, 0, 0, 0, 0,
2378 0, 0, 0, 0, 0, 0, 0, 0, 74, 75,
2379 0, 0, 76, 0, 77, 196, 197, 198, 0, 0,
2380 199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
2381 209, 210, 211, 212, 213, 214, 215, 216, 217
2382};
2383
2384static const yytype_int16 yycheck[] =
2385{
2386 0, 27, 163, 198, 175, 4, 236, 120, 127, 0,
2387 11, 28, 54, 11, 259, 260, 54, 17, 213, 214,
2388 215, 216, 217, 307, 21, 220, 17, 176, 34, 432,
2389 164, 152, 29, 576, 11, 148, 54, 409, 410, 54,
2390 34, 54, 11, 52, 58, 153, 54, 3, 4, 5,
2391 6, 77, 54, 596, 162, 42, 43, 44, 67, 53,
2392 47, 42, 43, 44, 45, 46, 47, 48, 153, 50,
2393 26, 27, 152, 222, 11, 101, 53, 162, 153, 105,
2394 17, 7, 8, 54, 53, 111, 153, 162, 54, 153,
2395 18, 117, 92, 19, 20, 162, 22, 23, 24, 163,
2396 153, 127, 152, 237, 238, 158, 153, 479, 150, 354,
2397 0, 158, 150, 139, 140, 152, 158, 143, 38, 152,
2398 523, 20, 160, 149, 23, 528, 529, 322, 373, 135,
2399 136, 137, 150, 54, 140, 150, 154, 150, 144, 145,
2400 156, 156, 150, 22, 161, 153, 154, 173, 150, 153,
2401 19, 153, 154, 22, 21, 24, 160, 158, 277, 46,
2402 158, 48, 161, 114, 115, 162, 147, 148, 149, 153,
2403 196, 197, 198, 199, 458, 166, 160, 580, 581, 150,
2404 583, 584, 150, 154, 150, 151, 212, 213, 214, 215,
2405 216, 217, 218, 219, 220, 35, 391, 37, 393, 394,
2406 395, 320, 228, 606, 607, 22, 490, 271, 492, 273,
2407 274, 22, 276, 239, 22, 135, 136, 137, 19, 4,
2408 140, 22, 4, 24, 144, 145, 42, 37, 44, 150,
2409 151, 40, 41, 346, 347, 348, 349, 350, 47, 3,
2410 4, 5, 6, 157, 53, 309, 359, 360, 361, 118,
2411 119, 277, 482, 317, 318, 135, 136, 137, 542, 157,
2412 140, 422, 288, 154, 144, 145, 135, 136, 150, 138,
2413 139, 4, 141, 142, 143, 147, 148, 149, 22, 305,
2414 61, 62, 63, 64, 65, 66, 151, 273, 274, 153,
2415 276, 0, 32, 33, 320, 321, 322, 160, 493, 412,
2416 413, 496, 497, 498, 4, 151, 419, 153, 151, 18,
2417 19, 20, 150, 22, 23, 24, 9, 381, 382, 383,
2418 9, 30, 31, 309, 151, 389, 153, 151, 354, 153,
2419 560, 317, 318, 9, 564, 399, 400, 363, 113, 114,
2420 83, 84, 51, 9, 9, 9, 55, 54, 56, 11,
2421 59, 151, 150, 466, 467, 468, 469, 160, 422, 150,
2422 473, 474, 150, 150, 150, 391, 392, 393, 394, 395,
2423 22, 150, 398, 150, 150, 153, 150, 38, 38, 443,
2424 153, 445, 153, 153, 448, 411, 557, 118, 119, 60,
2425 454, 455, 153, 506, 507, 381, 382, 383, 153, 150,
2426 150, 153, 156, 389, 135, 136, 577, 138, 139, 38,
2427 141, 142, 143, 399, 400, 153, 153, 153, 153, 153,
2428 22, 485, 486, 0, 488, 489, 153, 153, 153, 153,
2429 494, 160, 545, 459, 547, 548, 153, 153, 153, 151,
2430 504, 18, 19, 20, 17, 22, 23, 24, 17, 475,
2431 153, 150, 153, 30, 31, 481, 4, 443, 153, 445,
2432 22, 487, 448, 153, 150, 153, 153, 493, 454, 455,
2433 496, 497, 498, 537, 51, 501, 153, 160, 55, 153,
2434 480, 153, 59, 91, 92, 93, 94, 95, 96, 97,
2435 98, 99, 100, 4, 558, 559, 153, 153, 153, 485,
2436 486, 53, 488, 489, 153, 151, 153, 22, 494, 153,
2437 574, 151, 151, 156, 151, 153, 7, 8, 504, 10,
2438 11, 12, 13, 14, 15, 16, 17, 158, 19, 20,
2439 151, 22, 23, 24, 53, 561, 600, 601, 17, 158,
2440 151, 605, 151, 4, 608, 151, 146, 150, 22, 150,
2441 614, 537, 552, 617, 153, 17, 153, 17, 49, 17,
2442 72, 3, 4, 17, 130, 7, 8, 9, 252, 130,
2443 130, 251, 558, 559, 552, 92, 524, 19, 20, 111,
2444 22, 23, 24, 25, 26, 27, 228, 105, 574, 239,
2445 17, 89, 56, 501, 414, -1, -1, -1, 40, 41,
2446 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2447 -1, -1, -1, -1, 600, 601, 58, -1, -1, 605,
2448 -1, -1, 608, -1, -1, -1, -1, -1, 614, -1,
2449 -1, 617, 74, 75, 76, 77, 78, 79, 80, 81,
2450 82, 83, 84, 85, 86, 87, 88, 89, 90, -1,
2451 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2452 -1, -1, -1, -1, 155, 156, -1, -1, 159, -1,
2453 161, 162, -1, -1, 116, 117, 118, 119, 120, 121,
2454 122, 123, 124, 125, 126, 127, 128, -1, 130, -1,
2455 132, 133, 134, 135, 136, -1, 138, 139, -1, 141,
2456 142, 143, 3, 4, -1, -1, 7, 8, 9, -1,
2457 -1, -1, -1, -1, -1, -1, -1, 159, 19, 20,
2458 -1, 22, 23, 24, 25, 26, 27, -1, -1, -1,
2459 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2460 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2461 -1, -1, -1, 54, -1, 7, 8, 58, 10, 11,
2462 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2463 22, 23, 24, 74, 75, 76, 77, 78, 79, 80,
2464 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2465 -1, -1, -1, -1, -1, 7, 8, 49, 10, 11,
2466 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2467 22, 23, 24, -1, -1, 116, 117, 118, 119, 120,
2468 121, 122, 123, 124, 125, 126, 127, 128, -1, 130,
2469 -1, 132, 133, 134, -1, -1, -1, 49, -1, -1,
2470 3, 4, -1, -1, 7, 8, 9, -1, -1, 150,
2471 -1, -1, -1, -1, -1, -1, 19, 20, 159, 22,
2472 23, 24, 25, 26, 27, -1, -1, -1, -1, -1,
2473 -1, -1, -1, -1, -1, -1, -1, 40, 41, -1,
2474 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2475 -1, -1, -1, -1, -1, 58, -1, -1, -1, -1,
2476 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2477 162, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2478 83, 84, 85, 86, 87, 88, 89, 90, -1, -1,
2479 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2480 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2481 162, -1, -1, 116, 117, 118, 119, 120, 121, 122,
2482 123, 124, 125, 126, 127, 128, -1, 130, -1, 132,
2483 133, 134, 7, 8, -1, -1, -1, -1, -1, -1,
2484 -1, -1, -1, -1, 19, 20, -1, 22, 23, 24,
2485 25, -1, -1, -1, -1, -1, 159, -1, -1, -1,
2486 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2487 -1, -1, -1, -1, -1, -1, -1, 7, 8, 54,
2488 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2489 20, -1, 22, 23, 24, -1, -1, -1, -1, 74,
2490 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2491 85, 86, 87, 88, 89, 90, -1, -1, -1, 49,
2492 -1, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2493 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2494 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2495 125, 126, 127, 128, 39, 130, -1, 132, 133, 134,
2496 -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2497 -1, -1, -1, -1, -1, 150, -1, 7, 8, 154,
2498 -1, 156, -1, -1, 159, -1, 161, -1, 163, 19,
2499 20, -1, 22, 23, 24, 25, -1, -1, -1, -1,
2500 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2501 40, 41, -1, -1, -1, -1, -1, -1, -1, -1,
2502 -1, -1, -1, -1, 54, 155, 156, -1, -1, 159,
2503 -1, 161, 162, -1, -1, -1, -1, -1, -1, -1,
2504 -1, -1, -1, -1, 74, 75, 76, 77, 78, 79,
2505 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2506 90, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2507 155, 156, -1, -1, 159, -1, 161, -1, -1, -1,
2508 26, 27, -1, -1, -1, -1, 116, 117, 118, 119,
2509 120, 121, 122, 123, 124, 125, 126, 127, 128, -1,
2510 130, -1, 132, 133, 134, -1, -1, -1, -1, -1,
2511 -1, -1, 3, 4, -1, -1, -1, -1, 9, -1,
2512 150, -1, -1, -1, -1, -1, 156, -1, -1, 159,
2513 -1, 161, -1, 163, 25, 26, 27, -1, -1, -1,
2514 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
2515 41, 97, 98, 99, 100, 101, 102, 103, 104, 105,
2516 106, 107, 108, 109, 110, 7, 8, 58, 10, 11,
2517 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2518 22, 23, 24, 74, 75, 76, 77, 78, 79, 80,
2519 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2520 -1, -1, -1, -1, -1, -1, -1, 49, -1, -1,
2521 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2522 -1, -1, -1, -1, -1, 116, 117, 118, 119, 120,
2523 121, 122, 123, 124, 125, 126, 127, 128, -1, 130,
2524 -1, 132, 133, 134, 7, 8, -1, 10, 11, 12,
2525 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2526 23, 24, -1, -1, -1, -1, -1, -1, 159, -1,
2527 -1, -1, -1, -1, -1, -1, 39, -1, -1, -1,
2528 122, -1, -1, -1, 7, 8, 49, 10, 11, 12,
2529 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2530 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2531 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2532 -1, -1, -1, -1, 7, 8, 49, 10, 11, 12,
2533 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2534 23, 24, 7, 8, -1, 10, 11, 12, 13, 14,
2535 15, 16, 17, -1, 19, 20, 39, 22, 23, 24,
2536 -1, -1, -1, -1, -1, -1, 49, -1, -1, -1,
2537 -1, -1, -1, -1, 39, -1, -1, -1, -1, -1,
2538 -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2539 -1, -1, 155, 156, -1, -1, 159, -1, 161, 7,
2540 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2541 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2542 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2543 -1, -1, 155, 156, -1, 158, 159, -1, 161, 7,
2544 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2545 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2546 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2547 -1, -1, 155, 156, -1, -1, 159, -1, 161, -1,
2548 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
2549 155, 156, -1, -1, 159, -1, 161, 7, 8, -1,
2550 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2551 20, -1, 22, 23, 24, 7, 8, -1, 10, 11,
2552 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2553 22, 23, 24, -1, -1, -1, -1, -1, -1, 49,
2554 -1, -1, -1, -1, -1, -1, -1, 155, 156, -1,
2555 -1, 159, -1, 161, -1, 7, 8, 49, 10, 11,
2556 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2557 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2558 -1, -1, -1, -1, -1, -1, -1, 155, 156, -1,
2559 -1, 159, -1, 161, -1, 7, 8, 49, 10, 11,
2560 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2561 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
2562 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2563 24, -1, -1, -1, -1, -1, -1, 49, -1, -1,
2564 -1, -1, -1, -1, -1, 155, 156, -1, -1, 159,
2565 -1, 161, -1, -1, -1, 49, -1, -1, -1, -1,
2566 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2567 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2568 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2569 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2570 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2571 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2572 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2573 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2574 -1, -1, -1, 155, 156, -1, -1, 159, -1, 161,
2575 36, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2576 -1, 155, 156, -1, -1, 159, -1, 161, -1, -1,
2577 56, 57, -1, -1, -1, -1, -1, -1, -1, -1,
2578 -1, -1, 68, 69, 70, 71, 72, 73, 74, 75,
2579 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2580 86, 87, 88, 89, 90, -1, -1, -1, -1, -1,
2581 -1, -1, -1, -1, -1, -1, -1, -1, 155, 156,
2582 -1, -1, 159, -1, 161, 111, 112, 113, -1, -1,
2583 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2584 126, 127, 128, 129, 130, 131, 132, 133, 134
2585};
2586
2587/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2588 symbol of state STATE-NUM. */
2589static const yytype_uint8 yystos[] =
2590{
2591 0, 19, 20, 22, 23, 24, 30, 31, 51, 55,
2592 59, 172, 175, 176, 177, 178, 210, 211, 212, 214,
2593 213, 52, 67, 219, 152, 58, 152, 18, 152, 42,
2594 43, 44, 45, 46, 47, 48, 50, 147, 148, 149,
2595 179, 180, 181, 0, 212, 46, 48, 182, 229, 42,
2596 43, 44, 47, 183, 226, 228, 235, 152, 152, 156,
2597 220, 22, 218, 7, 8, 10, 11, 12, 13, 14,
2598 15, 16, 17, 49, 155, 156, 159, 161, 172, 176,
2599 197, 198, 232, 181, 181, 35, 37, 208, 181, 181,
2600 21, 236, 237, 29, 162, 227, 236, 22, 22, 22,
2601 221, 150, 4, 4, 4, 161, 10, 162, 198, 203,
2602 54, 150, 174, 208, 208, 42, 44, 184, 32, 33,
2603 207, 61, 62, 63, 64, 65, 66, 185, 224, 224,
2604 175, 240, 153, 158, 39, 198, 199, 201, 202, 157,
2605 157, 162, 203, 153, 162, 150, 202, 154, 207, 207,
2606 10, 122, 198, 200, 209, 11, 12, 13, 14, 15,
2607 16, 170, 171, 198, 204, 4, 200, 28, 161, 225,
2608 36, 56, 57, 68, 69, 70, 71, 72, 73, 74,
2609 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2610 85, 86, 87, 88, 89, 90, 111, 112, 113, 116,
2611 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2612 127, 128, 129, 130, 131, 132, 133, 134, 165, 166,
2613 167, 238, 244, 245, 246, 247, 22, 187, 153, 151,
2614 198, 198, 160, 162, 198, 4, 151, 204, 198, 150,
2615 232, 26, 27, 3, 4, 5, 6, 9, 25, 40,
2616 41, 89, 90, 116, 130, 132, 133, 134, 156, 159,
2617 161, 163, 165, 166, 167, 205, 232, 174, 176, 56,
2618 10, 198, 234, 11, 17, 11, 170, 185, 91, 92,
2619 93, 94, 95, 96, 97, 98, 99, 100, 168, 26,
2620 27, 97, 98, 99, 100, 101, 102, 103, 104, 105,
2621 106, 107, 108, 109, 110, 169, 198, 198, 234, 198,
2622 198, 241, 234, 234, 234, 234, 234, 198, 198, 234,
2623 185, 114, 115, 118, 119, 135, 136, 138, 139, 141,
2624 142, 143, 186, 39, 199, 189, 158, 160, 160, 151,
2625 189, 174, 174, 209, 168, 169, 150, 150, 150, 150,
2626 150, 158, 204, 206, 161, 206, 162, 206, 22, 150,
2627 150, 150, 215, 150, 3, 4, 9, 25, 26, 27,
2628 40, 41, 58, 159, 205, 231, 232, 233, 233, 233,
2629 233, 200, 198, 198, 153, 192, 153, 192, 233, 156,
2630 153, 153, 153, 153, 153, 153, 233, 233, 38, 200,
2631 198, 234, 135, 136, 137, 140, 144, 145, 188, 216,
2632 217, 38, 150, 150, 204, 204, 204, 204, 204, 153,
2633 158, 162, 198, 206, 160, 162, 204, 204, 204, 153,
2634 195, 39, 198, 222, 223, 60, 230, 206, 153, 153,
2635 233, 233, 233, 11, 53, 11, 243, 233, 156, 234,
2636 198, 234, 234, 234, 153, 153, 198, 233, 233, 153,
2637 195, 195, 198, 204, 204, 243, 153, 153, 153, 153,
2638 204, 160, 162, 153, 153, 38, 34, 53, 193, 196,
2639 187, 153, 151, 22, 160, 17, 17, 150, 153, 153,
2640 233, 4, 233, 153, 153, 233, 153, 153, 153, 233,
2641 233, 150, 153, 192, 198, 151, 153, 153, 151, 204,
2642 204, 204, 204, 160, 204, 204, 198, 22, 4, 195,
2643 172, 173, 39, 198, 189, 153, 233, 233, 17, 198,
2644 242, 233, 233, 192, 192, 234, 233, 153, 234, 234,
2645 234, 242, 233, 204, 204, 153, 151, 153, 153, 151,
2646 151, 151, 187, 193, 194, 22, 153, 156, 187, 187,
2647 151, 153, 158, 233, 151, 192, 151, 151, 204, 204,
2648 204, 173, 53, 191, 17, 158, 170, 239, 118, 119,
2649 233, 233, 189, 17, 198, 158, 189, 151, 151, 151,
2650 4, 146, 190, 233, 231, 158, 170, 187, 187, 38,
2651 187, 187, 22, 153, 231, 17, 233, 233, 17, 153,
2652 233, 187, 187, 233, 17, 72, 233, 17, 233
2653};
David Greene9145dd22007-08-01 03:59:32 +00002654
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655#define yyerrok (yyerrstatus = 0)
2656#define yyclearin (yychar = YYEMPTY)
Chris Lattner59363a32008-02-19 04:36:25 +00002657#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002658#define YYEOF 0
Chris Lattner59363a32008-02-19 04:36:25 +00002659
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660#define YYACCEPT goto yyacceptlab
Chris Lattner59363a32008-02-19 04:36:25 +00002661#define YYABORT goto yyabortlab
2662#define YYERROR goto yyerrorlab
2663
2664
2665/* Like YYERROR except do call yyerror. This remains here temporarily
2666 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667 Once GCC version 2 has supplanted version 1, this can go. */
Chris Lattner59363a32008-02-19 04:36:25 +00002668
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002669#define YYFAIL goto yyerrlab
Chris Lattner59363a32008-02-19 04:36:25 +00002670
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner59363a32008-02-19 04:36:25 +00002672
2673#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674do \
2675 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner59363a32008-02-19 04:36:25 +00002676 { \
2677 yychar = (Token); \
2678 yylval = (Value); \
2679 yytoken = YYTRANSLATE (yychar); \
2680 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681 goto yybackup; \
2682 } \
2683 else \
Chris Lattner59363a32008-02-19 04:36:25 +00002684 { \
2685 yyerror (YY_("syntax error: cannot back up")); \
2686 YYERROR; \
2687 } \
2688while (YYID (0))
2689
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002690
2691#define YYTERROR 1
2692#define YYERRCODE 256
2693
Chris Lattner59363a32008-02-19 04:36:25 +00002694
2695/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2696 If N is 0, then set CURRENT to the empty location which ends
2697 the previous symbol: RHS[0] (always defined). */
2698
2699#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2700#ifndef YYLLOC_DEFAULT
2701# define YYLLOC_DEFAULT(Current, Rhs, N) \
2702 do \
2703 if (YYID (N)) \
2704 { \
2705 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2706 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2707 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2708 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2709 } \
2710 else \
2711 { \
2712 (Current).first_line = (Current).last_line = \
2713 YYRHSLOC (Rhs, 0).last_line; \
2714 (Current).first_column = (Current).last_column = \
2715 YYRHSLOC (Rhs, 0).last_column; \
2716 } \
2717 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002718#endif
2719
Chris Lattner59363a32008-02-19 04:36:25 +00002720
2721/* YY_LOCATION_PRINT -- Print the location on the stream.
2722 This macro was not mandated originally: define only if we know
2723 we won't break user code: when these are the locations we know. */
2724
2725#ifndef YY_LOCATION_PRINT
2726# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2727# define YY_LOCATION_PRINT(File, Loc) \
2728 fprintf (File, "%d.%d-%d.%d", \
2729 (Loc).first_line, (Loc).first_column, \
2730 (Loc).last_line, (Loc).last_column)
2731# else
2732# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2733# endif
2734#endif
2735
2736
2737/* YYLEX -- calling `yylex' with the right arguments. */
2738
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739#ifdef YYLEX_PARAM
Chris Lattner59363a32008-02-19 04:36:25 +00002740# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741#else
Chris Lattner59363a32008-02-19 04:36:25 +00002742# define YYLEX yylex ()
Scott Michel6d1aba82008-01-30 03:10:00 +00002743#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002744
2745/* Enable debugging if requested. */
2746#if YYDEBUG
2747
2748# ifndef YYFPRINTF
2749# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2750# define YYFPRINTF fprintf
2751# endif
2752
2753# define YYDPRINTF(Args) \
2754do { \
2755 if (yydebug) \
2756 YYFPRINTF Args; \
2757} while (YYID (0))
2758
2759# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2760do { \
2761 if (yydebug) \
2762 { \
2763 YYFPRINTF (stderr, "%s ", Title); \
2764 yy_symbol_print (stderr, \
2765 Type, Value); \
2766 YYFPRINTF (stderr, "\n"); \
2767 } \
2768} while (YYID (0))
2769
2770
2771/*--------------------------------.
2772| Print this symbol on YYOUTPUT. |
2773`--------------------------------*/
2774
2775/*ARGSUSED*/
2776#if (defined __STDC__ || defined __C99__FUNC__ \
2777 || defined __cplusplus || defined _MSC_VER)
2778static void
2779yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Scott Michel6d1aba82008-01-30 03:10:00 +00002780#else
Chris Lattner59363a32008-02-19 04:36:25 +00002781static void
2782yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2783 FILE *yyoutput;
2784 int yytype;
2785 YYSTYPE const * const yyvaluep;
Scott Michel6d1aba82008-01-30 03:10:00 +00002786#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002787{
2788 if (!yyvaluep)
2789 return;
2790# ifdef YYPRINT
2791 if (yytype < YYNTOKENS)
2792 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2793# else
2794 YYUSE (yyoutput);
2795# endif
2796 switch (yytype)
2797 {
2798 default:
2799 break;
2800 }
2801}
2802
2803
2804/*--------------------------------.
2805| Print this symbol on YYOUTPUT. |
2806`--------------------------------*/
2807
2808#if (defined __STDC__ || defined __C99__FUNC__ \
2809 || defined __cplusplus || defined _MSC_VER)
2810static void
2811yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2812#else
2813static void
2814yy_symbol_print (yyoutput, yytype, yyvaluep)
2815 FILE *yyoutput;
2816 int yytype;
2817 YYSTYPE const * const yyvaluep;
Christopher Lamb0a243582007-12-11 09:02:08 +00002818#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002819{
2820 if (yytype < YYNTOKENS)
2821 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2822 else
2823 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Scott Michel5a6f17b2008-01-30 02:55:46 +00002824
Chris Lattner59363a32008-02-19 04:36:25 +00002825 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2826 YYFPRINTF (yyoutput, ")");
2827}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002828
Chris Lattner59363a32008-02-19 04:36:25 +00002829/*------------------------------------------------------------------.
2830| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2831| TOP (included). |
2832`------------------------------------------------------------------*/
Scott Michel5a6f17b2008-01-30 02:55:46 +00002833
Chris Lattner59363a32008-02-19 04:36:25 +00002834#if (defined __STDC__ || defined __C99__FUNC__ \
2835 || defined __cplusplus || defined _MSC_VER)
2836static void
2837yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2838#else
2839static void
2840yy_stack_print (bottom, top)
2841 yytype_int16 *bottom;
2842 yytype_int16 *top;
Christopher Lamb0a243582007-12-11 09:02:08 +00002843#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002844{
2845 YYFPRINTF (stderr, "Stack now");
2846 for (; bottom <= top; ++bottom)
2847 YYFPRINTF (stderr, " %d", *bottom);
2848 YYFPRINTF (stderr, "\n");
2849}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002850
Chris Lattner59363a32008-02-19 04:36:25 +00002851# define YY_STACK_PRINT(Bottom, Top) \
2852do { \
2853 if (yydebug) \
2854 yy_stack_print ((Bottom), (Top)); \
2855} while (YYID (0))
Scott Michel5a6f17b2008-01-30 02:55:46 +00002856
Chris Lattner59363a32008-02-19 04:36:25 +00002857
2858/*------------------------------------------------.
2859| Report that the YYRULE is going to be reduced. |
2860`------------------------------------------------*/
2861
2862#if (defined __STDC__ || defined __C99__FUNC__ \
2863 || defined __cplusplus || defined _MSC_VER)
2864static void
2865yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2866#else
2867static void
2868yy_reduce_print (yyvsp, yyrule)
2869 YYSTYPE *yyvsp;
2870 int yyrule;
Dale Johannesen3afee192007-09-07 21:07:57 +00002871#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002872{
2873 int yynrhs = yyr2[yyrule];
2874 int yyi;
2875 unsigned long int yylno = yyrline[yyrule];
2876 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2877 yyrule - 1, yylno);
2878 /* The symbols being reduced. */
2879 for (yyi = 0; yyi < yynrhs; yyi++)
2880 {
2881 fprintf (stderr, " $%d = ", yyi + 1);
2882 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2883 &(yyvsp[(yyi + 1) - (yynrhs)])
2884 );
2885 fprintf (stderr, "\n");
2886 }
2887}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002888
Chris Lattner59363a32008-02-19 04:36:25 +00002889# define YY_REDUCE_PRINT(Rule) \
2890do { \
2891 if (yydebug) \
2892 yy_reduce_print (yyvsp, Rule); \
2893} while (YYID (0))
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002894
Chris Lattner59363a32008-02-19 04:36:25 +00002895/* Nonzero means print parse trace. It is left uninitialized so that
2896 multiple parsers can coexist. */
2897int yydebug;
2898#else /* !YYDEBUG */
2899# define YYDPRINTF(Args)
2900# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2901# define YY_STACK_PRINT(Bottom, Top)
2902# define YY_REDUCE_PRINT(Rule)
2903#endif /* !YYDEBUG */
2904
2905
2906/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907#ifndef YYINITDEPTH
Chris Lattner59363a32008-02-19 04:36:25 +00002908# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909#endif
2910
Chris Lattner59363a32008-02-19 04:36:25 +00002911/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2912 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913
Chris Lattner59363a32008-02-19 04:36:25 +00002914 Do not make this value too large; the results are undefined if
2915 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2916 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002917
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918#ifndef YYMAXDEPTH
Chris Lattner59363a32008-02-19 04:36:25 +00002919# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002921
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923
Chris Lattner59363a32008-02-19 04:36:25 +00002924#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925
Chris Lattner59363a32008-02-19 04:36:25 +00002926# ifndef yystrlen
2927# if defined __GLIBC__ && defined _STRING_H
2928# define yystrlen strlen
2929# else
2930/* Return the length of YYSTR. */
2931#if (defined __STDC__ || defined __C99__FUNC__ \
2932 || defined __cplusplus || defined _MSC_VER)
2933static YYSIZE_T
2934yystrlen (const char *yystr)
Scott Michel5a6f17b2008-01-30 02:55:46 +00002935#else
Chris Lattner59363a32008-02-19 04:36:25 +00002936static YYSIZE_T
2937yystrlen (yystr)
2938 const char *yystr;
2939#endif
2940{
2941 YYSIZE_T yylen;
2942 for (yylen = 0; yystr[yylen]; yylen++)
2943 continue;
2944 return yylen;
2945}
2946# endif
2947# endif
2948
2949# ifndef yystpcpy
2950# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2951# define yystpcpy stpcpy
2952# else
2953/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2954 YYDEST. */
2955#if (defined __STDC__ || defined __C99__FUNC__ \
2956 || defined __cplusplus || defined _MSC_VER)
2957static char *
2958yystpcpy (char *yydest, const char *yysrc)
2959#else
2960static char *
2961yystpcpy (yydest, yysrc)
2962 char *yydest;
2963 const char *yysrc;
2964#endif
2965{
2966 char *yyd = yydest;
2967 const char *yys = yysrc;
2968
2969 while ((*yyd++ = *yys++) != '\0')
2970 continue;
2971
2972 return yyd - 1;
2973}
2974# endif
2975# endif
2976
2977# ifndef yytnamerr
2978/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2979 quotes and backslashes, so that it's suitable for yyerror. The
2980 heuristic is that double-quoting is unnecessary unless the string
2981 contains an apostrophe, a comma, or backslash (other than
2982 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2983 null, do not copy; instead, return the length of what the result
2984 would have been. */
2985static YYSIZE_T
2986yytnamerr (char *yyres, const char *yystr)
2987{
2988 if (*yystr == '"')
2989 {
2990 YYSIZE_T yyn = 0;
2991 char const *yyp = yystr;
2992
2993 for (;;)
2994 switch (*++yyp)
2995 {
2996 case '\'':
2997 case ',':
2998 goto do_not_strip_quotes;
2999
3000 case '\\':
3001 if (*++yyp != '\\')
3002 goto do_not_strip_quotes;
3003 /* Fall through. */
3004 default:
3005 if (yyres)
3006 yyres[yyn] = *yyp;
3007 yyn++;
3008 break;
3009
3010 case '"':
3011 if (yyres)
3012 yyres[yyn] = '\0';
3013 return yyn;
3014 }
3015 do_not_strip_quotes: ;
3016 }
3017
3018 if (! yyres)
3019 return yystrlen (yystr);
3020
3021 return yystpcpy (yyres, yystr) - yyres;
3022}
3023# endif
3024
3025/* Copy into YYRESULT an error message about the unexpected token
3026 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3027 including the terminating null byte. If YYRESULT is null, do not
3028 copy anything; just return the number of bytes that would be
3029 copied. As a special case, return 0 if an ordinary "syntax error"
3030 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3031 size calculation. */
3032static YYSIZE_T
3033yysyntax_error (char *yyresult, int yystate, int yychar)
3034{
3035 int yyn = yypact[yystate];
3036
3037 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3038 return 0;
3039 else
3040 {
3041 int yytype = YYTRANSLATE (yychar);
3042 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3043 YYSIZE_T yysize = yysize0;
3044 YYSIZE_T yysize1;
3045 int yysize_overflow = 0;
3046 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3047 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3048 int yyx;
3049
3050# if 0
3051 /* This is so xgettext sees the translatable formats that are
3052 constructed on the fly. */
3053 YY_("syntax error, unexpected %s");
3054 YY_("syntax error, unexpected %s, expecting %s");
3055 YY_("syntax error, unexpected %s, expecting %s or %s");
3056 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3057 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3058# endif
3059 char *yyfmt;
3060 char const *yyf;
3061 static char const yyunexpected[] = "syntax error, unexpected %s";
3062 static char const yyexpecting[] = ", expecting %s";
3063 static char const yyor[] = " or %s";
3064 char yyformat[sizeof yyunexpected
3065 + sizeof yyexpecting - 1
3066 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3067 * (sizeof yyor - 1))];
3068 char const *yyprefix = yyexpecting;
3069
3070 /* Start YYX at -YYN if negative to avoid negative indexes in
3071 YYCHECK. */
3072 int yyxbegin = yyn < 0 ? -yyn : 0;
3073
3074 /* Stay within bounds of both yycheck and yytname. */
3075 int yychecklim = YYLAST - yyn + 1;
3076 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3077 int yycount = 1;
3078
3079 yyarg[0] = yytname[yytype];
3080 yyfmt = yystpcpy (yyformat, yyunexpected);
3081
3082 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3083 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3084 {
3085 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3086 {
3087 yycount = 1;
3088 yysize = yysize0;
3089 yyformat[sizeof yyunexpected - 1] = '\0';
3090 break;
3091 }
3092 yyarg[yycount++] = yytname[yyx];
3093 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3094 yysize_overflow |= (yysize1 < yysize);
3095 yysize = yysize1;
3096 yyfmt = yystpcpy (yyfmt, yyprefix);
3097 yyprefix = yyor;
3098 }
3099
3100 yyf = YY_(yyformat);
3101 yysize1 = yysize + yystrlen (yyf);
3102 yysize_overflow |= (yysize1 < yysize);
3103 yysize = yysize1;
3104
3105 if (yysize_overflow)
3106 return YYSIZE_MAXIMUM;
3107
3108 if (yyresult)
3109 {
3110 /* Avoid sprintf, as that infringes on the user's name space.
3111 Don't have undefined behavior even if the translation
3112 produced a string with the wrong number of "%s"s. */
3113 char *yyp = yyresult;
3114 int yyi = 0;
3115 while ((*yyp = *yyf) != '\0')
3116 {
3117 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3118 {
3119 yyp += yytnamerr (yyp, yyarg[yyi++]);
3120 yyf += 2;
3121 }
3122 else
3123 {
3124 yyp++;
3125 yyf++;
3126 }
3127 }
3128 }
3129 return yysize;
3130 }
3131}
3132#endif /* YYERROR_VERBOSE */
3133
3134
3135/*-----------------------------------------------.
3136| Release the memory associated to this symbol. |
3137`-----------------------------------------------*/
3138
3139/*ARGSUSED*/
3140#if (defined __STDC__ || defined __C99__FUNC__ \
3141 || defined __cplusplus || defined _MSC_VER)
3142static void
3143yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3144#else
3145static void
3146yydestruct (yymsg, yytype, yyvaluep)
3147 const char *yymsg;
3148 int yytype;
3149 YYSTYPE *yyvaluep;
3150#endif
3151{
3152 YYUSE (yyvaluep);
3153
3154 if (!yymsg)
3155 yymsg = "Deleting";
3156 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3157
3158 switch (yytype)
3159 {
3160
3161 default:
3162 break;
3163 }
3164}
3165
3166
3167/* Prevent warnings from -Wmissing-prototypes. */
3168
3169#ifdef YYPARSE_PARAM
3170#if defined __STDC__ || defined __cplusplus
3171int yyparse (void *YYPARSE_PARAM);
3172#else
3173int yyparse ();
3174#endif
3175#else /* ! YYPARSE_PARAM */
3176#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003177int yyparse (void);
Scott Michel6d1aba82008-01-30 03:10:00 +00003178#else
Chris Lattner59363a32008-02-19 04:36:25 +00003179int yyparse ();
Christopher Lamb0a243582007-12-11 09:02:08 +00003180#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003181#endif /* ! YYPARSE_PARAM */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003182
Scott Michel5a6f17b2008-01-30 02:55:46 +00003183
Chris Lattner59363a32008-02-19 04:36:25 +00003184
3185/* The look-ahead symbol. */
3186int yychar;
3187
3188/* The semantic value of the look-ahead symbol. */
3189YYSTYPE yylval;
3190
3191/* Number of syntax errors so far. */
3192int yynerrs;
3193
3194
3195
3196/*----------.
3197| yyparse. |
3198`----------*/
3199
3200#ifdef YYPARSE_PARAM
3201#if (defined __STDC__ || defined __C99__FUNC__ \
3202 || defined __cplusplus || defined _MSC_VER)
3203int
3204yyparse (void *YYPARSE_PARAM)
3205#else
3206int
3207yyparse (YYPARSE_PARAM)
3208 void *YYPARSE_PARAM;
3209#endif
3210#else /* ! YYPARSE_PARAM */
3211#if (defined __STDC__ || defined __C99__FUNC__ \
3212 || defined __cplusplus || defined _MSC_VER)
3213int
3214yyparse (void)
3215#else
3216int
3217yyparse ()
3218
Scott Michel6d1aba82008-01-30 03:10:00 +00003219#endif
3220#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003221{
3222
3223 int yystate;
3224 int yyn;
3225 int yyresult;
3226 /* Number of tokens to shift before error messages enabled. */
3227 int yyerrstatus;
3228 /* Look-ahead token as an internal (translated) token number. */
3229 int yytoken = 0;
3230#if YYERROR_VERBOSE
3231 /* Buffer for error messages, and its allocated size. */
3232 char yymsgbuf[128];
3233 char *yymsg = yymsgbuf;
3234 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Scott Michel6d1aba82008-01-30 03:10:00 +00003235#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00003236
Chris Lattner59363a32008-02-19 04:36:25 +00003237 /* Three stacks and their tools:
3238 `yyss': related to states,
3239 `yyvs': related to semantic values,
3240 `yyls': related to locations.
3241
3242 Refer to the stacks thru separate pointers, to allow yyoverflow
3243 to reallocate them elsewhere. */
3244
3245 /* The state stack. */
3246 yytype_int16 yyssa[YYINITDEPTH];
3247 yytype_int16 *yyss = yyssa;
3248 yytype_int16 *yyssp;
3249
3250 /* The semantic value stack. */
3251 YYSTYPE yyvsa[YYINITDEPTH];
3252 YYSTYPE *yyvs = yyvsa;
3253 YYSTYPE *yyvsp;
3254
3255
3256
3257#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3258
3259 YYSIZE_T yystacksize = YYINITDEPTH;
3260
3261 /* The variables used to return semantic value and location from the
3262 action routines. */
3263 YYSTYPE yyval;
3264
3265
3266 /* The number of symbols on the RHS of the reduced rule.
3267 Keep to zero when no symbol should be popped. */
3268 int yylen = 0;
3269
3270 YYDPRINTF ((stderr, "Starting parse\n"));
3271
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003272 yystate = 0;
3273 yyerrstatus = 0;
3274 yynerrs = 0;
3275 yychar = YYEMPTY; /* Cause a token to be read. */
3276
3277 /* Initialize stack pointers.
3278 Waste one element of value and location stack
3279 so that they stay on the same level as the state stack.
3280 The wasted elements are never initialized. */
3281
Chris Lattner59363a32008-02-19 04:36:25 +00003282 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003283 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284
Chris Lattner59363a32008-02-19 04:36:25 +00003285 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286
Chris Lattner59363a32008-02-19 04:36:25 +00003287/*------------------------------------------------------------.
3288| yynewstate -- Push a new state, which is found in yystate. |
3289`------------------------------------------------------------*/
3290 yynewstate:
3291 /* In all cases, when you get here, the value and location stacks
3292 have just been pushed. So pushing a state here evens the stacks. */
3293 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003294
Chris Lattner59363a32008-02-19 04:36:25 +00003295 yysetstate:
3296 *yyssp = yystate;
3297
3298 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300 /* Get the current used size of the three stacks, in elements. */
Chris Lattner59363a32008-02-19 04:36:25 +00003301 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003302
3303#ifdef yyoverflow
Chris Lattner59363a32008-02-19 04:36:25 +00003304 {
3305 /* Give user a chance to reallocate the stack. Use copies of
3306 these so that the &'s don't force the real ones into
3307 memory. */
3308 YYSTYPE *yyvs1 = yyvs;
3309 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310
Chris Lattner59363a32008-02-19 04:36:25 +00003311
3312 /* Each stack pointer address is followed by the size of the
3313 data in use in that stack, in bytes. This used to be a
3314 conditional around just the two extra args, but that might
3315 be undefined if yyoverflow is a macro. */
3316 yyoverflow (YY_("memory exhausted"),
3317 &yyss1, yysize * sizeof (*yyssp),
3318 &yyvs1, yysize * sizeof (*yyvsp),
3319
3320 &yystacksize);
3321
3322 yyss = yyss1;
3323 yyvs = yyvs1;
3324 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325#else /* no yyoverflow */
Chris Lattner59363a32008-02-19 04:36:25 +00003326# ifndef YYSTACK_RELOCATE
3327 goto yyexhaustedlab;
3328# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329 /* Extend the stack our own way. */
Chris Lattner59363a32008-02-19 04:36:25 +00003330 if (YYMAXDEPTH <= yystacksize)
3331 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332 yystacksize *= 2;
Chris Lattner59363a32008-02-19 04:36:25 +00003333 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334 yystacksize = YYMAXDEPTH;
Chris Lattner59363a32008-02-19 04:36:25 +00003335
3336 {
3337 yytype_int16 *yyss1 = yyss;
3338 union yyalloc *yyptr =
3339 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3340 if (! yyptr)
3341 goto yyexhaustedlab;
3342 YYSTACK_RELOCATE (yyss);
3343 YYSTACK_RELOCATE (yyvs);
3344
3345# undef YYSTACK_RELOCATE
3346 if (yyss1 != yyssa)
3347 YYSTACK_FREE (yyss1);
3348 }
3349# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350#endif /* no yyoverflow */
3351
Chris Lattner59363a32008-02-19 04:36:25 +00003352 yyssp = yyss + yysize - 1;
3353 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355
Chris Lattner59363a32008-02-19 04:36:25 +00003356 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3357 (unsigned long int) yystacksize));
3358
3359 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360 YYABORT;
3361 }
3362
Chris Lattner59363a32008-02-19 04:36:25 +00003363 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364
3365 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366
Chris Lattner59363a32008-02-19 04:36:25 +00003367/*-----------.
3368| yybackup. |
3369`-----------*/
3370yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371
Chris Lattner59363a32008-02-19 04:36:25 +00003372 /* Do appropriate processing given the current state. Read a
3373 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374
Chris Lattner59363a32008-02-19 04:36:25 +00003375 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376 yyn = yypact[yystate];
Chris Lattner59363a32008-02-19 04:36:25 +00003377 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003378 goto yydefault;
3379
Chris Lattner59363a32008-02-19 04:36:25 +00003380 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003381
Chris Lattner59363a32008-02-19 04:36:25 +00003382 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 if (yychar == YYEMPTY)
3384 {
Chris Lattner59363a32008-02-19 04:36:25 +00003385 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003386 yychar = YYLEX;
3387 }
3388
Chris Lattner59363a32008-02-19 04:36:25 +00003389 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003390 {
Chris Lattner59363a32008-02-19 04:36:25 +00003391 yychar = yytoken = YYEOF;
3392 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 }
3394 else
3395 {
Chris Lattner59363a32008-02-19 04:36:25 +00003396 yytoken = YYTRANSLATE (yychar);
3397 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003398 }
3399
Chris Lattner59363a32008-02-19 04:36:25 +00003400 /* If the proper action on seeing token YYTOKEN is to reduce or to
3401 detect an error, take that action. */
3402 yyn += yytoken;
3403 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405 yyn = yytable[yyn];
Chris Lattner59363a32008-02-19 04:36:25 +00003406 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003407 {
Chris Lattner59363a32008-02-19 04:36:25 +00003408 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003409 goto yyerrlab;
3410 yyn = -yyn;
3411 goto yyreduce;
3412 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003413
3414 if (yyn == YYFINAL)
3415 YYACCEPT;
3416
Chris Lattner59363a32008-02-19 04:36:25 +00003417 /* Count tokens shifted since error; after three, turn off error
3418 status. */
3419 if (yyerrstatus)
3420 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003421
Chris Lattner59363a32008-02-19 04:36:25 +00003422 /* Shift the look-ahead token. */
3423 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003424
Chris Lattner59363a32008-02-19 04:36:25 +00003425 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003426 if (yychar != YYEOF)
3427 yychar = YYEMPTY;
3428
Scott Michel6d1aba82008-01-30 03:10:00 +00003429 yystate = yyn;
Chris Lattner59363a32008-02-19 04:36:25 +00003430 *++yyvsp = yylval;
3431
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432 goto yynewstate;
3433
Scott Michel6d1aba82008-01-30 03:10:00 +00003434
Chris Lattner59363a32008-02-19 04:36:25 +00003435/*-----------------------------------------------------------.
3436| yydefault -- do the default action for the current state. |
3437`-----------------------------------------------------------*/
3438yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003439 yyn = yydefact[yystate];
3440 if (yyn == 0)
3441 goto yyerrlab;
Chris Lattner59363a32008-02-19 04:36:25 +00003442 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003443
Chris Lattner59363a32008-02-19 04:36:25 +00003444
3445/*-----------------------------.
3446| yyreduce -- Do a reduction. |
3447`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003448yyreduce:
Chris Lattner59363a32008-02-19 04:36:25 +00003449 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003450 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451
Chris Lattner59363a32008-02-19 04:36:25 +00003452 /* If YYLEN is nonzero, implement the default value of the action:
3453 `$$ = $1'.
3454
3455 Otherwise, the following line sets YYVAL to garbage.
3456 This behavior is undocumented and Bison
3457 users should not rely upon it. Assigning to YYVAL
3458 unconditionally makes the parser a bit smaller, and it avoids a
3459 GCC warning that YYVAL may be used uninitialized. */
3460 yyval = yyvsp[1-yylen];
3461
3462
3463 YY_REDUCE_PRINT (yyn);
3464 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003465 {
Chris Lattner59363a32008-02-19 04:36:25 +00003466 case 29:
3467#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3468 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3469 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003470
Chris Lattner59363a32008-02-19 04:36:25 +00003471 case 30:
3472#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3473 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3474 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003475
Chris Lattner59363a32008-02-19 04:36:25 +00003476 case 31:
3477#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3478 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3479 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480
Chris Lattner59363a32008-02-19 04:36:25 +00003481 case 32:
3482#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3483 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3484 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003485
Chris Lattner59363a32008-02-19 04:36:25 +00003486 case 33:
3487#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3488 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3489 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003490
Chris Lattner59363a32008-02-19 04:36:25 +00003491 case 34:
3492#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3493 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3494 break;
3495
3496 case 35:
3497#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3498 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3499 break;
3500
3501 case 36:
3502#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3503 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3504 break;
3505
3506 case 37:
3507#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3508 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3509 break;
3510
3511 case 38:
3512#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3513 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3514 break;
3515
3516 case 39:
3517#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3518 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3519 break;
3520
3521 case 40:
3522#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3523 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3524 break;
3525
3526 case 41:
3527#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3528 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3529 break;
3530
3531 case 42:
3532#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3533 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3534 break;
3535
3536 case 43:
3537#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3538 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3539 break;
3540
3541 case 44:
3542#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3543 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3544 break;
3545
3546 case 45:
3547#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3548 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3549 break;
3550
3551 case 46:
3552#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3553 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3554 break;
3555
3556 case 47:
3557#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3558 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3559 break;
3560
3561 case 48:
3562#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3563 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3564 break;
3565
3566 case 49:
3567#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3568 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3569 break;
3570
3571 case 50:
3572#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3573 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3574 break;
3575
3576 case 51:
3577#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3578 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3579 break;
3580
3581 case 52:
3582#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3583 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3584 break;
3585
3586 case 53:
3587#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3588 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3589 break;
3590
3591 case 54:
3592#line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3593 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3594 break;
3595
3596 case 65:
3597#line 1142 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3598 { (yyval.StrVal) = 0; ;}
3599 break;
3600
3601 case 66:
3602#line 1144 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3603 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3604 break;
3605
3606 case 67:
3607#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3608 { (yyval.UIntVal)=0; ;}
3609 break;
3610
3611 case 68:
3612#line 1149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3613 {
3614 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003615 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003616 ;}
3617 break;
3618
3619 case 69:
3620#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3621 {
3622 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003623 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003624 ;}
3625 break;
3626
3627 case 73:
3628#line 1161 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3629 {
3630 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003631 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003632 ;}
3633 break;
3634
3635 case 74:
3636#line 1166 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3637 {
3638 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00003639 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003640 ;}
3641 break;
3642
3643 case 75:
3644#line 1172 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3645 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3646 break;
3647
3648 case 76:
3649#line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3650 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3651 break;
3652
3653 case 77:
3654#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3655 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3656 break;
3657
3658 case 78:
3659#line 1175 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3660 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3661 break;
3662
3663 case 79:
3664#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3665 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3666 break;
3667
3668 case 80:
3669#line 1180 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3670 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3671 break;
3672
3673 case 81:
3674#line 1181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3675 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3676 break;
3677
3678 case 82:
3679#line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3680 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3681 break;
3682
3683 case 83:
3684#line 1186 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3685 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3686 break;
3687
3688 case 84:
3689#line 1187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3690 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3691 break;
3692
3693 case 85:
3694#line 1188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3695 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3696 break;
3697
3698 case 86:
3699#line 1189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3700 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3701 break;
3702
3703 case 87:
3704#line 1193 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3705 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3706 break;
3707
3708 case 88:
3709#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3710 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3711 break;
3712
3713 case 89:
3714#line 1195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3715 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3716 break;
3717
3718 case 90:
3719#line 1199 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3720 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3721 break;
3722
3723 case 91:
3724#line 1200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3725 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3726 break;
3727
3728 case 92:
3729#line 1201 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3730 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3731 break;
3732
3733 case 93:
3734#line 1202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3735 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3736 break;
3737
3738 case 94:
3739#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3740 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3741 break;
3742
3743 case 95:
3744#line 1207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3745 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3746 break;
3747
3748 case 96:
3749#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3750 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3751 break;
3752
3753 case 97:
3754#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3755 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3756 break;
3757
3758 case 98:
3759#line 1212 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3760 { (yyval.UIntVal) = CallingConv::C; ;}
3761 break;
3762
3763 case 99:
3764#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3765 { (yyval.UIntVal) = CallingConv::C; ;}
3766 break;
3767
3768 case 100:
3769#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3770 { (yyval.UIntVal) = CallingConv::Fast; ;}
3771 break;
3772
3773 case 101:
3774#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3775 { (yyval.UIntVal) = CallingConv::Cold; ;}
3776 break;
3777
3778 case 102:
3779#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3780 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3781 break;
3782
3783 case 103:
3784#line 1217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3785 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3786 break;
3787
3788 case 104:
3789#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3790 {
3791 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003792 GEN_ERROR("Calling conv too large");
Chris Lattner59363a32008-02-19 04:36:25 +00003793 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003794 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003795 ;}
3796 break;
3797
3798 case 105:
3799#line 1225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3800 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3801 break;
3802
3803 case 106:
3804#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3805 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3806 break;
3807
3808 case 107:
3809#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3810 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3811 break;
3812
3813 case 108:
3814#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3815 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3816 break;
3817
3818 case 109:
3819#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3820 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3821 break;
3822
3823 case 110:
3824#line 1230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3825 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3826 break;
3827
3828 case 111:
3829#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3830 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3831 break;
3832
3833 case 112:
3834#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3835 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3836 break;
3837
3838 case 113:
3839#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3840 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3841 break;
3842
3843 case 114:
3844#line 1236 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3845 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3846 break;
3847
3848 case 115:
3849#line 1237 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3850 {
3851 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3852 ;}
3853 break;
3854
3855 case 116:
3856#line 1242 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3857 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3858 break;
3859
3860 case 117:
3861#line 1243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3862 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3863 break;
3864
3865 case 118:
3866#line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3867 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3868 break;
3869
3870 case 119:
3871#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3872 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3873 break;
3874
3875 case 120:
3876#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3877 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
3878 break;
3879
3880 case 121:
3881#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3882 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
3883 break;
3884
3885 case 122:
3886#line 1250 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3887 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3888 break;
3889
3890 case 123:
3891#line 1251 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3892 {
3893 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3894 ;}
3895 break;
3896
3897 case 124:
3898#line 1256 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3899 { (yyval.StrVal) = 0; ;}
3900 break;
3901
3902 case 125:
3903#line 1257 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3904 {
3905 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3906 ;}
3907 break;
3908
3909 case 126:
3910#line 1264 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3911 { (yyval.UIntVal) = 0; ;}
3912 break;
3913
3914 case 127:
3915#line 1265 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3916 {
3917 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3918 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003919 GEN_ERROR("Alignment must be a power of two");
3920 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003921;}
3922 break;
3923
3924 case 128:
3925#line 1271 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3926 { (yyval.UIntVal) = 0; ;}
3927 break;
3928
3929 case 129:
3930#line 1272 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3931 {
3932 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3933 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lamb668d9a02007-12-12 08:45:45 +00003934 GEN_ERROR("Alignment must be a power of two");
3935 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003936;}
3937 break;
3938
3939 case 130:
3940#line 1281 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3941 {
3942 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3943 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003944 GEN_ERROR("Invalid character in section name");
Chris Lattner59363a32008-02-19 04:36:25 +00003945 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003946 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003947;}
3948 break;
3949
3950 case 131:
3951#line 1289 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3952 { (yyval.StrVal) = 0; ;}
3953 break;
3954
3955 case 132:
3956#line 1290 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3957 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3958 break;
3959
3960 case 133:
3961#line 1295 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3962 {;}
3963 break;
3964
3965 case 134:
3966#line 1296 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3967 {;}
3968 break;
3969
3970 case 135:
3971#line 1297 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3972 {
3973 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3974 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003975 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003976 ;}
3977 break;
3978
3979 case 136:
3980#line 1302 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3981 {
3982 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003983 GEN_ERROR("Alignment must be a power of two");
Chris Lattner59363a32008-02-19 04:36:25 +00003984 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003985 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003986 ;}
3987 break;
3988
3989 case 144:
3990#line 1318 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3991 {
3992 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003993 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003994 ;}
3995 break;
3996
3997 case 145:
3998#line 1322 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3999 {
4000 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004001 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004002 ;}
4003 break;
4004
4005 case 146:
4006#line 1326 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4007 { // Pointer type?
4008 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00004009 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner59363a32008-02-19 04:36:25 +00004010 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4011 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00004012 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004013 ;}
4014 break;
4015
4016 case 147:
4017#line 1333 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4018 { // Named types are also simple types...
4019 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamb0a243582007-12-11 09:02:08 +00004020 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004021 (yyval.TypeVal) = new PATypeHolder(tmp);
4022 ;}
4023 break;
4024
4025 case 148:
4026#line 1338 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4027 { // Type UpReference
4028 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004029 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner59363a32008-02-19 04:36:25 +00004030 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4031 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004032 UR_OUT("New Upreference!\n");
4033 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004034 ;}
4035 break;
4036
4037 case 149:
4038#line 1346 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4039 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004040 // Allow but ignore attributes on function types; this permits auto-upgrade.
4041 // FIXME: remove in LLVM 3.0.
Chris Lattner59363a32008-02-19 04:36:25 +00004042 const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal);
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004043 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
4044 isa<OpaqueType>(RetTy)))
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004045 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004046
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004047 std::vector<const Type*> Params;
Chris Lattner59363a32008-02-19 04:36:25 +00004048 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004049 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004050 const Type *Ty = I->Ty->get();
4051 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004052 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004053
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004054 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4055 if (isVarArg) Params.pop_back();
4056
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004057 for (unsigned i = 0; i != Params.size(); ++i)
4058 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4059 GEN_ERROR("Function arguments must be value types!");
4060
4061 CHECK_FOR_ERROR
4062
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004063 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Chris Lattner59363a32008-02-19 04:36:25 +00004064 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4065 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4066 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004067 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004068 ;}
4069 break;
4070
4071 case 150:
4072#line 1376 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4073 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004074 // Allow but ignore attributes on function types; this permits auto-upgrade.
4075 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004076 std::vector<const Type*> Params;
Chris Lattner59363a32008-02-19 04:36:25 +00004077 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004078 for ( ; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004079 const Type* Ty = I->Ty->get();
4080 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004081 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004082
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004083 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4084 if (isVarArg) Params.pop_back();
4085
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004086 for (unsigned i = 0; i != Params.size(); ++i)
4087 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4088 GEN_ERROR("Function arguments must be value types!");
4089
4090 CHECK_FOR_ERROR
4091
Chris Lattner59363a32008-02-19 04:36:25 +00004092 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4093 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4094 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004095 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004096 ;}
4097 break;
4098
4099 case 151:
4100#line 1401 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4101 { // Sized array type?
4102 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4103 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004104 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004105 ;}
4106 break;
4107
4108 case 152:
4109#line 1406 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4110 { // Vector type?
4111 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4112 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004113 GEN_ERROR("Unsigned result not equal to signed result");
4114 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4115 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner59363a32008-02-19 04:36:25 +00004116 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4117 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004118 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004119 ;}
4120 break;
4121
4122 case 153:
4123#line 1416 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4124 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004125 std::vector<const Type*> Elements;
Chris Lattner59363a32008-02-19 04:36:25 +00004126 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4127 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004128 Elements.push_back(*I);
4129
Chris Lattner59363a32008-02-19 04:36:25 +00004130 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4131 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004132 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004133 ;}
4134 break;
4135
4136 case 154:
4137#line 1426 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4138 { // Empty structure type?
4139 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004140 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004141 ;}
4142 break;
4143
4144 case 155:
4145#line 1430 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4146 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004147 std::vector<const Type*> Elements;
Chris Lattner59363a32008-02-19 04:36:25 +00004148 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4149 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004150 Elements.push_back(*I);
4151
Chris Lattner59363a32008-02-19 04:36:25 +00004152 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4153 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004154 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004155 ;}
4156 break;
4157
4158 case 156:
4159#line 1440 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4160 { // Empty structure type?
4161 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004162 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004163 ;}
4164 break;
4165
4166 case 157:
4167#line 1447 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4168 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004169 // Allow but ignore attributes on function types; this permits auto-upgrade.
4170 // FIXME: remove in LLVM 3.0.
Chris Lattner59363a32008-02-19 04:36:25 +00004171 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4172 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4173 ;}
4174 break;
4175
4176 case 158:
4177#line 1456 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4178 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004179 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004180 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4181 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004182 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner59363a32008-02-19 04:36:25 +00004183 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4184 ;}
4185 break;
4186
4187 case 159:
4188#line 1463 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4189 {
4190 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4191 ;}
4192 break;
4193
4194 case 160:
4195#line 1468 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4196 {
4197 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4198 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004199 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004200 ;}
4201 break;
4202
4203 case 161:
4204#line 1473 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4205 {
4206 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004207 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004208 ;}
4209 break;
4210
4211 case 163:
4212#line 1481 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4213 {
4214 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004215 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4216 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner59363a32008-02-19 04:36:25 +00004217 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004218 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004219 ;}
4220 break;
4221
4222 case 164:
4223#line 1488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4224 {
4225 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004226 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4227 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner59363a32008-02-19 04:36:25 +00004228 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004229 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004230 ;}
4231 break;
4232
4233 case 165:
4234#line 1495 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4235 {
4236 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004237 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004238 ;}
4239 break;
4240
4241 case 166:
4242#line 1503 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4243 {
4244 (yyval.TypeList) = new std::list<PATypeHolder>();
4245 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4246 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004247 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004248 ;}
4249 break;
4250
4251 case 167:
4252#line 1509 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4253 {
4254 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4255 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004256 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004257 ;}
4258 break;
4259
4260 case 168:
4261#line 1521 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4262 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004264 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4265 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004266 if (ATy == 0)
4267 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004268 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004269 const Type *ETy = ATy->getElementType();
4270 int NumElements = ATy->getNumElements();
4271
4272 // Verify that we have the correct size...
Chris Lattner59363a32008-02-19 04:36:25 +00004273 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004274 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner59363a32008-02-19 04:36:25 +00004275 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004276 itostr(NumElements) + "");
4277
4278 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00004279 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4280 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004281 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4282 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner59363a32008-02-19 04:36:25 +00004283 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004284 }
4285
Chris Lattner59363a32008-02-19 04:36:25 +00004286 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4287 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004288 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004289 ;}
4290 break;
4291
4292 case 169:
4293#line 1549 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4294 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004296 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4297 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004298 if (ATy == 0)
4299 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004300 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004301
4302 int NumElements = ATy->getNumElements();
4303 if (NumElements != -1 && NumElements != 0)
4304 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4305 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner59363a32008-02-19 04:36:25 +00004306 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4307 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004308 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004309 ;}
4310 break;
4311
4312 case 170:
4313#line 1565 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4314 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004315 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004316 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4317 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004318 if (ATy == 0)
4319 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004320 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004321
4322 int NumElements = ATy->getNumElements();
4323 const Type *ETy = ATy->getElementType();
Chris Lattner59363a32008-02-19 04:36:25 +00004324 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004325 GEN_ERROR("Can't build string constant of size " +
Chris Lattner59363a32008-02-19 04:36:25 +00004326 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004327 " when array has size " + itostr(NumElements) + "");
4328 std::vector<Constant*> Vals;
4329 if (ETy == Type::Int8Ty) {
Chris Lattner59363a32008-02-19 04:36:25 +00004330 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4331 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004332 } else {
Chris Lattner59363a32008-02-19 04:36:25 +00004333 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004334 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4335 }
Chris Lattner59363a32008-02-19 04:36:25 +00004336 delete (yyvsp[(3) - (3)].StrVal);
4337 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4338 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004339 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004340 ;}
4341 break;
4342
4343 case 171:
4344#line 1592 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4345 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004346 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004347 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4348 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004349 if (PTy == 0)
4350 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004351 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004352 const Type *ETy = PTy->getElementType();
4353 int NumElements = PTy->getNumElements();
4354
4355 // Verify that we have the correct size...
Chris Lattner59363a32008-02-19 04:36:25 +00004356 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004357 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner59363a32008-02-19 04:36:25 +00004358 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004359 itostr(NumElements) + "");
4360
4361 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00004362 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4363 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004364 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4365 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner59363a32008-02-19 04:36:25 +00004366 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004367 }
4368
Chris Lattner59363a32008-02-19 04:36:25 +00004369 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4370 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004371 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004372 ;}
4373 break;
4374
4375 case 172:
4376#line 1620 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4377 {
4378 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004379 if (STy == 0)
4380 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004381 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004382
Chris Lattner59363a32008-02-19 04:36:25 +00004383 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004384 GEN_ERROR("Illegal number of initializers for structure type");
4385
4386 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner59363a32008-02-19 04:36:25 +00004387 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4388 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004389 GEN_ERROR("Expected type '" +
4390 STy->getElementType(i)->getDescription() +
4391 "' for element #" + utostr(i) +
4392 " of structure initializer");
4393
4394 // Check to ensure that Type is not packed
4395 if (STy->isPacked())
4396 GEN_ERROR("Unpacked Initializer to vector type '" +
4397 STy->getDescription() + "'");
4398
Chris Lattner59363a32008-02-19 04:36:25 +00004399 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4400 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004401 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004402 ;}
4403 break;
4404
4405 case 173:
4406#line 1646 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4407 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004408 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004409 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4410 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004411 if (STy == 0)
4412 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004413 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004414
4415 if (STy->getNumContainedTypes() != 0)
4416 GEN_ERROR("Illegal number of initializers for structure type");
4417
4418 // Check to ensure that Type is not packed
4419 if (STy->isPacked())
4420 GEN_ERROR("Unpacked Initializer to vector type '" +
4421 STy->getDescription() + "'");
4422
Chris Lattner59363a32008-02-19 04:36:25 +00004423 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4424 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004425 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004426 ;}
4427 break;
4428
4429 case 174:
4430#line 1666 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4431 {
4432 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004433 if (STy == 0)
4434 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004435 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004436
Chris Lattner59363a32008-02-19 04:36:25 +00004437 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004438 GEN_ERROR("Illegal number of initializers for structure type");
4439
4440 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner59363a32008-02-19 04:36:25 +00004441 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4442 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004443 GEN_ERROR("Expected type '" +
4444 STy->getElementType(i)->getDescription() +
4445 "' for element #" + utostr(i) +
4446 " of structure initializer");
4447
4448 // Check to ensure that Type is packed
4449 if (!STy->isPacked())
4450 GEN_ERROR("Vector initializer to non-vector type '" +
4451 STy->getDescription() + "'");
4452
Chris Lattner59363a32008-02-19 04:36:25 +00004453 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4454 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004455 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004456 ;}
4457 break;
4458
4459 case 175:
4460#line 1692 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4461 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004462 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004463 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4464 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004465 if (STy == 0)
4466 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004467 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004468
4469 if (STy->getNumContainedTypes() != 0)
4470 GEN_ERROR("Illegal number of initializers for structure type");
4471
4472 // Check to ensure that Type is packed
4473 if (!STy->isPacked())
4474 GEN_ERROR("Vector initializer to non-vector type '" +
4475 STy->getDescription() + "'");
4476
Chris Lattner59363a32008-02-19 04:36:25 +00004477 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4478 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004479 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004480 ;}
4481 break;
4482
4483 case 176:
4484#line 1712 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4485 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004486 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004487 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4488 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004489 if (PTy == 0)
4490 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004491 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004492
Chris Lattner59363a32008-02-19 04:36:25 +00004493 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4494 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004495 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004496 ;}
4497 break;
4498
4499 case 177:
4500#line 1724 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4501 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004502 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004503 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4504 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4505 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004506 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004507 ;}
4508 break;
4509
4510 case 178:
4511#line 1731 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4512 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004513 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004514 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4515 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004516 if (Ty == 0)
4517 GEN_ERROR("Global const reference must be a pointer type");
4518
4519 // ConstExprs can exist in the body of a function, thus creating
4520 // GlobalValues whenever they refer to a variable. Because we are in
4521 // the context of a function, getExistingVal will search the functions
4522 // symbol table instead of the module symbol table for the global symbol,
4523 // which throws things all off. To get around this, we just tell
4524 // getExistingVal that we are at global scope here.
4525 //
4526 Function *SavedCurFn = CurFun.CurrentFunction;
4527 CurFun.CurrentFunction = 0;
4528
Chris Lattner59363a32008-02-19 04:36:25 +00004529 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004530 CHECK_FOR_ERROR
4531
4532 CurFun.CurrentFunction = SavedCurFn;
4533
4534 // If this is an initializer for a constant pointer, which is referencing a
4535 // (currently) undefined variable, create a stub now that shall be replaced
4536 // in the future with the right type of variable.
4537 //
4538 if (V == 0) {
4539 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4540 const PointerType *PT = cast<PointerType>(Ty);
4541
4542 // First check to see if the forward references value is already created!
4543 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner59363a32008-02-19 04:36:25 +00004544 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004545
4546 if (I != CurModule.GlobalRefs.end()) {
4547 V = I->second; // Placeholder already exists, use it...
Chris Lattner59363a32008-02-19 04:36:25 +00004548 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004549 } else {
4550 std::string Name;
Chris Lattner59363a32008-02-19 04:36:25 +00004551 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4552 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4553 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004554 GEN_ERROR("Invalid reference to global");
4555
4556 // Create the forward referenced global.
4557 GlobalValue *GV;
4558 if (const FunctionType *FTy =
4559 dyn_cast<FunctionType>(PT->getElementType())) {
4560 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
4561 CurModule.CurrentModule);
4562 } else {
4563 GV = new GlobalVariable(PT->getElementType(), false,
4564 GlobalValue::ExternalWeakLinkage, 0,
4565 Name, CurModule.CurrentModule);
4566 }
4567
4568 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner59363a32008-02-19 04:36:25 +00004569 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004570 V = GV;
4571 }
4572 }
4573
Chris Lattner59363a32008-02-19 04:36:25 +00004574 (yyval.ConstVal) = cast<GlobalValue>(V);
4575 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004576 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004577 ;}
4578 break;
4579
4580 case 179:
4581#line 1797 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4582 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004583 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004584 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4585 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004586 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner59363a32008-02-19 04:36:25 +00004587 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4588 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4589 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004590 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004591 ;}
4592 break;
4593
4594 case 180:
4595#line 1807 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4596 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004597 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004598 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4599 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004600 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4601 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner59363a32008-02-19 04:36:25 +00004602 (yyval.ConstVal) = Constant::getNullValue(Ty);
4603 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004604 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004605 ;}
4606 break;
4607
4608 case 181:
4609#line 1817 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4610 { // integral constants
4611 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004612 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner59363a32008-02-19 04:36:25 +00004613 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004614 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004615 ;}
4616 break;
4617
4618 case 182:
4619#line 1823 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4620 { // arbitrary precision integer constants
4621 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4622 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004623 GEN_ERROR("Constant value does not fit in type");
4624 }
Chris Lattner59363a32008-02-19 04:36:25 +00004625 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4626 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4627 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004628 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004629 ;}
4630 break;
4631
4632 case 183:
4633#line 1833 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4634 { // integral constants
4635 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004636 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner59363a32008-02-19 04:36:25 +00004637 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004638 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004639 ;}
4640 break;
4641
4642 case 184:
4643#line 1839 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4644 { // arbitrary precision integer constants
4645 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4646 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004647 GEN_ERROR("Constant value does not fit in type");
4648 }
Chris Lattner59363a32008-02-19 04:36:25 +00004649 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4650 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4651 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004652 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004653 ;}
4654 break;
4655
4656 case 185:
4657#line 1849 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4658 { // Boolean constants
4659 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4660 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004661 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004662 ;}
4663 break;
4664
4665 case 186:
4666#line 1854 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4667 { // Boolean constants
4668 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4669 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004670 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004671 ;}
4672 break;
4673
4674 case 187:
4675#line 1859 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4676 { // Floating point constants
4677 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004678 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004679 // Lexer has no type info, so builds all float and double FP constants
4680 // as double. Fix this here. Long double is done right.
Chris Lattner59363a32008-02-19 04:36:25 +00004681 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4682 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4683 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal));
4684 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004685 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004686 ;}
4687 break;
4688
4689 case 188:
4690#line 1872 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4691 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004692 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004693 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4694 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4695 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4696 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004697 GEN_ERROR("invalid cast opcode for cast from '" +
4698 Val->getType()->getDescription() + "' to '" +
4699 DestTy->getDescription() + "'");
Chris Lattner59363a32008-02-19 04:36:25 +00004700 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4701 delete (yyvsp[(5) - (6)].TypeVal);
4702 ;}
4703 break;
4704
4705 case 189:
4706#line 1884 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4707 {
4708 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004709 GEN_ERROR("GetElementPtr requires a pointer operand");
4710
4711 const Type *IdxTy =
Chris Lattner59363a32008-02-19 04:36:25 +00004712 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004713 true);
4714 if (!IdxTy)
4715 GEN_ERROR("Index list invalid for constant getelementptr");
4716
4717 SmallVector<Constant*, 8> IdxVec;
Chris Lattner59363a32008-02-19 04:36:25 +00004718 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4719 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004720 IdxVec.push_back(C);
4721 else
4722 GEN_ERROR("Indices to constant getelementptr must be constants");
4723
Chris Lattner59363a32008-02-19 04:36:25 +00004724 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004725
Chris Lattner59363a32008-02-19 04:36:25 +00004726 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004727 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004728 ;}
4729 break;
4730
4731 case 190:
4732#line 1906 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4733 {
4734 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004735 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner59363a32008-02-19 04:36:25 +00004736 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004737 GEN_ERROR("Select operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004738 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004739 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004740 ;}
4741 break;
4742
4743 case 191:
4744#line 1914 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4745 {
4746 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004747 GEN_ERROR("Binary operator types must match");
4748 CHECK_FOR_ERROR;
Chris Lattner59363a32008-02-19 04:36:25 +00004749 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4750 ;}
4751 break;
4752
4753 case 192:
4754#line 1920 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4755 {
4756 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004757 GEN_ERROR("Logical operator types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004758 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4759 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4760 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004761 GEN_ERROR("Logical operator requires integral operands");
4762 }
Chris Lattner59363a32008-02-19 04:36:25 +00004763 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004764 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004765 ;}
4766 break;
4767
4768 case 193:
4769#line 1931 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4770 {
4771 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004772 GEN_ERROR("icmp operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004773 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4774 ;}
4775 break;
4776
4777 case 194:
4778#line 1936 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4779 {
4780 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004781 GEN_ERROR("fcmp operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004782 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4783 ;}
4784 break;
4785
4786 case 195:
4787#line 1941 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4788 {
4789 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004790 GEN_ERROR("Invalid extractelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004791 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004792 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004793 ;}
4794 break;
4795
4796 case 196:
4797#line 1947 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4798 {
4799 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004800 GEN_ERROR("Invalid insertelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004801 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004802 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004803 ;}
4804 break;
4805
4806 case 197:
4807#line 1953 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4808 {
4809 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004810 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004811 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004812 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004813 ;}
4814 break;
4815
4816 case 198:
4817#line 1962 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4818 {
4819 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004820 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004821 ;}
4822 break;
4823
4824 case 199:
4825#line 1966 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4826 {
4827 (yyval.ConstVector) = new std::vector<Constant*>();
4828 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004829 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004830 ;}
4831 break;
4832
4833 case 200:
4834#line 1974 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4835 { (yyval.BoolVal) = false; ;}
4836 break;
4837
4838 case 201:
4839#line 1974 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4840 { (yyval.BoolVal) = true; ;}
4841 break;
4842
4843 case 202:
4844#line 1977 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4845 { (yyval.BoolVal) = true; ;}
4846 break;
4847
4848 case 203:
4849#line 1977 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4850 { (yyval.BoolVal) = false; ;}
4851 break;
4852
4853 case 204:
4854#line 1980 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4855 {
4856 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4857 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00004858 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004859 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4860 if (!Aliasee)
4861 GEN_ERROR("Aliases can be created only to global values");
4862
Chris Lattner59363a32008-02-19 04:36:25 +00004863 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004864 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004865 delete (yyvsp[(1) - (2)].TypeVal);
4866 ;}
4867 break;
4868
4869 case 205:
4870#line 1992 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4871 {
4872 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4873 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4874 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004875 GEN_ERROR("invalid cast opcode for cast from '" +
4876 Val->getType()->getDescription() + "' to '" +
4877 DestTy->getDescription() + "'");
4878
Chris Lattner59363a32008-02-19 04:36:25 +00004879 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004880 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004881 delete (yyvsp[(5) - (6)].TypeVal);
4882 ;}
4883 break;
4884
4885 case 206:
4886#line 2013 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4887 {
4888 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004889 CurModule.ModuleDone();
4890 CHECK_FOR_ERROR;
Chris Lattner59363a32008-02-19 04:36:25 +00004891 ;}
4892 break;
4893
4894 case 207:
4895#line 2018 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4896 {
4897 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lamb668d9a02007-12-12 08:45:45 +00004898 CurModule.ModuleDone();
4899 CHECK_FOR_ERROR;
Chris Lattner59363a32008-02-19 04:36:25 +00004900 ;}
4901 break;
4902
4903 case 210:
4904#line 2031 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4905 { CurFun.isDeclare = false; ;}
4906 break;
4907
4908 case 211:
4909#line 2031 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4910 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004911 CurFun.FunctionDone();
4912 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004913 ;}
4914 break;
4915
4916 case 212:
4917#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4918 { CurFun.isDeclare = true; ;}
4919 break;
4920
4921 case 213:
4922#line 2035 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4923 {
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00004924 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004925 ;}
4926 break;
4927
4928 case 214:
4929#line 2038 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4930 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00004931 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004932 ;}
4933 break;
4934
4935 case 215:
4936#line 2041 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4937 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004938 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004939 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004940 // Eagerly resolve types. This is not an optimization, this is a
4941 // requirement that is due to the fact that we could have this:
4942 //
4943 // %list = type { %list * }
4944 // %list = type { %list * } ; repeated type decl
4945 //
4946 // If types are not resolved eagerly, then the two types will not be
4947 // determined to be the same type!
4948 //
Chris Lattner59363a32008-02-19 04:36:25 +00004949 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004950
Chris Lattner59363a32008-02-19 04:36:25 +00004951 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004952 CHECK_FOR_ERROR
4953 // If this is a named type that is not a redefinition, add it to the slot
4954 // table.
Chris Lattner59363a32008-02-19 04:36:25 +00004955 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004956 }
4957
Chris Lattner59363a32008-02-19 04:36:25 +00004958 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004959 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004960 ;}
4961 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004962
Chris Lattner59363a32008-02-19 04:36:25 +00004963 case 216:
4964#line 2065 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4965 {
4966 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4967
4968 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004969 CHECK_FOR_ERROR
4970 // If this is a named type that is not a redefinition, add it to the slot
4971 // table.
Chris Lattner59363a32008-02-19 04:36:25 +00004972 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004973 }
4974 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004975 ;}
4976 break;
4977
4978 case 217:
4979#line 2077 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4980 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004981 /* "Externally Visible" Linkage */
Chris Lattner59363a32008-02-19 04:36:25 +00004982 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004983 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner59363a32008-02-19 04:36:25 +00004984 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
4985 (yyvsp[(2) - (6)].Visibility), (yyvsp[(4) - (6)].BoolVal), (yyvsp[(5) - (6)].ConstVal)->getType(), (yyvsp[(5) - (6)].ConstVal), (yyvsp[(3) - (6)].BoolVal), (yyvsp[(6) - (6)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004986 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004987 ;}
4988 break;
4989
4990 case 218:
4991#line 2084 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4992 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00004993 CurGV = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00004994 ;}
4995 break;
4996
4997 case 219:
4998#line 2088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4999 {
5000 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00005001 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner59363a32008-02-19 04:36:25 +00005002 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), (yyvsp[(6) - (7)].ConstVal)->getType(), (yyvsp[(6) - (7)].ConstVal), (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lamb668d9a02007-12-12 08:45:45 +00005003 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005004 ;}
5005 break;
5006
5007 case 220:
5008#line 2093 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5009 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005010 CurGV = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005011 ;}
5012 break;
5013
5014 case 221:
5015#line 2097 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5016 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005017 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005018 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5019 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), *(yyvsp[(6) - (7)].TypeVal), 0, (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lamb668d9a02007-12-12 08:45:45 +00005020 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005021 delete (yyvsp[(6) - (7)].TypeVal);
5022 ;}
5023 break;
5024
5025 case 222:
5026#line 2103 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5027 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005028 CurGV = 0;
5029 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005030 ;}
5031 break;
5032
5033 case 223:
5034#line 2107 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5035 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005036 std::string Name;
Chris Lattner59363a32008-02-19 04:36:25 +00005037 if ((yyvsp[(1) - (5)].StrVal)) {
5038 Name = *(yyvsp[(1) - (5)].StrVal);
5039 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005040 }
5041 if (Name.empty())
5042 GEN_ERROR("Alias name cannot be empty");
5043
Chris Lattner59363a32008-02-19 04:36:25 +00005044 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005045 if (Aliasee == 0)
5046 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
5047
Chris Lattner59363a32008-02-19 04:36:25 +00005048 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005049 CurModule.CurrentModule);
Chris Lattner59363a32008-02-19 04:36:25 +00005050 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005051 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00005052
5053
5054 // If there was a forward reference of this alias, resolve it now.
5055
5056 ValID ID;
5057 if (!Name.empty())
5058 ID = ValID::createGlobalName(Name);
5059 else
5060 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5061
5062 if (GlobalValue *FWGV =
5063 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5064 // Replace uses of the fwdref with the actual alias.
5065 FWGV->replaceAllUsesWith(GA);
5066 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5067 GV->eraseFromParent();
5068 else
5069 cast<Function>(FWGV)->eraseFromParent();
5070 }
5071 ID.destroy();
5072
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005073 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005074 ;}
5075 break;
5076
5077 case 224:
5078#line 2147 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5079 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005080 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005081 ;}
5082 break;
5083
5084 case 225:
5085#line 2150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5086 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005087 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005088 ;}
5089 break;
5090
5091 case 226:
5092#line 2156 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5093 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005094 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5095 if (AsmSoFar.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005096 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005097 else
Chris Lattner59363a32008-02-19 04:36:25 +00005098 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5099 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005100 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005101;}
5102 break;
5103
5104 case 227:
5105#line 2166 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5106 {
5107 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5108 delete (yyvsp[(3) - (3)].StrVal);
5109 ;}
5110 break;
5111
5112 case 228:
5113#line 2170 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5114 {
5115 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5116 delete (yyvsp[(3) - (3)].StrVal);
5117 ;}
5118 break;
5119
5120 case 230:
5121#line 2177 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5122 {
5123 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5124 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00005125 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005126 ;}
5127 break;
5128
5129 case 231:
5130#line 2182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5131 {
5132 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5133 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005134 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005135 ;}
5136 break;
5137
5138 case 232:
5139#line 2187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5140 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005141 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005142 ;}
5143 break;
5144
5145 case 233:
5146#line 2196 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5147 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005148 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005149 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5150 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005151 GEN_ERROR("void typed arguments are invalid");
Chris Lattner59363a32008-02-19 04:36:25 +00005152 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5153 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5154 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005155 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005156 ;}
5157 break;
5158
5159 case 234:
5160#line 2206 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5161 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005162 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005163 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5164 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005165 GEN_ERROR("void typed arguments are invalid");
Chris Lattner59363a32008-02-19 04:36:25 +00005166 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5167 (yyval.ArgList) = new ArgListType;
5168 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005169 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005170 ;}
5171 break;
5172
5173 case 235:
5174#line 2217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5175 {
5176 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005177 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005178 ;}
5179 break;
5180
5181 case 236:
5182#line 2221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5183 {
5184 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005185 struct ArgListEntry E;
5186 E.Ty = new PATypeHolder(Type::VoidTy);
5187 E.Name = 0;
5188 E.Attrs = ParamAttr::None;
Chris Lattner59363a32008-02-19 04:36:25 +00005189 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005190 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005191 ;}
5192 break;
5193
5194 case 237:
5195#line 2230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5196 {
5197 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 struct ArgListEntry E;
5199 E.Ty = new PATypeHolder(Type::VoidTy);
5200 E.Name = 0;
5201 E.Attrs = ParamAttr::None;
Chris Lattner59363a32008-02-19 04:36:25 +00005202 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005203 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005204 ;}
5205 break;
5206
5207 case 238:
5208#line 2239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5209 {
5210 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005211 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005212 ;}
5213 break;
5214
5215 case 239:
5216#line 2245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5217 {
5218 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5219 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005220
5221 // Check the function result for abstractness if this is a define. We should
5222 // have no abstract types at this point
Chris Lattner59363a32008-02-19 04:36:25 +00005223 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5224 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005225
5226 std::vector<const Type*> ParamTypeList;
5227 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00005228 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005229 ParamAttrsWithIndex PAWI;
5230 PAWI.index = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005231 PAWI.attrs = (yyvsp[(7) - (10)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005232 Attrs.push_back(PAWI);
5233 }
Chris Lattner59363a32008-02-19 04:36:25 +00005234 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005235 unsigned index = 1;
Chris Lattner59363a32008-02-19 04:36:25 +00005236 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005237 const Type* Ty = I->Ty->get();
5238 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5239 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5240 ParamTypeList.push_back(Ty);
5241 if (Ty != Type::VoidTy)
5242 if (I->Attrs != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005243 ParamAttrsWithIndex PAWI;
5244 PAWI.index = index;
5245 PAWI.attrs = I->Attrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005246 Attrs.push_back(PAWI);
5247 }
5248 }
5249 }
5250
5251 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5252 if (isVarArg) ParamTypeList.pop_back();
5253
Duncan Sands637ec552007-11-28 17:07:01 +00005254 const ParamAttrsList *PAL = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005255 if (!Attrs.empty())
5256 PAL = ParamAttrsList::get(Attrs);
5257
Chris Lattner59363a32008-02-19 04:36:25 +00005258 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00005259 const PointerType *PFT = PointerType::getUnqual(FT);
Chris Lattner59363a32008-02-19 04:36:25 +00005260 delete (yyvsp[(2) - (10)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005261
5262 ValID ID;
5263 if (!FunctionName.empty()) {
5264 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5265 } else {
5266 ID = ValID::createGlobalID(CurModule.Values.size());
5267 }
5268
5269 Function *Fn = 0;
5270 // See if this function was forward referenced. If so, recycle the object.
5271 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5272 // Move the function to the end of the list, from whereever it was
5273 // previously inserted.
5274 Fn = cast<Function>(FWRef);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005275 assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005276 CurModule.CurrentModule->getFunctionList().remove(Fn);
5277 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5278 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5279 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005280 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005281 // The existing function doesn't have the same type. This is an overload
5282 // error.
5283 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005284 } else if (Fn->getParamAttrs() != PAL) {
5285 // The existing function doesn't have the same parameter attributes.
5286 // This is an overload error.
5287 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005288 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5289 // Neither the existing or the current function is a declaration and they
5290 // have the same name and same type. Clearly this is a redefinition.
5291 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005292 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005293 // Make sure to strip off any argument names so we can't get conflicts.
5294 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5295 AI != AE; ++AI)
5296 AI->setName("");
5297 }
5298 } else { // Not already defined?
5299 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5300 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005301 InsertValue(Fn, CurModule.Values);
5302 }
5303
5304 CurFun.FunctionStart(Fn);
5305
5306 if (CurFun.isDeclare) {
5307 // If we have declaration, always overwrite linkage. This will allow us to
5308 // correctly handle cases, when pointer to function is passed as argument to
5309 // another function.
5310 Fn->setLinkage(CurFun.Linkage);
5311 Fn->setVisibility(CurFun.Visibility);
5312 }
Chris Lattner59363a32008-02-19 04:36:25 +00005313 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005314 Fn->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00005315 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5316 if ((yyvsp[(8) - (10)].StrVal)) {
5317 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5318 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00005319 }
Chris Lattner59363a32008-02-19 04:36:25 +00005320 if ((yyvsp[(10) - (10)].StrVal)) {
5321 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5322 delete (yyvsp[(10) - (10)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005323 }
5324
5325 // Add all of the arguments we parsed to the function...
Chris Lattner59363a32008-02-19 04:36:25 +00005326 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005327 if (isVarArg) { // Nuke the last entry
Chris Lattner59363a32008-02-19 04:36:25 +00005328 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005329 "Not a varargs marker!");
Chris Lattner59363a32008-02-19 04:36:25 +00005330 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5331 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005332 }
5333 Function::arg_iterator ArgIt = Fn->arg_begin();
5334 Function::arg_iterator ArgEnd = Fn->arg_end();
5335 unsigned Idx = 1;
Chris Lattner59363a32008-02-19 04:36:25 +00005336 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5337 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005338 delete I->Ty; // Delete the typeholder...
5339 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5340 CHECK_FOR_ERROR
5341 InsertValue(ArgIt);
5342 Idx++;
5343 }
5344
Chris Lattner59363a32008-02-19 04:36:25 +00005345 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005346 }
5347 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005348;}
5349 break;
5350
5351 case 242:
5352#line 2380 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5353 {
5354 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005355
5356 // Make sure that we keep track of the linkage type even if there was a
5357 // previous "declare".
Chris Lattner59363a32008-02-19 04:36:25 +00005358 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5359 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5360;}
5361 break;
5362
5363 case 245:
5364#line 2391 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5365 {
5366 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005367 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005368;}
5369 break;
5370
5371 case 246:
5372#line 2396 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5373 {
5374 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5375 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5376 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005377 CurFun.FunctionDone();
5378 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005379 ;}
5380 break;
5381
5382 case 247:
5383#line 2408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5384 {
5385 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005386 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005387 ;}
5388 break;
5389
5390 case 248:
5391#line 2412 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5392 {
5393 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005394 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005395 ;}
5396 break;
5397
5398 case 249:
5399#line 2417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5400 { // A reference to a direct constant
5401 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005402 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005403 ;}
5404 break;
5405
5406 case 250:
5407#line 2421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5408 {
5409 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005410 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005411 ;}
5412 break;
5413
5414 case 251:
5415#line 2425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5416 { // Perhaps it's an FP constant?
5417 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005418 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005419 ;}
5420 break;
5421
5422 case 252:
5423#line 2429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5424 {
5425 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005426 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005427 ;}
5428 break;
5429
5430 case 253:
5431#line 2433 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5432 {
5433 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005434 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005435 ;}
5436 break;
5437
5438 case 254:
5439#line 2437 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5440 {
5441 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005442 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005443 ;}
5444 break;
5445
5446 case 255:
5447#line 2441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5448 {
5449 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005450 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005451 ;}
5452 break;
5453
5454 case 256:
5455#line 2445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5456 { // A vector zero constant.
5457 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005458 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005459 ;}
5460 break;
5461
5462 case 257:
5463#line 2449 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5464 { // Nonempty unsized packed vector
5465 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5466 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005467
5468 VectorType* pt = VectorType::get(ETy, NumElements);
5469 PATypeHolder* PTy = new PATypeHolder(
5470 HandleUpRefs(
5471 VectorType::get(
5472 ETy,
5473 NumElements)
5474 )
5475 );
5476
5477 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00005478 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5479 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005480 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5481 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner59363a32008-02-19 04:36:25 +00005482 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005483 }
5484
Chris Lattner59363a32008-02-19 04:36:25 +00005485 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5486 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005487 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005488 ;}
5489 break;
5490
5491 case 258:
5492#line 2474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5493 {
5494 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005495 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005496 ;}
5497 break;
5498
5499 case 259:
5500#line 2478 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5501 {
5502 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5503 delete (yyvsp[(3) - (5)].StrVal);
5504 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005505 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005506 ;}
5507 break;
5508
5509 case 260:
5510#line 2488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5511 { // Is it an integer reference...?
5512 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005513 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005514 ;}
5515 break;
5516
5517 case 261:
5518#line 2492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5519 {
5520 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005521 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005522 ;}
5523 break;
5524
5525 case 262:
5526#line 2496 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5527 { // Is it a named reference...?
5528 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5529 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005530 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005531 ;}
5532 break;
5533
5534 case 263:
5535#line 2501 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5536 { // Is it a named reference...?
5537 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5538 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005539 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005540 ;}
5541 break;
5542
5543 case 266:
5544#line 2514 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5545 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005546 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005547 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5548 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5549 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005550 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005551 ;}
5552 break;
5553
5554 case 267:
5555#line 2523 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5556 {
5557 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005558 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005559 ;}
5560 break;
5561
5562 case 268:
5563#line 2527 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5564 { // Do not allow functions with 0 basic blocks
5565 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005566 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005567 ;}
5568 break;
5569
5570 case 269:
5571#line 2536 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5572 {
5573 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005574 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005575 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5576 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5577 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005578 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005579 ;}
5580 break;
5581
5582 case 270:
5583#line 2545 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5584 {
5585 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005586 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5587 if (CI2->getParent() == 0)
Chris Lattner59363a32008-02-19 04:36:25 +00005588 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5589 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5590 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005591 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005592 ;}
5593 break;
5594
5595 case 271:
5596#line 2554 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5597 { // Empty space between instruction lists
5598 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005599 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005600 ;}
5601 break;
5602
5603 case 272:
5604#line 2558 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5605 { // Labelled (named) basic block
5606 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5607 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005608 CHECK_FOR_ERROR
5609
Chris Lattner59363a32008-02-19 04:36:25 +00005610 ;}
5611 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005612
Chris Lattner59363a32008-02-19 04:36:25 +00005613 case 273:
5614#line 2565 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5615 { // Return with a result...
5616 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5617 CHECK_FOR_ERROR
5618 ;}
5619 break;
5620
5621 case 274:
5622#line 2569 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5623 { // Return with no result...
5624 (yyval.TermInstVal) = new ReturnInst();
5625 CHECK_FOR_ERROR
5626 ;}
5627 break;
5628
5629 case 275:
5630#line 2573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5631 { // Unconditional Branch...
5632 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5633 CHECK_FOR_ERROR
5634 (yyval.TermInstVal) = new BranchInst(tmpBB);
5635 ;}
5636 break;
5637
5638 case 276:
5639#line 2578 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5640 {
5641 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5642 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5643 CHECK_FOR_ERROR
5644 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5645 CHECK_FOR_ERROR
5646 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5647 CHECK_FOR_ERROR
5648 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5649 ;}
5650 break;
5651
5652 case 277:
5653#line 2588 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5654 {
5655 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5656 CHECK_FOR_ERROR
5657 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5658 CHECK_FOR_ERROR
5659 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5660 (yyval.TermInstVal) = S;
5661
5662 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5663 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005664 for (; I != E; ++I) {
5665 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5666 S->addCase(CI, I->second);
5667 else
5668 GEN_ERROR("Switch case is constant, but not a simple integer");
5669 }
Chris Lattner59363a32008-02-19 04:36:25 +00005670 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005671 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005672 ;}
5673 break;
5674
5675 case 278:
5676#line 2607 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5677 {
5678 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005679 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005680 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005681 CHECK_FOR_ERROR
5682 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner59363a32008-02-19 04:36:25 +00005683 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005684 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005685 ;}
5686 break;
5687
5688 case 279:
5689#line 2617 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5690 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005691
5692 // Handle the short syntax
5693 const PointerType *PFTy = 0;
5694 const FunctionType *Ty = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005695 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005696 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5697 // Pull out the types of all of the arguments...
5698 std::vector<const Type*> ParamTypes;
Chris Lattner59363a32008-02-19 04:36:25 +00005699 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005700 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005701 const Type *Ty = I->Val->getType();
5702 if (Ty == Type::VoidTy)
5703 GEN_ERROR("Short call syntax cannot be used with varargs");
5704 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005705 }
Chris Lattner59363a32008-02-19 04:36:25 +00005706 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00005707 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005708 }
5709
Chris Lattner59363a32008-02-19 04:36:25 +00005710 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005711
Chris Lattner59363a32008-02-19 04:36:25 +00005712 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005713 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005714 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005715 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005716 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005717 CHECK_FOR_ERROR
5718
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005719 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00005720 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5721 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005722 Attrs.push_back(PAWI);
5723 }
5724
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005725 // Check the arguments
5726 ValueList Args;
Chris Lattner59363a32008-02-19 04:36:25 +00005727 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005728 // Make sure no arguments is a good thing!
5729 if (Ty->getNumParams() != 0)
5730 GEN_ERROR("No arguments passed to a function that "
5731 "expects arguments");
5732 } else { // Has arguments?
5733 // Loop through FunctionType's arguments and ensure they are specified
5734 // correctly!
5735 FunctionType::param_iterator I = Ty->param_begin();
5736 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner59363a32008-02-19 04:36:25 +00005737 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005738 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005739
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005740 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005741 if (ArgI->Val->getType() != *I)
5742 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5743 (*I)->getDescription() + "'");
5744 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005745 if (ArgI->Attrs != ParamAttr::None) {
5746 ParamAttrsWithIndex PAWI;
5747 PAWI.index = index;
5748 PAWI.attrs = ArgI->Attrs;
5749 Attrs.push_back(PAWI);
5750 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005751 }
5752
5753 if (Ty->isVarArg()) {
5754 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00005755 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005756 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner59363a32008-02-19 04:36:25 +00005757 if (ArgI->Attrs != ParamAttr::None) {
5758 ParamAttrsWithIndex PAWI;
5759 PAWI.index = index;
5760 PAWI.attrs = ArgI->Attrs;
5761 Attrs.push_back(PAWI);
5762 }
5763 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005764 } else if (I != E || ArgI != ArgE)
5765 GEN_ERROR("Invalid number of parameters detected");
5766 }
5767
Duncan Sands637ec552007-11-28 17:07:01 +00005768 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005769 if (!Attrs.empty())
5770 PAL = ParamAttrsList::get(Attrs);
5771
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005772 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00005773 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattner59363a32008-02-19 04:36:25 +00005774 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005775 II->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00005776 (yyval.TermInstVal) = II;
5777 delete (yyvsp[(6) - (14)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005778 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005779 ;}
5780 break;
5781
5782 case 280:
5783#line 2707 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5784 {
5785 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005786 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005787 ;}
5788 break;
5789
5790 case 281:
5791#line 2711 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5792 {
5793 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005794 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005795 ;}
5796 break;
5797
5798 case 282:
5799#line 2718 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5800 {
5801 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5802 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005803 CHECK_FOR_ERROR
5804 if (V == 0)
5805 GEN_ERROR("May only switch on a constant pool value");
5806
Chris Lattner59363a32008-02-19 04:36:25 +00005807 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005808 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005809 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5810 ;}
5811 break;
5812
5813 case 283:
5814#line 2729 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5815 {
5816 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5817 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005818 CHECK_FOR_ERROR
5819
5820 if (V == 0)
5821 GEN_ERROR("May only switch on a constant pool value");
5822
Chris Lattner59363a32008-02-19 04:36:25 +00005823 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005824 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005825 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5826 ;}
5827 break;
5828
5829 case 284:
5830#line 2742 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5831 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005832 // Is this definition named?? if so, assign the name...
Chris Lattner59363a32008-02-19 04:36:25 +00005833 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005834 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005835 InsertValue((yyvsp[(2) - (2)].InstVal));
5836 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005837 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005838 ;}
5839 break;
5840
5841 case 285:
5842#line 2752 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5843 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005844 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005845 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5846 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5847 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005848 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005849 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005850 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005851 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5852 delete (yyvsp[(1) - (6)].TypeVal);
5853 ;}
5854 break;
5855
5856 case 286:
5857#line 2763 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5858 {
5859 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5860 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005861 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005862 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005863 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005864 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5865 ;}
5866 break;
5867
5868 case 287:
5869#line 2773 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5870 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005871 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005872 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005873 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005874 // Used for call and invoke instructions
Chris Lattner59363a32008-02-19 04:36:25 +00005875 (yyval.ParamList) = new ParamList();
5876 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5877 (yyval.ParamList)->push_back(E);
5878 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005879 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005880 ;}
5881 break;
5882
5883 case 288:
5884#line 2784 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5885 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005886 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00005887 // Labels are only valid in ASMs
Chris Lattner59363a32008-02-19 04:36:25 +00005888 (yyval.ParamList) = new ParamList();
5889 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5890 (yyval.ParamList)->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005891 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005892 ;}
5893 break;
5894
5895 case 289:
5896#line 2792 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5897 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005898 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005899 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005900 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5901 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5902 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5903 (yyval.ParamList)->push_back(E);
5904 delete (yyvsp[(3) - (6)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005905 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005906 ;}
5907 break;
5908
5909 case 290:
5910#line 2802 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5911 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005912 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Chris Lattner59363a32008-02-19 04:36:25 +00005913 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5914 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5915 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00005916 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005917 ;}
5918 break;
5919
5920 case 291:
5921#line 2809 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5922 { (yyval.ParamList) = new ParamList(); ;}
5923 break;
5924
5925 case 292:
5926#line 2812 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5927 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5928 break;
5929
5930 case 293:
5931#line 2813 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5932 {
5933 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5934 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005935 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005936 ;}
5937 break;
5938
5939 case 294:
5940#line 2820 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5941 {
5942 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005943 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005944 ;}
5945 break;
5946
5947 case 295:
5948#line 2824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5949 {
5950 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005951 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005952 ;}
5953 break;
5954
5955 case 296:
5956#line 2829 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5957 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005958 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005959 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5960 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5961 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005962 GEN_ERROR(
5963 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner59363a32008-02-19 04:36:25 +00005964 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005965 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005966 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005967 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005968 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5969 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005970 GEN_ERROR("binary operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00005971 delete (yyvsp[(2) - (5)].TypeVal);
5972 ;}
5973 break;
5974
5975 case 297:
5976#line 2845 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5977 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005978 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005979 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5980 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5981 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5982 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005983 GEN_ERROR("Logical operator requires integral operands");
5984 }
Chris Lattner59363a32008-02-19 04:36:25 +00005985 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005986 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005987 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005988 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005989 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5990 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005991 GEN_ERROR("binary operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00005992 delete (yyvsp[(2) - (5)].TypeVal);
5993 ;}
5994 break;
5995
5996 case 298:
5997#line 2862 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5998 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005999 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006000 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6001 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006002 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner59363a32008-02-19 04:36:25 +00006003 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006004 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006005 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006006 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006007 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6008 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006009 GEN_ERROR("icmp operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006010 delete (yyvsp[(3) - (6)].TypeVal);
6011 ;}
6012 break;
6013
6014 case 299:
6015#line 2876 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6016 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006017 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006018 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6019 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006020 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner59363a32008-02-19 04:36:25 +00006021 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006022 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006023 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006024 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006025 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6026 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006027 GEN_ERROR("fcmp operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006028 delete (yyvsp[(3) - (6)].TypeVal);
6029 ;}
6030 break;
6031
6032 case 300:
6033#line 2890 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6034 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006035 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006036 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6037 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6038 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6039 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006040 GEN_ERROR("invalid cast opcode for cast from '" +
6041 Val->getType()->getDescription() + "' to '" +
6042 DestTy->getDescription() + "'");
Chris Lattner59363a32008-02-19 04:36:25 +00006043 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6044 delete (yyvsp[(4) - (4)].TypeVal);
6045 ;}
6046 break;
6047
6048 case 301:
6049#line 2902 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6050 {
6051 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006052 GEN_ERROR("select condition must be boolean");
Chris Lattner59363a32008-02-19 04:36:25 +00006053 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006054 GEN_ERROR("select value types should match");
Chris Lattner59363a32008-02-19 04:36:25 +00006055 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006056 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006057 ;}
6058 break;
6059
6060 case 302:
6061#line 2910 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6062 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006063 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006064 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6065 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6066 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006067 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006068 ;}
6069 break;
6070
6071 case 303:
6072#line 2917 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6073 {
6074 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006075 GEN_ERROR("Invalid extractelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006076 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006077 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006078 ;}
6079 break;
6080
6081 case 304:
6082#line 2923 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6083 {
6084 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006085 GEN_ERROR("Invalid insertelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006086 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006087 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006088 ;}
6089 break;
6090
6091 case 305:
6092#line 2929 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6093 {
6094 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006095 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006096 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006097 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006098 ;}
6099 break;
6100
6101 case 306:
6102#line 2935 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6103 {
6104 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006105 if (!Ty->isFirstClassType())
6106 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner59363a32008-02-19 04:36:25 +00006107 (yyval.InstVal) = new PHINode(Ty);
6108 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6109 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6110 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006111 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner59363a32008-02-19 04:36:25 +00006112 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6113 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006114 }
Chris Lattner59363a32008-02-19 04:36:25 +00006115 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006116 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006117 ;}
6118 break;
6119
6120 case 307:
6121#line 2951 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6122 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006123
6124 // Handle the short syntax
6125 const PointerType *PFTy = 0;
6126 const FunctionType *Ty = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00006127 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006128 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6129 // Pull out the types of all of the arguments...
6130 std::vector<const Type*> ParamTypes;
Chris Lattner59363a32008-02-19 04:36:25 +00006131 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006132 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006133 const Type *Ty = I->Val->getType();
6134 if (Ty == Type::VoidTy)
6135 GEN_ERROR("Short call syntax cannot be used with varargs");
6136 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006137 }
Chris Lattner59363a32008-02-19 04:36:25 +00006138 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00006139 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006140 }
6141
Chris Lattner59363a32008-02-19 04:36:25 +00006142 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006143 CHECK_FOR_ERROR
6144
6145 // Check for call to invalid intrinsic to avoid crashing later.
6146 if (Function *theF = dyn_cast<Function>(V)) {
6147 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6148 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6149 !theF->getIntrinsicID(true))
6150 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6151 theF->getName() + "'");
6152 }
6153
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006154 // Set up the ParamAttrs for the function
6155 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00006156 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006157 ParamAttrsWithIndex PAWI;
6158 PAWI.index = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00006159 PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006160 Attrs.push_back(PAWI);
6161 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006162 // Check the arguments
6163 ValueList Args;
Chris Lattner59363a32008-02-19 04:36:25 +00006164 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006165 // Make sure no arguments is a good thing!
6166 if (Ty->getNumParams() != 0)
6167 GEN_ERROR("No arguments passed to a function that "
6168 "expects arguments");
6169 } else { // Has arguments?
6170 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006171 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006172 FunctionType::param_iterator I = Ty->param_begin();
6173 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner59363a32008-02-19 04:36:25 +00006174 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006175 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006176
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006177 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006178 if (ArgI->Val->getType() != *I)
6179 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6180 (*I)->getDescription() + "'");
6181 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006182 if (ArgI->Attrs != ParamAttr::None) {
6183 ParamAttrsWithIndex PAWI;
6184 PAWI.index = index;
6185 PAWI.attrs = ArgI->Attrs;
6186 Attrs.push_back(PAWI);
6187 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006188 }
6189 if (Ty->isVarArg()) {
6190 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00006191 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006192 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner59363a32008-02-19 04:36:25 +00006193 if (ArgI->Attrs != ParamAttr::None) {
6194 ParamAttrsWithIndex PAWI;
6195 PAWI.index = index;
6196 PAWI.attrs = ArgI->Attrs;
6197 Attrs.push_back(PAWI);
6198 }
6199 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006200 } else if (I != E || ArgI != ArgE)
6201 GEN_ERROR("Invalid number of parameters detected");
6202 }
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006203
6204 // Finish off the ParamAttrs and check them
Duncan Sands637ec552007-11-28 17:07:01 +00006205 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006206 if (!Attrs.empty())
6207 PAL = ParamAttrsList::get(Attrs);
6208
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006209 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00006210 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner59363a32008-02-19 04:36:25 +00006211 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6212 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006213 CI->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00006214 (yyval.InstVal) = CI;
6215 delete (yyvsp[(6) - (8)].ParamList);
6216 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006217 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006218 ;}
6219 break;
6220
6221 case 308:
6222#line 3048 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6223 {
6224 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006225 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006226 ;}
6227 break;
6228
6229 case 309:
6230#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6231 {
6232 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006233 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006234 ;}
6235 break;
6236
6237 case 310:
6238#line 3057 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6239 {
6240 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006241 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006242 ;}
6243 break;
6244
6245 case 311:
6246#line 3064 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6247 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006248 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006249 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6250 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6251 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006252 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006253 ;}
6254 break;
6255
6256 case 312:
6257#line 3071 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6258 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006259 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006260 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6261 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006262 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006263 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6264 delete (yyvsp[(2) - (6)].TypeVal);
6265 ;}
6266 break;
6267
6268 case 313:
6269#line 3079 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6270 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006271 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006272 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6273 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6274 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006275 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006276 ;}
6277 break;
6278
6279 case 314:
6280#line 3086 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6281 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006282 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006283 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6284 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006285 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006286 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6287 delete (yyvsp[(2) - (6)].TypeVal);
6288 ;}
6289 break;
6290
6291 case 315:
6292#line 3094 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6293 {
6294 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006295 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner59363a32008-02-19 04:36:25 +00006296 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6297 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006298 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006299 ;}
6300 break;
6301
6302 case 316:
6303#line 3102 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6304 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006305 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006306 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6307 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006308 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006309 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6310 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006311 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006312 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6313 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006314 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006315 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6316 delete (yyvsp[(3) - (5)].TypeVal);
6317 ;}
6318 break;
6319
6320 case 317:
6321#line 3116 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6322 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006323 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006324 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6325 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006326 if (!PT)
6327 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006328 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006329 const Type *ElTy = PT->getElementType();
Chris Lattner59363a32008-02-19 04:36:25 +00006330 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6331 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006332 "' into space of type '" + ElTy->getDescription() + "'");
6333
Chris Lattner59363a32008-02-19 04:36:25 +00006334 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006335 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006336 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6337 delete (yyvsp[(5) - (7)].TypeVal);
6338 ;}
6339 break;
6340
6341 case 318:
6342#line 3133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
6343 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006344 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006345 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6346 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006347 GEN_ERROR("getelementptr insn requires pointer operand");
6348
Chris Lattner59363a32008-02-19 04:36:25 +00006349 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 +00006350 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner59363a32008-02-19 04:36:25 +00006351 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6352 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006353 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006354 (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6355 delete (yyvsp[(2) - (4)].TypeVal);
6356 delete (yyvsp[(4) - (4)].ValueList);
6357 ;}
6358 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006359
Chris Lattner59363a32008-02-19 04:36:25 +00006360
6361/* Line 1267 of yacc.c. */
6362#line 6363 "llvmAsmParser.tab.c"
6363 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00006364 }
Chris Lattner59363a32008-02-19 04:36:25 +00006365 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6366
6367 YYPOPSTACK (yylen);
6368 yylen = 0;
6369 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006370
6371 *++yyvsp = yyval;
6372
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006373
Chris Lattner59363a32008-02-19 04:36:25 +00006374 /* Now `shift' the result of the reduction. Determine what state
6375 that goes to, based on the state we popped back to and the rule
6376 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006377
6378 yyn = yyr1[yyn];
6379
Chris Lattner59363a32008-02-19 04:36:25 +00006380 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6381 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006382 yystate = yytable[yystate];
6383 else
Chris Lattner59363a32008-02-19 04:36:25 +00006384 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006385
6386 goto yynewstate;
6387
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006388
Chris Lattner59363a32008-02-19 04:36:25 +00006389/*------------------------------------.
6390| yyerrlab -- here on detecting error |
6391`------------------------------------*/
6392yyerrlab:
6393 /* If not already recovering from an error, report this error. */
6394 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006395 {
6396 ++yynerrs;
Chris Lattner59363a32008-02-19 04:36:25 +00006397#if ! YYERROR_VERBOSE
6398 yyerror (YY_("syntax error"));
6399#else
6400 {
6401 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6402 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6403 {
6404 YYSIZE_T yyalloc = 2 * yysize;
6405 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6406 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6407 if (yymsg != yymsgbuf)
6408 YYSTACK_FREE (yymsg);
6409 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6410 if (yymsg)
6411 yymsg_alloc = yyalloc;
6412 else
6413 {
6414 yymsg = yymsgbuf;
6415 yymsg_alloc = sizeof yymsgbuf;
6416 }
6417 }
Dale Johannesen3afee192007-09-07 21:07:57 +00006418
Chris Lattner59363a32008-02-19 04:36:25 +00006419 if (0 < yysize && yysize <= yymsg_alloc)
6420 {
6421 (void) yysyntax_error (yymsg, yystate, yychar);
6422 yyerror (yymsg);
6423 }
6424 else
6425 {
6426 yyerror (YY_("syntax error"));
6427 if (yysize != 0)
6428 goto yyexhaustedlab;
6429 }
6430 }
6431#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006432 }
6433
Chris Lattner59363a32008-02-19 04:36:25 +00006434
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006435
6436 if (yyerrstatus == 3)
6437 {
Chris Lattner59363a32008-02-19 04:36:25 +00006438 /* If just tried and failed to reuse look-ahead token after an
6439 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006440
Chris Lattner59363a32008-02-19 04:36:25 +00006441 if (yychar <= YYEOF)
6442 {
6443 /* Return failure if at end of input. */
6444 if (yychar == YYEOF)
6445 YYABORT;
6446 }
6447 else
6448 {
6449 yydestruct ("Error: discarding",
6450 yytoken, &yylval);
6451 yychar = YYEMPTY;
6452 }
6453 }
6454
6455 /* Else will try to reuse look-ahead token after shifting the error
6456 token. */
6457 goto yyerrlab1;
6458
6459
6460/*---------------------------------------------------.
6461| yyerrorlab -- error raised explicitly by YYERROR. |
6462`---------------------------------------------------*/
6463yyerrorlab:
6464
6465 /* Pacify compilers like GCC when the user code never invokes
6466 YYERROR and the label yyerrorlab therefore never appears in user
6467 code. */
6468 if (/*CONSTCOND*/ 0)
6469 goto yyerrorlab;
6470
6471 /* Do not reclaim the symbols of the rule which action triggered
6472 this YYERROR. */
6473 YYPOPSTACK (yylen);
6474 yylen = 0;
6475 YY_STACK_PRINT (yyss, yyssp);
6476 yystate = *yyssp;
6477 goto yyerrlab1;
6478
6479
6480/*-------------------------------------------------------------.
6481| yyerrlab1 -- common code for both syntax error and YYERROR. |
6482`-------------------------------------------------------------*/
6483yyerrlab1:
6484 yyerrstatus = 3; /* Each real token shifted decrements this. */
6485
6486 for (;;)
6487 {
6488 yyn = yypact[yystate];
6489 if (yyn != YYPACT_NINF)
6490 {
6491 yyn += YYTERROR;
6492 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6493 {
6494 yyn = yytable[yyn];
6495 if (0 < yyn)
6496 break;
6497 }
6498 }
6499
6500 /* Pop the current state because it cannot handle the error token. */
6501 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006502 YYABORT;
6503
Dale Johannesen3afee192007-09-07 21:07:57 +00006504
Chris Lattner59363a32008-02-19 04:36:25 +00006505 yydestruct ("Error: popping",
6506 yystos[yystate], yyvsp);
6507 YYPOPSTACK (1);
6508 yystate = *yyssp;
6509 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006510 }
6511
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006512 if (yyn == YYFINAL)
6513 YYACCEPT;
6514
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006515 *++yyvsp = yylval;
Chris Lattner59363a32008-02-19 04:36:25 +00006516
6517
6518 /* Shift the error token. */
6519 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006520
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006521 yystate = yyn;
6522 goto yynewstate;
6523
Scott Michel6d1aba82008-01-30 03:10:00 +00006524
Chris Lattner59363a32008-02-19 04:36:25 +00006525/*-------------------------------------.
6526| yyacceptlab -- YYACCEPT comes here. |
6527`-------------------------------------*/
6528yyacceptlab:
6529 yyresult = 0;
6530 goto yyreturn;
6531
6532/*-----------------------------------.
6533| yyabortlab -- YYABORT comes here. |
6534`-----------------------------------*/
6535yyabortlab:
6536 yyresult = 1;
6537 goto yyreturn;
6538
6539#ifndef yyoverflow
6540/*-------------------------------------------------.
6541| yyexhaustedlab -- memory exhaustion comes here. |
6542`-------------------------------------------------*/
6543yyexhaustedlab:
6544 yyerror (YY_("memory exhausted"));
6545 yyresult = 2;
6546 /* Fall through. */
Scott Michel5a6f17b2008-01-30 02:55:46 +00006547#endif
Chris Lattner59363a32008-02-19 04:36:25 +00006548
6549yyreturn:
6550 if (yychar != YYEOF && yychar != YYEMPTY)
6551 yydestruct ("Cleanup: discarding lookahead",
6552 yytoken, &yylval);
6553 /* Do not reclaim the symbols of the rule which action triggered
6554 this YYABORT or YYACCEPT. */
6555 YYPOPSTACK (yylen);
6556 YY_STACK_PRINT (yyss, yyssp);
6557 while (yyssp != yyss)
6558 {
6559 yydestruct ("Cleanup: popping",
6560 yystos[*yyssp], yyvsp);
6561 YYPOPSTACK (1);
Scott Michel6d1aba82008-01-30 03:10:00 +00006562 }
Chris Lattner59363a32008-02-19 04:36:25 +00006563#ifndef yyoverflow
6564 if (yyss != yyssa)
6565 YYSTACK_FREE (yyss);
6566#endif
6567#if YYERROR_VERBOSE
6568 if (yymsg != yymsgbuf)
6569 YYSTACK_FREE (yymsg);
6570#endif
6571 /* Make sure YYID is used. */
6572 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006573}
Chris Lattner59363a32008-02-19 04:36:25 +00006574
6575
6576#line 3150 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006577
6578
6579// common code from the two 'RunVMAsmParser' functions
6580static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006581 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006582 // Check to make sure the parser succeeded
6583 if (yyparse()) {
6584 if (ParserResult)
6585 delete ParserResult;
6586 return 0;
6587 }
6588
6589 // Emit an error if there are any unresolved types left.
6590 if (!CurModule.LateResolveTypes.empty()) {
6591 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6592 if (DID.Type == ValID::LocalName) {
6593 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6594 } else {
6595 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6596 }
6597 if (ParserResult)
6598 delete ParserResult;
6599 return 0;
6600 }
6601
6602 // Emit an error if there are any unresolved values left.
6603 if (!CurModule.LateResolveValues.empty()) {
6604 Value *V = CurModule.LateResolveValues.back();
6605 std::map<Value*, std::pair<ValID, int> >::iterator I =
6606 CurModule.PlaceHolderInfo.find(V);
6607
6608 if (I != CurModule.PlaceHolderInfo.end()) {
6609 ValID &DID = I->second.first;
6610 if (DID.Type == ValID::LocalName) {
6611 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6612 } else {
6613 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6614 }
6615 if (ParserResult)
6616 delete ParserResult;
6617 return 0;
6618 }
6619 }
6620
6621 // Check to make sure that parsing produced a result
6622 if (!ParserResult)
6623 return 0;
6624
6625 // Reset ParserResult variable while saving its value for the result.
6626 Module *Result = ParserResult;
6627 ParserResult = 0;
6628
6629 return Result;
6630}
6631
6632void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006633 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006634 // TODO: column number in exception
6635 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006636 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006637 TriggerError = 1;
6638}
6639
6640int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006641 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006642 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006643 if (yychar != YYEMPTY && yychar != 0) {
6644 errMsg += " while reading token: '";
6645 errMsg += std::string(LLLgetTokenStart(),
6646 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6647 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006648 GenerateError(errMsg);
6649 return 0;
6650}
Chris Lattner59363a32008-02-19 04:36:25 +00006651