blob: 4a1534881feda028f2733b5ece3ea99dfabdf2d7 [file] [log] [blame]
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007
Anton Korobeynikov66e28652007-11-14 09:53:48 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062#define yyparse llvmAsmparse
Anton Korobeynikov66e28652007-11-14 09:53:48 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Anton Korobeynikov66e28652007-11-14 09:53:48 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
Anton Korobeynikov66e28652007-11-14 09:53:48 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 DEPLIBS = 309,
129 CALL = 310,
130 TAIL = 311,
131 ASM_TOK = 312,
132 MODULE = 313,
133 SIDEEFFECT = 314,
134 CC_TOK = 315,
135 CCC_TOK = 316,
136 FASTCC_TOK = 317,
137 COLDCC_TOK = 318,
138 X86_STDCALLCC_TOK = 319,
139 X86_FASTCALLCC_TOK = 320,
140 DATALAYOUT = 321,
141 RET = 322,
142 BR = 323,
143 SWITCH = 324,
144 INVOKE = 325,
145 UNWIND = 326,
146 UNREACHABLE = 327,
147 ADD = 328,
148 SUB = 329,
149 MUL = 330,
150 UDIV = 331,
151 SDIV = 332,
152 FDIV = 333,
153 UREM = 334,
154 SREM = 335,
155 FREM = 336,
156 AND = 337,
157 OR = 338,
158 XOR = 339,
159 SHL = 340,
160 LSHR = 341,
161 ASHR = 342,
162 ICMP = 343,
163 FCMP = 344,
164 EQ = 345,
165 NE = 346,
166 SLT = 347,
167 SGT = 348,
168 SLE = 349,
169 SGE = 350,
170 ULT = 351,
171 UGT = 352,
172 ULE = 353,
173 UGE = 354,
174 OEQ = 355,
175 ONE = 356,
176 OLT = 357,
177 OGT = 358,
178 OLE = 359,
179 OGE = 360,
180 ORD = 361,
181 UNO = 362,
182 UEQ = 363,
183 UNE = 364,
184 MALLOC = 365,
185 ALLOCA = 366,
186 FREE = 367,
187 LOAD = 368,
188 STORE = 369,
189 GETELEMENTPTR = 370,
190 TRUNC = 371,
191 ZEXT = 372,
192 SEXT = 373,
193 FPTRUNC = 374,
194 FPEXT = 375,
195 BITCAST = 376,
196 UITOFP = 377,
197 SITOFP = 378,
198 FPTOUI = 379,
199 FPTOSI = 380,
200 INTTOPTR = 381,
201 PTRTOINT = 382,
202 PHI_TOK = 383,
203 SELECT = 384,
204 VAARG = 385,
205 EXTRACTELEMENT = 386,
206 INSERTELEMENT = 387,
207 SHUFFLEVECTOR = 388,
208 SIGNEXT = 389,
209 ZEROEXT = 390,
210 NORETURN = 391,
211 INREG = 392,
212 SRET = 393,
213 NOUNWIND = 394,
214 NOALIAS = 395,
215 BYVAL = 396,
216 NEST = 397,
217 CONST = 398,
218 PURE = 399,
219 DEFAULT = 400,
220 HIDDEN = 401,
221 PROTECTED = 402
222 };
223#endif
224/* Tokens. */
225#define ESINT64VAL 258
226#define EUINT64VAL 259
227#define ESAPINTVAL 260
228#define EUAPINTVAL 261
229#define LOCALVAL_ID 262
230#define GLOBALVAL_ID 263
231#define FPVAL 264
232#define VOID 265
233#define INTTYPE 266
234#define FLOAT 267
235#define DOUBLE 268
236#define X86_FP80 269
237#define FP128 270
238#define PPC_FP128 271
239#define LABEL 272
240#define TYPE 273
241#define LOCALVAR 274
242#define GLOBALVAR 275
243#define LABELSTR 276
244#define STRINGCONSTANT 277
245#define ATSTRINGCONSTANT 278
246#define PCTSTRINGCONSTANT 279
247#define ZEROINITIALIZER 280
248#define TRUETOK 281
249#define FALSETOK 282
250#define BEGINTOK 283
251#define ENDTOK 284
252#define DECLARE 285
253#define DEFINE 286
254#define GLOBAL 287
255#define CONSTANT 288
256#define SECTION 289
257#define ALIAS 290
258#define VOLATILE 291
259#define THREAD_LOCAL 292
260#define TO 293
261#define DOTDOTDOT 294
262#define NULL_TOK 295
263#define UNDEF 296
264#define INTERNAL 297
265#define LINKONCE 298
266#define WEAK 299
267#define APPENDING 300
268#define DLLIMPORT 301
269#define DLLEXPORT 302
270#define EXTERN_WEAK 303
271#define OPAQUE 304
272#define EXTERNAL 305
273#define TARGET 306
274#define TRIPLE 307
275#define ALIGN 308
276#define DEPLIBS 309
277#define CALL 310
278#define TAIL 311
279#define ASM_TOK 312
280#define MODULE 313
281#define SIDEEFFECT 314
282#define CC_TOK 315
283#define CCC_TOK 316
284#define FASTCC_TOK 317
285#define COLDCC_TOK 318
286#define X86_STDCALLCC_TOK 319
287#define X86_FASTCALLCC_TOK 320
288#define DATALAYOUT 321
289#define RET 322
290#define BR 323
291#define SWITCH 324
292#define INVOKE 325
293#define UNWIND 326
294#define UNREACHABLE 327
295#define ADD 328
296#define SUB 329
297#define MUL 330
298#define UDIV 331
299#define SDIV 332
300#define FDIV 333
301#define UREM 334
302#define SREM 335
303#define FREM 336
304#define AND 337
305#define OR 338
306#define XOR 339
307#define SHL 340
308#define LSHR 341
309#define ASHR 342
310#define ICMP 343
311#define FCMP 344
312#define EQ 345
313#define NE 346
314#define SLT 347
315#define SGT 348
316#define SLE 349
317#define SGE 350
318#define ULT 351
319#define UGT 352
320#define ULE 353
321#define UGE 354
322#define OEQ 355
323#define ONE 356
324#define OLT 357
325#define OGT 358
326#define OLE 359
327#define OGE 360
328#define ORD 361
329#define UNO 362
330#define UEQ 363
331#define UNE 364
332#define MALLOC 365
333#define ALLOCA 366
334#define FREE 367
335#define LOAD 368
336#define STORE 369
337#define GETELEMENTPTR 370
338#define TRUNC 371
339#define ZEXT 372
340#define SEXT 373
341#define FPTRUNC 374
342#define FPEXT 375
343#define BITCAST 376
344#define UITOFP 377
345#define SITOFP 378
346#define FPTOUI 379
347#define FPTOSI 380
348#define INTTOPTR 381
349#define PTRTOINT 382
350#define PHI_TOK 383
351#define SELECT 384
352#define VAARG 385
353#define EXTRACTELEMENT 386
354#define INSERTELEMENT 387
355#define SHUFFLEVECTOR 388
356#define SIGNEXT 389
357#define ZEROEXT 390
358#define NORETURN 391
359#define INREG 392
360#define SRET 393
361#define NOUNWIND 394
362#define NOALIAS 395
363#define BYVAL 396
364#define NEST 397
365#define CONST 398
366#define PURE 399
367#define DEFAULT 400
368#define HIDDEN 401
369#define PROTECTED 402
370
371
372
373
374/* Copy the first part of user declarations. */
Nate Begeman4a365ad2007-11-15 21:15:26 +0000375#line 14 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
377#include "ParserInternals.h"
378#include "llvm/CallingConv.h"
379#include "llvm/InlineAsm.h"
380#include "llvm/Instructions.h"
381#include "llvm/Module.h"
382#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000383#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384#include "llvm/Support/GetElementPtrTypeIterator.h"
385#include "llvm/Support/CommandLine.h"
386#include "llvm/ADT/SmallVector.h"
387#include "llvm/ADT/STLExtras.h"
388#include "llvm/Support/MathExtras.h"
389#include "llvm/Support/Streams.h"
390#include <algorithm>
391#include <list>
392#include <map>
393#include <utility>
394#ifndef NDEBUG
395#define YYDEBUG 1
396#endif
397
398// The following is a gross hack. In order to rid the libAsmParser library of
399// exceptions, we have to have a way of getting the yyparse function to go into
400// an error situation. So, whenever we want an error to occur, the GenerateError
401// function (see bottom of file) sets TriggerError. Then, at the end of each
402// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
403// (a goto) to put YACC in error state. Furthermore, several calls to
404// GenerateError are made from inside productions and they must simulate the
405// previous exception behavior by exiting the production immediately. We have
406// replaced these with the GEN_ERROR macro which calls GeneratError and then
407// immediately invokes YYERROR. This would be so much cleaner if it was a
408// recursive descent parser.
409static bool TriggerError = false;
410#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
411#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
412
413int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
414int yylex(); // declaration" of xxx warnings.
415int yyparse();
416
417namespace llvm {
418 std::string CurFilename;
419#if YYDEBUG
420static cl::opt<bool>
421Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
422 cl::Hidden, cl::init(false));
423#endif
424}
425using namespace llvm;
426
427static Module *ParserResult;
428
429// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
430// relating to upreferences in the input stream.
431//
432//#define DEBUG_UPREFS 1
433#ifdef DEBUG_UPREFS
434#define UR_OUT(X) cerr << X
435#else
436#define UR_OUT(X)
437#endif
438
439#define YYERROR_VERBOSE 1
440
441static GlobalVariable *CurGV;
442
443
444// This contains info used when building the body of a function. It is
445// destroyed when the function is completed.
446//
447typedef std::vector<Value *> ValueList; // Numbered defs
448
449static void
450ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
451
452static struct PerModuleInfo {
453 Module *CurrentModule;
454 ValueList Values; // Module level numbered definitions
455 ValueList LateResolveValues;
456 std::vector<PATypeHolder> Types;
457 std::map<ValID, PATypeHolder> LateResolveTypes;
458
459 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
460 /// how they were referenced and on which line of the input they came from so
461 /// that we can resolve them later and print error messages as appropriate.
462 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
463
464 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
465 // references to global values. Global values may be referenced before they
466 // are defined, and if so, the temporary object that they represent is held
467 // here. This is used for forward references of GlobalValues.
468 //
469 typedef std::map<std::pair<const PointerType *,
470 ValID>, GlobalValue*> GlobalRefsType;
471 GlobalRefsType GlobalRefs;
472
473 void ModuleDone() {
474 // If we could not resolve some functions at function compilation time
475 // (calls to functions before they are defined), resolve them now... Types
476 // are resolved when the constant pool has been completely parsed.
477 //
478 ResolveDefinitions(LateResolveValues);
479 if (TriggerError)
480 return;
481
482 // Check to make sure that all global value forward references have been
483 // resolved!
484 //
485 if (!GlobalRefs.empty()) {
486 std::string UndefinedReferences = "Unresolved global references exist:\n";
487
488 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
489 I != E; ++I) {
490 UndefinedReferences += " " + I->first.first->getDescription() + " " +
491 I->first.second.getName() + "\n";
492 }
493 GenerateError(UndefinedReferences);
494 return;
495 }
496
Chandler Carruth563d4a42007-08-04 01:56:21 +0000497 // Look for intrinsic functions and CallInst that need to be upgraded
498 for (Module::iterator FI = CurrentModule->begin(),
499 FE = CurrentModule->end(); FI != FE; )
500 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
501
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 Values.clear(); // Clear out function local definitions
503 Types.clear();
504 CurrentModule = 0;
505 }
506
507 // GetForwardRefForGlobal - Check to see if there is a forward reference
508 // for this global. If so, remove it from the GlobalRefs map and return it.
509 // If not, just return null.
510 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
511 // Check to see if there is a forward reference to this global variable...
512 // if there is, eliminate it and patch the reference to use the new def'n.
513 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
514 GlobalValue *Ret = 0;
515 if (I != GlobalRefs.end()) {
516 Ret = I->second;
517 GlobalRefs.erase(I);
518 }
519 return Ret;
520 }
521
522 bool TypeIsUnresolved(PATypeHolder* PATy) {
523 // If it isn't abstract, its resolved
524 const Type* Ty = PATy->get();
525 if (!Ty->isAbstract())
526 return false;
527 // Traverse the type looking for abstract types. If it isn't abstract then
528 // we don't need to traverse that leg of the type.
529 std::vector<const Type*> WorkList, SeenList;
530 WorkList.push_back(Ty);
531 while (!WorkList.empty()) {
532 const Type* Ty = WorkList.back();
533 SeenList.push_back(Ty);
534 WorkList.pop_back();
535 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
536 // Check to see if this is an unresolved type
537 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
538 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
539 for ( ; I != E; ++I) {
540 if (I->second.get() == OpTy)
541 return true;
542 }
543 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
544 const Type* TheTy = SeqTy->getElementType();
545 if (TheTy->isAbstract() && TheTy != Ty) {
546 std::vector<const Type*>::iterator I = SeenList.begin(),
547 E = SeenList.end();
548 for ( ; I != E; ++I)
549 if (*I == TheTy)
550 break;
551 if (I == E)
552 WorkList.push_back(TheTy);
553 }
554 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
555 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
556 const Type* TheTy = StrTy->getElementType(i);
557 if (TheTy->isAbstract() && TheTy != Ty) {
558 std::vector<const Type*>::iterator I = SeenList.begin(),
559 E = SeenList.end();
560 for ( ; I != E; ++I)
561 if (*I == TheTy)
562 break;
563 if (I == E)
564 WorkList.push_back(TheTy);
565 }
566 }
567 }
568 }
569 return false;
570 }
571} CurModule;
572
573static struct PerFunctionInfo {
574 Function *CurrentFunction; // Pointer to current function being created
575
576 ValueList Values; // Keep track of #'d definitions
577 unsigned NextValNum;
578 ValueList LateResolveValues;
579 bool isDeclare; // Is this function a forward declararation?
580 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
581 GlobalValue::VisibilityTypes Visibility;
582
583 /// BBForwardRefs - When we see forward references to basic blocks, keep
584 /// track of them here.
585 std::map<ValID, BasicBlock*> BBForwardRefs;
586
587 inline PerFunctionInfo() {
588 CurrentFunction = 0;
589 isDeclare = false;
590 Linkage = GlobalValue::ExternalLinkage;
591 Visibility = GlobalValue::DefaultVisibility;
592 }
593
594 inline void FunctionStart(Function *M) {
595 CurrentFunction = M;
596 NextValNum = 0;
597 }
598
599 void FunctionDone() {
600 // Any forward referenced blocks left?
601 if (!BBForwardRefs.empty()) {
602 GenerateError("Undefined reference to label " +
603 BBForwardRefs.begin()->second->getName());
604 return;
605 }
606
607 // Resolve all forward references now.
608 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
609
610 Values.clear(); // Clear out function local definitions
611 BBForwardRefs.clear();
612 CurrentFunction = 0;
613 isDeclare = false;
614 Linkage = GlobalValue::ExternalLinkage;
615 Visibility = GlobalValue::DefaultVisibility;
616 }
617} CurFun; // Info for the current function...
618
619static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
620
621
622//===----------------------------------------------------------------------===//
623// Code to handle definitions of all the types
624//===----------------------------------------------------------------------===//
625
626static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
627 // Things that have names or are void typed don't get slot numbers
628 if (V->hasName() || (V->getType() == Type::VoidTy))
629 return;
630
631 // In the case of function values, we have to allow for the forward reference
632 // of basic blocks, which are included in the numbering. Consequently, we keep
633 // track of the next insertion location with NextValNum. When a BB gets
634 // inserted, it could change the size of the CurFun.Values vector.
635 if (&ValueTab == &CurFun.Values) {
636 if (ValueTab.size() <= CurFun.NextValNum)
637 ValueTab.resize(CurFun.NextValNum+1);
638 ValueTab[CurFun.NextValNum++] = V;
639 return;
640 }
641 // For all other lists, its okay to just tack it on the back of the vector.
642 ValueTab.push_back(V);
643}
644
645static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
646 switch (D.Type) {
647 case ValID::LocalID: // Is it a numbered definition?
648 // Module constants occupy the lowest numbered slots...
649 if (D.Num < CurModule.Types.size())
650 return CurModule.Types[D.Num];
651 break;
652 case ValID::LocalName: // Is it a named definition?
653 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
654 D.destroy(); // Free old strdup'd memory...
655 return N;
656 }
657 break;
658 default:
659 GenerateError("Internal parser error: Invalid symbol type reference");
660 return 0;
661 }
662
663 // If we reached here, we referenced either a symbol that we don't know about
664 // or an id number that hasn't been read yet. We may be referencing something
665 // forward, so just create an entry to be resolved later and get to it...
666 //
667 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
668
669
670 if (inFunctionScope()) {
671 if (D.Type == ValID::LocalName) {
672 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
673 return 0;
674 } else {
675 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
676 return 0;
677 }
678 }
679
680 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
681 if (I != CurModule.LateResolveTypes.end())
682 return I->second;
683
684 Type *Typ = OpaqueType::get();
685 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
686 return Typ;
687 }
688
689// getExistingVal - Look up the value specified by the provided type and
690// the provided ValID. If the value exists and has already been defined, return
691// it. Otherwise return null.
692//
693static Value *getExistingVal(const Type *Ty, const ValID &D) {
694 if (isa<FunctionType>(Ty)) {
695 GenerateError("Functions are not values and "
696 "must be referenced as pointers");
697 return 0;
698 }
699
700 switch (D.Type) {
701 case ValID::LocalID: { // Is it a numbered definition?
702 // Check that the number is within bounds.
703 if (D.Num >= CurFun.Values.size())
704 return 0;
705 Value *Result = CurFun.Values[D.Num];
706 if (Ty != Result->getType()) {
707 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
708 Result->getType()->getDescription() + "' does not match "
709 "expected type, '" + Ty->getDescription() + "'");
710 return 0;
711 }
712 return Result;
713 }
714 case ValID::GlobalID: { // Is it a numbered definition?
715 if (D.Num >= CurModule.Values.size())
716 return 0;
717 Value *Result = CurModule.Values[D.Num];
718 if (Ty != Result->getType()) {
719 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
720 Result->getType()->getDescription() + "' does not match "
721 "expected type, '" + Ty->getDescription() + "'");
722 return 0;
723 }
724 return Result;
725 }
726
727 case ValID::LocalName: { // Is it a named definition?
728 if (!inFunctionScope())
729 return 0;
730 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
731 Value *N = SymTab.lookup(D.getName());
732 if (N == 0)
733 return 0;
734 if (N->getType() != Ty)
735 return 0;
736
737 D.destroy(); // Free old strdup'd memory...
738 return N;
739 }
740 case ValID::GlobalName: { // Is it a named definition?
741 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
742 Value *N = SymTab.lookup(D.getName());
743 if (N == 0)
744 return 0;
745 if (N->getType() != Ty)
746 return 0;
747
748 D.destroy(); // Free old strdup'd memory...
749 return N;
750 }
751
752 // Check to make sure that "Ty" is an integral type, and that our
753 // value will fit into the specified type...
754 case ValID::ConstSIntVal: // Is it a constant pool reference??
755 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
756 GenerateError("Signed integral constant '" +
757 itostr(D.ConstPool64) + "' is invalid for type '" +
758 Ty->getDescription() + "'");
759 return 0;
760 }
761 return ConstantInt::get(Ty, D.ConstPool64, true);
762
763 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
764 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
765 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
766 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
767 "' is invalid or out of range");
768 return 0;
769 } else { // This is really a signed reference. Transmogrify.
770 return ConstantInt::get(Ty, D.ConstPool64, true);
771 }
772 } else {
773 return ConstantInt::get(Ty, D.UConstPool64);
774 }
775
776 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Dale Johannesen3afee192007-09-07 21:07:57 +0000777 if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 GenerateError("FP constant invalid for type");
779 return 0;
780 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000781 // Lexer has no type info, so builds all float and double FP constants
782 // as double. Fix this here. Long double does not need this.
783 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
784 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000785 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
786 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787
788 case ValID::ConstNullVal: // Is it a null value?
789 if (!isa<PointerType>(Ty)) {
790 GenerateError("Cannot create a a non pointer null");
791 return 0;
792 }
793 return ConstantPointerNull::get(cast<PointerType>(Ty));
794
795 case ValID::ConstUndefVal: // Is it an undef value?
796 return UndefValue::get(Ty);
797
798 case ValID::ConstZeroVal: // Is it a zero value?
799 return Constant::getNullValue(Ty);
800
801 case ValID::ConstantVal: // Fully resolved constant?
802 if (D.ConstantValue->getType() != Ty) {
803 GenerateError("Constant expression type different from required type");
804 return 0;
805 }
806 return D.ConstantValue;
807
808 case ValID::InlineAsmVal: { // Inline asm expression
809 const PointerType *PTy = dyn_cast<PointerType>(Ty);
810 const FunctionType *FTy =
811 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
812 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
813 GenerateError("Invalid type for asm constraint string");
814 return 0;
815 }
816 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
817 D.IAD->HasSideEffects);
818 D.destroy(); // Free InlineAsmDescriptor.
819 return IA;
820 }
821 default:
822 assert(0 && "Unhandled case!");
823 return 0;
824 } // End of switch
825
826 assert(0 && "Unhandled case!");
827 return 0;
828}
829
830// getVal - This function is identical to getExistingVal, except that if a
831// value is not already defined, it "improvises" by creating a placeholder var
832// that looks and acts just like the requested variable. When the value is
833// defined later, all uses of the placeholder variable are replaced with the
834// real thing.
835//
836static Value *getVal(const Type *Ty, const ValID &ID) {
837 if (Ty == Type::LabelTy) {
838 GenerateError("Cannot use a basic block here");
839 return 0;
840 }
841
842 // See if the value has already been defined.
843 Value *V = getExistingVal(Ty, ID);
844 if (V) return V;
845 if (TriggerError) return 0;
846
847 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
848 GenerateError("Invalid use of a composite type");
849 return 0;
850 }
851
852 // If we reached here, we referenced either a symbol that we don't know about
853 // or an id number that hasn't been read yet. We may be referencing something
854 // forward, so just create an entry to be resolved later and get to it...
855 //
856 switch (ID.Type) {
857 case ValID::GlobalName:
858 case ValID::GlobalID: {
859 const PointerType *PTy = dyn_cast<PointerType>(Ty);
860 if (!PTy) {
861 GenerateError("Invalid type for reference to global" );
862 return 0;
863 }
864 const Type* ElTy = PTy->getElementType();
865 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
866 V = new Function(FTy, GlobalValue::ExternalLinkage);
867 else
868 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
869 break;
870 }
871 default:
872 V = new Argument(Ty);
873 }
874
875 // Remember where this forward reference came from. FIXME, shouldn't we try
876 // to recycle these things??
877 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
878 llvmAsmlineno)));
879
880 if (inFunctionScope())
881 InsertValue(V, CurFun.LateResolveValues);
882 else
883 InsertValue(V, CurModule.LateResolveValues);
884 return V;
885}
886
887/// defineBBVal - This is a definition of a new basic block with the specified
888/// identifier which must be the same as CurFun.NextValNum, if its numeric.
889static BasicBlock *defineBBVal(const ValID &ID) {
890 assert(inFunctionScope() && "Can't get basic block at global scope!");
891
892 BasicBlock *BB = 0;
893
894 // First, see if this was forward referenced
895
896 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
897 if (BBI != CurFun.BBForwardRefs.end()) {
898 BB = BBI->second;
899 // The forward declaration could have been inserted anywhere in the
900 // function: insert it into the correct place now.
901 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
902 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
903
904 // We're about to erase the entry, save the key so we can clean it up.
905 ValID Tmp = BBI->first;
906
907 // Erase the forward ref from the map as its no longer "forward"
908 CurFun.BBForwardRefs.erase(ID);
909
910 // The key has been removed from the map but so we don't want to leave
911 // strdup'd memory around so destroy it too.
912 Tmp.destroy();
913
914 // If its a numbered definition, bump the number and set the BB value.
915 if (ID.Type == ValID::LocalID) {
916 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
917 InsertValue(BB);
918 }
919
920 ID.destroy();
921 return BB;
922 }
923
924 // We haven't seen this BB before and its first mention is a definition.
925 // Just create it and return it.
926 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
927 BB = new BasicBlock(Name, CurFun.CurrentFunction);
928 if (ID.Type == ValID::LocalID) {
929 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
930 InsertValue(BB);
931 }
932
933 ID.destroy(); // Free strdup'd memory
934 return BB;
935}
936
937/// getBBVal - get an existing BB value or create a forward reference for it.
938///
939static BasicBlock *getBBVal(const ValID &ID) {
940 assert(inFunctionScope() && "Can't get basic block at global scope!");
941
942 BasicBlock *BB = 0;
943
944 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
945 if (BBI != CurFun.BBForwardRefs.end()) {
946 BB = BBI->second;
947 } if (ID.Type == ValID::LocalName) {
948 std::string Name = ID.getName();
949 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
950 if (N)
951 if (N->getType()->getTypeID() == Type::LabelTyID)
952 BB = cast<BasicBlock>(N);
953 else
954 GenerateError("Reference to label '" + Name + "' is actually of type '"+
955 N->getType()->getDescription() + "'");
956 } else if (ID.Type == ValID::LocalID) {
957 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
958 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
959 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
960 else
961 GenerateError("Reference to label '%" + utostr(ID.Num) +
962 "' is actually of type '"+
963 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
964 }
965 } else {
966 GenerateError("Illegal label reference " + ID.getName());
967 return 0;
968 }
969
970 // If its already been defined, return it now.
971 if (BB) {
972 ID.destroy(); // Free strdup'd memory.
973 return BB;
974 }
975
976 // Otherwise, this block has not been seen before, create it.
977 std::string Name;
978 if (ID.Type == ValID::LocalName)
979 Name = ID.getName();
980 BB = new BasicBlock(Name, CurFun.CurrentFunction);
981
982 // Insert it in the forward refs map.
983 CurFun.BBForwardRefs[ID] = BB;
984
985 return BB;
986}
987
988
989//===----------------------------------------------------------------------===//
990// Code to handle forward references in instructions
991//===----------------------------------------------------------------------===//
992//
993// This code handles the late binding needed with statements that reference
994// values not defined yet... for example, a forward branch, or the PHI node for
995// a loop body.
996//
997// This keeps a table (CurFun.LateResolveValues) of all such forward references
998// and back patchs after we are done.
999//
1000
1001// ResolveDefinitions - If we could not resolve some defs at parsing
1002// time (forward branches, phi functions for loops, etc...) resolve the
1003// defs now...
1004//
1005static void
1006ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1007 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1008 while (!LateResolvers.empty()) {
1009 Value *V = LateResolvers.back();
1010 LateResolvers.pop_back();
1011
1012 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1013 CurModule.PlaceHolderInfo.find(V);
1014 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1015
1016 ValID &DID = PHI->second.first;
1017
1018 Value *TheRealValue = getExistingVal(V->getType(), DID);
1019 if (TriggerError)
1020 return;
1021 if (TheRealValue) {
1022 V->replaceAllUsesWith(TheRealValue);
1023 delete V;
1024 CurModule.PlaceHolderInfo.erase(PHI);
1025 } else if (FutureLateResolvers) {
1026 // Functions have their unresolved items forwarded to the module late
1027 // resolver table
1028 InsertValue(V, *FutureLateResolvers);
1029 } else {
1030 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1031 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1032 "' of type '" + V->getType()->getDescription() + "'",
1033 PHI->second.second);
1034 return;
1035 } else {
1036 GenerateError("Reference to an invalid definition: #" +
1037 itostr(DID.Num) + " of type '" +
1038 V->getType()->getDescription() + "'",
1039 PHI->second.second);
1040 return;
1041 }
1042 }
1043 }
1044 LateResolvers.clear();
1045}
1046
1047// ResolveTypeTo - A brand new type was just declared. This means that (if
1048// name is not null) things referencing Name can be resolved. Otherwise, things
1049// refering to the number can be resolved. Do this now.
1050//
1051static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1052 ValID D;
1053 if (Name)
1054 D = ValID::createLocalName(*Name);
1055 else
1056 D = ValID::createLocalID(CurModule.Types.size());
1057
1058 std::map<ValID, PATypeHolder>::iterator I =
1059 CurModule.LateResolveTypes.find(D);
1060 if (I != CurModule.LateResolveTypes.end()) {
1061 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1062 CurModule.LateResolveTypes.erase(I);
1063 }
1064}
1065
1066// setValueName - Set the specified value to the name given. The name may be
1067// null potentially, in which case this is a noop. The string passed in is
1068// assumed to be a malloc'd string buffer, and is free'd by this function.
1069//
1070static void setValueName(Value *V, std::string *NameStr) {
1071 if (!NameStr) return;
1072 std::string Name(*NameStr); // Copy string
1073 delete NameStr; // Free old string
1074
1075 if (V->getType() == Type::VoidTy) {
1076 GenerateError("Can't assign name '" + Name+"' to value with void type");
1077 return;
1078 }
1079
1080 assert(inFunctionScope() && "Must be in function scope!");
1081 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1082 if (ST.lookup(Name)) {
1083 GenerateError("Redefinition of value '" + Name + "' of type '" +
1084 V->getType()->getDescription() + "'");
1085 return;
1086 }
1087
1088 // Set the name.
1089 V->setName(Name);
1090}
1091
1092/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1093/// this is a declaration, otherwise it is a definition.
1094static GlobalVariable *
1095ParseGlobalVariable(std::string *NameStr,
1096 GlobalValue::LinkageTypes Linkage,
1097 GlobalValue::VisibilityTypes Visibility,
1098 bool isConstantGlobal, const Type *Ty,
1099 Constant *Initializer, bool IsThreadLocal) {
1100 if (isa<FunctionType>(Ty)) {
1101 GenerateError("Cannot declare global vars of function type");
1102 return 0;
1103 }
1104
1105 const PointerType *PTy = PointerType::get(Ty);
1106
1107 std::string Name;
1108 if (NameStr) {
1109 Name = *NameStr; // Copy string
1110 delete NameStr; // Free old string
1111 }
1112
1113 // See if this global value was forward referenced. If so, recycle the
1114 // object.
1115 ValID ID;
1116 if (!Name.empty()) {
1117 ID = ValID::createGlobalName(Name);
1118 } else {
1119 ID = ValID::createGlobalID(CurModule.Values.size());
1120 }
1121
1122 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1123 // Move the global to the end of the list, from whereever it was
1124 // previously inserted.
1125 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1126 CurModule.CurrentModule->getGlobalList().remove(GV);
1127 CurModule.CurrentModule->getGlobalList().push_back(GV);
1128 GV->setInitializer(Initializer);
1129 GV->setLinkage(Linkage);
1130 GV->setVisibility(Visibility);
1131 GV->setConstant(isConstantGlobal);
1132 GV->setThreadLocal(IsThreadLocal);
1133 InsertValue(GV, CurModule.Values);
1134 return GV;
1135 }
1136
1137 // If this global has a name
1138 if (!Name.empty()) {
1139 // if the global we're parsing has an initializer (is a definition) and
1140 // has external linkage.
1141 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1142 // If there is already a global with external linkage with this name
1143 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1144 // If we allow this GVar to get created, it will be renamed in the
1145 // symbol table because it conflicts with an existing GVar. We can't
1146 // allow redefinition of GVars whose linking indicates that their name
1147 // must stay the same. Issue the error.
1148 GenerateError("Redefinition of global variable named '" + Name +
1149 "' of type '" + Ty->getDescription() + "'");
1150 return 0;
1151 }
1152 }
1153
1154 // Otherwise there is no existing GV to use, create one now.
1155 GlobalVariable *GV =
1156 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1157 CurModule.CurrentModule, IsThreadLocal);
1158 GV->setVisibility(Visibility);
1159 InsertValue(GV, CurModule.Values);
1160 return GV;
1161}
1162
1163// setTypeName - Set the specified type to the name given. The name may be
1164// null potentially, in which case this is a noop. The string passed in is
1165// assumed to be a malloc'd string buffer, and is freed by this function.
1166//
1167// This function returns true if the type has already been defined, but is
1168// allowed to be redefined in the specified context. If the name is a new name
1169// for the type plane, it is inserted and false is returned.
1170static bool setTypeName(const Type *T, std::string *NameStr) {
1171 assert(!inFunctionScope() && "Can't give types function-local names!");
1172 if (NameStr == 0) return false;
1173
1174 std::string Name(*NameStr); // Copy string
1175 delete NameStr; // Free old string
1176
1177 // We don't allow assigning names to void type
1178 if (T == Type::VoidTy) {
1179 GenerateError("Can't assign name '" + Name + "' to the void type");
1180 return false;
1181 }
1182
1183 // Set the type name, checking for conflicts as we do so.
1184 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1185
1186 if (AlreadyExists) { // Inserting a name that is already defined???
1187 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1188 assert(Existing && "Conflict but no matching type?!");
1189
1190 // There is only one case where this is allowed: when we are refining an
1191 // opaque type. In this case, Existing will be an opaque type.
1192 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1193 // We ARE replacing an opaque type!
1194 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1195 return true;
1196 }
1197
1198 // Otherwise, this is an attempt to redefine a type. That's okay if
1199 // the redefinition is identical to the original. This will be so if
1200 // Existing and T point to the same Type object. In this one case we
1201 // allow the equivalent redefinition.
1202 if (Existing == T) return true; // Yes, it's equal.
1203
1204 // Any other kind of (non-equivalent) redefinition is an error.
1205 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1206 T->getDescription() + "'");
1207 }
1208
1209 return false;
1210}
1211
1212//===----------------------------------------------------------------------===//
1213// Code for handling upreferences in type names...
1214//
1215
1216// TypeContains - Returns true if Ty directly contains E in it.
1217//
1218static bool TypeContains(const Type *Ty, const Type *E) {
1219 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1220 E) != Ty->subtype_end();
1221}
1222
1223namespace {
1224 struct UpRefRecord {
1225 // NestingLevel - The number of nesting levels that need to be popped before
1226 // this type is resolved.
1227 unsigned NestingLevel;
1228
1229 // LastContainedTy - This is the type at the current binding level for the
1230 // type. Every time we reduce the nesting level, this gets updated.
1231 const Type *LastContainedTy;
1232
1233 // UpRefTy - This is the actual opaque type that the upreference is
1234 // represented with.
1235 OpaqueType *UpRefTy;
1236
1237 UpRefRecord(unsigned NL, OpaqueType *URTy)
1238 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1239 };
1240}
1241
1242// UpRefs - A list of the outstanding upreferences that need to be resolved.
1243static std::vector<UpRefRecord> UpRefs;
1244
1245/// HandleUpRefs - Every time we finish a new layer of types, this function is
1246/// called. It loops through the UpRefs vector, which is a list of the
1247/// currently active types. For each type, if the up reference is contained in
1248/// the newly completed type, we decrement the level count. When the level
1249/// count reaches zero, the upreferenced type is the type that is passed in:
1250/// thus we can complete the cycle.
1251///
1252static PATypeHolder HandleUpRefs(const Type *ty) {
1253 // If Ty isn't abstract, or if there are no up-references in it, then there is
1254 // nothing to resolve here.
1255 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1256
1257 PATypeHolder Ty(ty);
1258 UR_OUT("Type '" << Ty->getDescription() <<
1259 "' newly formed. Resolving upreferences.\n" <<
1260 UpRefs.size() << " upreferences active!\n");
1261
1262 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1263 // to zero), we resolve them all together before we resolve them to Ty. At
1264 // the end of the loop, if there is anything to resolve to Ty, it will be in
1265 // this variable.
1266 OpaqueType *TypeToResolve = 0;
1267
1268 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1269 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1270 << UpRefs[i].second->getDescription() << ") = "
1271 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1272 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1273 // Decrement level of upreference
1274 unsigned Level = --UpRefs[i].NestingLevel;
1275 UpRefs[i].LastContainedTy = Ty;
1276 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1277 if (Level == 0) { // Upreference should be resolved!
1278 if (!TypeToResolve) {
1279 TypeToResolve = UpRefs[i].UpRefTy;
1280 } else {
1281 UR_OUT(" * Resolving upreference for "
1282 << UpRefs[i].second->getDescription() << "\n";
1283 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1284 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1285 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1286 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1287 }
1288 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1289 --i; // Do not skip the next element...
1290 }
1291 }
1292 }
1293
1294 if (TypeToResolve) {
1295 UR_OUT(" * Resolving upreference for "
1296 << UpRefs[i].second->getDescription() << "\n";
1297 std::string OldName = TypeToResolve->getDescription());
1298 TypeToResolve->refineAbstractTypeTo(Ty);
1299 }
1300
1301 return Ty;
1302}
1303
1304//===----------------------------------------------------------------------===//
1305// RunVMAsmParser - Define an interface to this parser
1306//===----------------------------------------------------------------------===//
1307//
1308static Module* RunParser(Module * M);
1309
1310Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1311 set_scan_file(F);
1312
1313 CurFilename = Filename;
1314 return RunParser(new Module(CurFilename));
1315}
1316
1317Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1318 set_scan_string(AsmString);
1319
1320 CurFilename = "from_memory";
1321 if (M == NULL) {
1322 return RunParser(new Module (CurFilename));
1323 } else {
1324 return RunParser(M);
1325 }
1326}
1327
1328
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001329
1330/* Enabling traces. */
1331#ifndef YYDEBUG
1332# define YYDEBUG 0
1333#endif
1334
1335/* Enabling verbose error messages. */
1336#ifdef YYERROR_VERBOSE
1337# undef YYERROR_VERBOSE
1338# define YYERROR_VERBOSE 1
1339#else
1340# define YYERROR_VERBOSE 0
1341#endif
1342
1343/* Enabling the token table. */
1344#ifndef YYTOKEN_TABLE
1345# define YYTOKEN_TABLE 0
1346#endif
1347
1348#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1349typedef union YYSTYPE
Nate Begeman4a365ad2007-11-15 21:15:26 +00001350#line 968 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001351{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 llvm::Module *ModuleVal;
1353 llvm::Function *FunctionVal;
1354 llvm::BasicBlock *BasicBlockVal;
1355 llvm::TerminatorInst *TermInstVal;
1356 llvm::Instruction *InstVal;
1357 llvm::Constant *ConstVal;
1358
1359 const llvm::Type *PrimType;
1360 std::list<llvm::PATypeHolder> *TypeList;
1361 llvm::PATypeHolder *TypeVal;
1362 llvm::Value *ValueVal;
1363 std::vector<llvm::Value*> *ValueList;
1364 llvm::ArgListType *ArgList;
1365 llvm::TypeWithAttrs TypeWithAttrs;
1366 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001367 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368
1369 // Represent the RHS of PHI node
1370 std::list<std::pair<llvm::Value*,
1371 llvm::BasicBlock*> > *PHIList;
1372 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1373 std::vector<llvm::Constant*> *ConstVector;
1374
1375 llvm::GlobalValue::LinkageTypes Linkage;
1376 llvm::GlobalValue::VisibilityTypes Visibility;
1377 uint16_t ParamAttrs;
1378 llvm::APInt *APIntVal;
1379 int64_t SInt64Val;
1380 uint64_t UInt64Val;
1381 int SIntVal;
1382 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001383 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 bool BoolVal;
1385
1386 std::string *StrVal; // This memory must be deleted
1387 llvm::ValID ValIDVal;
1388
1389 llvm::Instruction::BinaryOps BinaryOpVal;
1390 llvm::Instruction::TermOps TermOpVal;
1391 llvm::Instruction::MemoryOps MemOpVal;
1392 llvm::Instruction::CastOps CastOpVal;
1393 llvm::Instruction::OtherOps OtherOpVal;
1394 llvm::ICmpInst::Predicate IPredicate;
1395 llvm::FCmpInst::Predicate FPredicate;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001396}
Nate Begeman4a365ad2007-11-15 21:15:26 +00001397/* Line 193 of yacc.c. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001398#line 1399 "llvmAsmParser.tab.c"
1399 YYSTYPE;
1400# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1401# define YYSTYPE_IS_DECLARED 1
1402# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403#endif
1404
1405
1406
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001407/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001410/* Line 216 of yacc.c. */
1411#line 1412 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001412
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001413#ifdef short
1414# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415#endif
1416
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001417#ifdef YYTYPE_UINT8
1418typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001420typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421#endif
1422
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001423#ifdef YYTYPE_INT8
1424typedef YYTYPE_INT8 yytype_int8;
1425#elif (defined __STDC__ || defined __C99__FUNC__ \
1426 || defined __cplusplus || defined _MSC_VER)
1427typedef signed char yytype_int8;
1428#else
1429typedef short int yytype_int8;
1430#endif
1431
1432#ifdef YYTYPE_UINT16
1433typedef YYTYPE_UINT16 yytype_uint16;
1434#else
1435typedef unsigned short int yytype_uint16;
1436#endif
1437
1438#ifdef YYTYPE_INT16
1439typedef YYTYPE_INT16 yytype_int16;
1440#else
1441typedef short int yytype_int16;
1442#endif
1443
1444#ifndef YYSIZE_T
1445# ifdef __SIZE_TYPE__
1446# define YYSIZE_T __SIZE_TYPE__
1447# elif defined size_t
1448# define YYSIZE_T size_t
1449# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1450 || defined __cplusplus || defined _MSC_VER)
1451# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1452# define YYSIZE_T size_t
1453# else
1454# define YYSIZE_T unsigned int
1455# endif
1456#endif
1457
1458#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1459
1460#ifndef YY_
Nate Begeman4a365ad2007-11-15 21:15:26 +00001461# if defined YYENABLE_NLS && YYENABLE_NLS
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001462# if ENABLE_NLS
1463# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1464# define YY_(msgid) dgettext ("bison-runtime", msgid)
1465# endif
1466# endif
1467# ifndef YY_
1468# define YY_(msgid) msgid
1469# endif
1470#endif
1471
1472/* Suppress unused-variable warnings by "using" E. */
1473#if ! defined lint || defined __GNUC__
1474# define YYUSE(e) ((void) (e))
1475#else
1476# define YYUSE(e) /* empty */
1477#endif
1478
1479/* Identity function, used to suppress warnings about constant conditions. */
1480#ifndef lint
1481# define YYID(n) (n)
1482#else
1483#if (defined __STDC__ || defined __C99__FUNC__ \
1484 || defined __cplusplus || defined _MSC_VER)
1485static int
1486YYID (int i)
1487#else
1488static int
1489YYID (i)
1490 int i;
1491#endif
1492{
1493 return i;
1494}
1495#endif
1496
1497#if ! defined yyoverflow || YYERROR_VERBOSE
1498
1499/* The parser invokes alloca or malloc; define the necessary symbols. */
1500
1501# ifdef YYSTACK_USE_ALLOCA
1502# if YYSTACK_USE_ALLOCA
1503# ifdef __GNUC__
1504# define YYSTACK_ALLOC __builtin_alloca
1505# elif defined __BUILTIN_VA_ARG_INCR
1506# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1507# elif defined _AIX
1508# define YYSTACK_ALLOC __alloca
1509# elif defined _MSC_VER
1510# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1511# define alloca _alloca
1512# else
1513# define YYSTACK_ALLOC alloca
1514# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1515 || defined __cplusplus || defined _MSC_VER)
1516# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1517# ifndef _STDLIB_H
1518# define _STDLIB_H 1
1519# endif
1520# endif
1521# endif
1522# endif
1523# endif
1524
1525# ifdef YYSTACK_ALLOC
1526 /* Pacify GCC's `empty if-body' warning. */
1527# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1528# ifndef YYSTACK_ALLOC_MAXIMUM
1529 /* The OS might guarantee only one guard page at the bottom of the stack,
1530 and a page size can be as small as 4096 bytes. So we cannot safely
1531 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1532 to allow for a few compiler-allocated temporary stack slots. */
1533# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1534# endif
1535# else
1536# define YYSTACK_ALLOC YYMALLOC
1537# define YYSTACK_FREE YYFREE
1538# ifndef YYSTACK_ALLOC_MAXIMUM
1539# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1540# endif
1541# if (defined __cplusplus && ! defined _STDLIB_H \
1542 && ! ((defined YYMALLOC || defined malloc) \
1543 && (defined YYFREE || defined free)))
1544# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1545# ifndef _STDLIB_H
1546# define _STDLIB_H 1
1547# endif
1548# endif
1549# ifndef YYMALLOC
1550# define YYMALLOC malloc
1551# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1552 || defined __cplusplus || defined _MSC_VER)
1553void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1554# endif
1555# endif
1556# ifndef YYFREE
1557# define YYFREE free
1558# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1559 || defined __cplusplus || defined _MSC_VER)
1560void free (void *); /* INFRINGES ON USER NAME SPACE */
1561# endif
1562# endif
1563# endif
1564#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1565
1566
1567#if (! defined yyoverflow \
1568 && (! defined __cplusplus \
1569 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1570
1571/* A type that is properly aligned for any stack member. */
1572union yyalloc
1573{
1574 yytype_int16 yyss;
1575 YYSTYPE yyvs;
1576 };
1577
1578/* The size of the maximum gap between one aligned stack and the next. */
1579# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1580
1581/* The size of an array large to enough to hold all stacks, each with
1582 N elements. */
1583# define YYSTACK_BYTES(N) \
1584 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1585 + YYSTACK_GAP_MAXIMUM)
1586
1587/* Copy COUNT objects from FROM to TO. The source and destination do
1588 not overlap. */
1589# ifndef YYCOPY
1590# if defined __GNUC__ && 1 < __GNUC__
1591# define YYCOPY(To, From, Count) \
1592 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1593# else
1594# define YYCOPY(To, From, Count) \
1595 do \
1596 { \
1597 YYSIZE_T yyi; \
1598 for (yyi = 0; yyi < (Count); yyi++) \
1599 (To)[yyi] = (From)[yyi]; \
1600 } \
1601 while (YYID (0))
1602# endif
1603# endif
1604
1605/* Relocate STACK from its old location to the new one. The
1606 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1607 elements in the stack, and YYPTR gives the new location of the
1608 stack. Advance YYPTR to a properly aligned location for the next
1609 stack. */
1610# define YYSTACK_RELOCATE(Stack) \
1611 do \
1612 { \
1613 YYSIZE_T yynewbytes; \
1614 YYCOPY (&yyptr->Stack, Stack, yysize); \
1615 Stack = &yyptr->Stack; \
1616 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1617 yyptr += yynewbytes / sizeof (*yyptr); \
1618 } \
1619 while (YYID (0))
1620
1621#endif
1622
1623/* YYFINAL -- State number of the termination state. */
1624#define YYFINAL 43
1625/* YYLAST -- Last index in YYTABLE. */
1626#define YYLAST 1754
1627
1628/* YYNTOKENS -- Number of terminals. */
1629#define YYNTOKENS 162
1630/* YYNNTS -- Number of nonterminals. */
1631#define YYNNTS 82
1632/* YYNRULES -- Number of rules. */
1633#define YYNRULES 314
1634/* YYNRULES -- Number of states. */
1635#define YYNSTATES 602
1636
1637/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1638#define YYUNDEFTOK 2
1639#define YYMAXUTOK 402
1640
1641#define YYTRANSLATE(YYX) \
1642 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1643
1644/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1645static const yytype_uint8 yytranslate[] =
1646{
1647 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1651 152, 153, 150, 2, 149, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 157, 148, 158, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 154, 151, 156, 2, 2, 2, 2, 2, 161,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 155, 2, 2, 159, 2, 160, 2, 2, 2, 2,
1660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1661 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1662 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1663 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1664 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1665 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1666 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1667 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1668 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1669 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1670 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1671 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1672 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1673 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1674 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1675 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1676 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1677 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1678 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1679 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1680 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1681 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1682 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1683 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1684 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1685 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1686 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1687 145, 146, 147
1688};
1689
1690#if YYDEBUG
1691/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1692 YYRHS. */
1693static const yytype_uint16 yyprhs[] =
1694{
1695 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1696 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1697 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1698 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1699 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1700 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1701 119, 121, 123, 125, 127, 129, 130, 133, 134, 136,
1702 138, 140, 141, 144, 146, 148, 150, 152, 154, 156,
1703 158, 160, 161, 163, 165, 167, 168, 170, 172, 173,
1704 175, 177, 179, 181, 182, 184, 186, 187, 189, 191,
1705 193, 195, 197, 200, 202, 204, 206, 208, 210, 212,
1706 214, 216, 218, 219, 222, 224, 226, 228, 230, 232,
1707 234, 235, 238, 239, 242, 243, 247, 250, 251, 253,
1708 254, 258, 260, 263, 265, 267, 269, 271, 273, 275,
1709 277, 279, 281, 284, 286, 289, 295, 301, 307, 313,
1710 317, 320, 326, 331, 334, 336, 338, 340, 344, 346,
1711 350, 352, 353, 355, 359, 364, 368, 372, 377, 382,
1712 386, 393, 399, 402, 405, 408, 411, 414, 417, 420,
1713 423, 426, 429, 432, 435, 442, 448, 457, 464, 471,
1714 479, 487, 494, 503, 512, 516, 518, 520, 522, 524,
1715 525, 528, 535, 537, 538, 540, 543, 544, 548, 549,
1716 553, 557, 561, 565, 566, 574, 575, 584, 585, 594,
1717 600, 603, 607, 609, 613, 617, 621, 625, 627, 628,
1718 634, 638, 640, 644, 646, 647, 657, 659, 661, 666,
1719 668, 670, 673, 677, 678, 680, 682, 684, 686, 688,
1720 690, 692, 694, 696, 700, 702, 708, 710, 712, 714,
1721 716, 718, 720, 723, 726, 729, 733, 736, 737, 739,
1722 742, 745, 749, 759, 769, 778, 793, 795, 797, 804,
1723 810, 813, 820, 828, 832, 836, 842, 848, 849, 850,
1724 854, 857, 859, 865, 871, 878, 885, 890, 897, 902,
1725 907, 914, 921, 924, 933, 935, 937, 938, 942, 949,
1726 953, 960, 963, 969, 977
1727};
1728
1729/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1730static const yytype_int16 yyrhs[] =
1731{
1732 206, 0, -1, 73, -1, 74, -1, 75, -1, 76,
1733 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1734 -1, 85, -1, 86, -1, 87, -1, 82, -1, 83,
1735 -1, 84, -1, 116, -1, 117, -1, 118, -1, 119,
1736 -1, 120, -1, 121, -1, 122, -1, 123, -1, 124,
1737 -1, 125, -1, 126, -1, 127, -1, 90, -1, 91,
1738 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1739 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1740 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1741 -1, 107, -1, 108, -1, 109, -1, 96, -1, 97,
1742 -1, 98, -1, 99, -1, 26, -1, 27, -1, 11,
1743 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1744 -1, 19, -1, 22, -1, 24, -1, 170, -1, -1,
1745 170, 148, -1, -1, 20, -1, 23, -1, 175, -1,
1746 -1, 173, 148, -1, 42, -1, 44, -1, 43, -1,
1747 45, -1, 47, -1, 46, -1, 48, -1, 50, -1,
1748 -1, 145, -1, 146, -1, 147, -1, -1, 46, -1,
1749 48, -1, -1, 42, -1, 43, -1, 44, -1, 47,
1750 -1, -1, 44, -1, 42, -1, -1, 61, -1, 62,
1751 -1, 63, -1, 64, -1, 65, -1, 60, 4, -1,
1752 135, -1, 117, -1, 134, -1, 118, -1, 137, -1,
1753 138, -1, 140, -1, 141, -1, 142, -1, -1, 184,
1754 183, -1, 136, -1, 139, -1, 135, -1, 134, -1,
1755 144, -1, 143, -1, -1, 186, 185, -1, -1, 53,
1756 4, -1, -1, 149, 53, 4, -1, 34, 22, -1,
1757 -1, 189, -1, -1, 149, 192, 191, -1, 189, -1,
1758 53, 4, -1, 11, -1, 12, -1, 13, -1, 16,
1759 -1, 15, -1, 14, -1, 17, -1, 49, -1, 193,
1760 -1, 194, 150, -1, 228, -1, 151, 4, -1, 194,
1761 152, 198, 153, 186, -1, 10, 152, 198, 153, 186,
1762 -1, 154, 4, 155, 194, 156, -1, 157, 4, 155,
1763 194, 158, -1, 159, 199, 160, -1, 159, 160, -1,
1764 157, 159, 199, 160, 158, -1, 157, 159, 160, 158,
1765 -1, 194, 184, -1, 194, -1, 10, -1, 195, -1,
1766 197, 149, 195, -1, 197, -1, 197, 149, 39, -1,
1767 39, -1, -1, 194, -1, 199, 149, 194, -1, 194,
1768 154, 202, 156, -1, 194, 154, 156, -1, 194, 161,
1769 22, -1, 194, 157, 202, 158, -1, 194, 159, 202,
1770 160, -1, 194, 159, 160, -1, 194, 157, 159, 202,
1771 160, 158, -1, 194, 157, 159, 160, 158, -1, 194,
1772 40, -1, 194, 41, -1, 194, 228, -1, 194, 201,
1773 -1, 194, 25, -1, 168, 3, -1, 168, 5, -1,
1774 168, 4, -1, 168, 6, -1, 11, 26, -1, 11,
1775 27, -1, 169, 9, -1, 165, 152, 200, 38, 194,
1776 153, -1, 115, 152, 200, 239, 153, -1, 129, 152,
1777 200, 149, 200, 149, 200, 153, -1, 163, 152, 200,
1778 149, 200, 153, -1, 164, 152, 200, 149, 200, 153,
1779 -1, 88, 166, 152, 200, 149, 200, 153, -1, 89,
1780 167, 152, 200, 149, 200, 153, -1, 131, 152, 200,
1781 149, 200, 153, -1, 132, 152, 200, 149, 200, 149,
1782 200, 153, -1, 133, 152, 200, 149, 200, 149, 200,
1783 153, -1, 202, 149, 200, -1, 200, -1, 32, -1,
1784 33, -1, 37, -1, -1, 196, 228, -1, 121, 152,
1785 205, 38, 194, 153, -1, 207, -1, -1, 208, -1,
1786 207, 208, -1, -1, 31, 209, 224, -1, -1, 30,
1787 210, 225, -1, 58, 57, 214, -1, 172, 18, 194,
1788 -1, 172, 18, 10, -1, -1, 174, 178, 204, 203,
1789 200, 211, 191, -1, -1, 174, 176, 178, 204, 203,
1790 200, 212, 191, -1, -1, 174, 177, 178, 204, 203,
1791 194, 213, 191, -1, 174, 178, 35, 181, 205, -1,
1792 51, 215, -1, 54, 148, 216, -1, 22, -1, 52,
1793 148, 22, -1, 66, 148, 22, -1, 154, 217, 156,
1794 -1, 217, 149, 22, -1, 22, -1, -1, 218, 149,
1795 194, 184, 171, -1, 194, 184, 171, -1, 218, -1,
1796 218, 149, 39, -1, 39, -1, -1, 182, 196, 173,
1797 152, 219, 153, 186, 190, 187, -1, 28, -1, 159,
1798 -1, 180, 178, 220, 221, -1, 29, -1, 160, -1,
1799 231, 223, -1, 179, 178, 220, -1, -1, 59, -1,
1800 3, -1, 4, -1, 9, -1, 26, -1, 27, -1,
1801 40, -1, 41, -1, 25, -1, 157, 202, 158, -1,
1802 201, -1, 57, 226, 22, 149, 22, -1, 7, -1,
1803 8, -1, 170, -1, 173, -1, 228, -1, 227, -1,
1804 194, 229, -1, 231, 232, -1, 222, 232, -1, 233,
1805 172, 234, -1, 233, 236, -1, -1, 21, -1, 67,
1806 230, -1, 67, 10, -1, 68, 17, 229, -1, 68,
1807 11, 229, 149, 17, 229, 149, 17, 229, -1, 69,
1808 168, 229, 149, 17, 229, 154, 235, 156, -1, 69,
1809 168, 229, 149, 17, 229, 154, 156, -1, 70, 182,
1810 196, 229, 152, 238, 153, 186, 38, 17, 229, 71,
1811 17, 229, -1, 71, -1, 72, -1, 235, 168, 227,
1812 149, 17, 229, -1, 168, 227, 149, 17, 229, -1,
1813 172, 241, -1, 194, 154, 229, 149, 229, 156, -1,
1814 237, 149, 154, 229, 149, 229, 156, -1, 194, 229,
1815 184, -1, 17, 229, 184, -1, 238, 149, 194, 229,
1816 184, -1, 238, 149, 17, 229, 184, -1, -1, -1,
1817 239, 149, 230, -1, 56, 55, -1, 55, -1, 163,
1818 194, 229, 149, 229, -1, 164, 194, 229, 149, 229,
1819 -1, 88, 166, 194, 229, 149, 229, -1, 89, 167,
1820 194, 229, 149, 229, -1, 165, 230, 38, 194, -1,
1821 129, 230, 149, 230, 149, 230, -1, 130, 230, 149,
1822 194, -1, 131, 230, 149, 230, -1, 132, 230, 149,
1823 230, 149, 230, -1, 133, 230, 149, 230, 149, 230,
1824 -1, 128, 237, -1, 240, 182, 196, 229, 152, 238,
1825 153, 186, -1, 243, -1, 36, -1, -1, 110, 194,
1826 188, -1, 110, 194, 149, 11, 229, 188, -1, 111,
1827 194, 188, -1, 111, 194, 149, 11, 229, 188, -1,
1828 112, 230, -1, 242, 113, 194, 229, 188, -1, 242,
1829 114, 230, 149, 194, 229, 188, -1, 115, 194, 229,
1830 239, -1
1831};
1832
1833/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1834static const yytype_uint16 yyrline[] =
1835{
1836 0, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128, 1128,
1837 1128, 1129, 1129, 1129, 1129, 1129, 1129, 1130, 1130, 1130,
1838 1130, 1130, 1130, 1131, 1131, 1131, 1131, 1131, 1131, 1134,
1839 1134, 1135, 1135, 1136, 1136, 1137, 1137, 1138, 1138, 1142,
1840 1142, 1143, 1143, 1144, 1144, 1145, 1145, 1146, 1146, 1147,
1841 1147, 1148, 1148, 1149, 1150, 1155, 1156, 1156, 1156, 1156,
1842 1156, 1158, 1158, 1158, 1159, 1159, 1163, 1167, 1172, 1172,
1843 1174, 1175, 1180, 1186, 1187, 1188, 1189, 1190, 1194, 1195,
1844 1196, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1213, 1214,
1845 1215, 1216, 1217, 1221, 1222, 1223, 1226, 1227, 1228, 1229,
1846 1230, 1231, 1232, 1239, 1240, 1241, 1242, 1243, 1244, 1245,
1847 1246, 1247, 1250, 1251, 1256, 1257, 1258, 1259, 1260, 1261,
1848 1264, 1265, 1272, 1273, 1279, 1280, 1288, 1296, 1297, 1302,
1849 1303, 1304, 1309, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
Nate Begeman4a365ad2007-11-15 21:15:26 +00001850 1325, 1329, 1333, 1340, 1345, 1353, 1383, 1414, 1419, 1429,
1851 1439, 1443, 1453, 1460, 1467, 1474, 1479, 1484, 1491, 1492,
1852 1499, 1506, 1514, 1520, 1532, 1560, 1576, 1603, 1631, 1657,
1853 1677, 1703, 1723, 1735, 1742, 1808, 1818, 1828, 1834, 1844,
1854 1850, 1860, 1865, 1870, 1883, 1895, 1917, 1925, 1931, 1942,
1855 1947, 1952, 1958, 1964, 1973, 1977, 1985, 1985, 1988, 1988,
1856 1991, 2003, 2024, 2029, 2037, 2038, 2042, 2042, 2046, 2046,
1857 2049, 2052, 2076, 2087, 2087, 2098, 2097, 2107, 2106, 2117,
1858 2157, 2160, 2166, 2176, 2180, 2185, 2187, 2192, 2197, 2206,
1859 2216, 2227, 2231, 2240, 2249, 2254, 2375, 2375, 2377, 2386,
1860 2386, 2388, 2393, 2405, 2409, 2414, 2418, 2422, 2426, 2430,
1861 2434, 2438, 2442, 2446, 2471, 2475, 2485, 2489, 2493, 2498,
1862 2505, 2505, 2511, 2520, 2524, 2533, 2542, 2551, 2555, 2562,
1863 2566, 2570, 2575, 2585, 2604, 2613, 2693, 2697, 2704, 2715,
1864 2728, 2738, 2749, 2759, 2768, 2774, 2783, 2789, 2792, 2793,
1865 2800, 2804, 2809, 2825, 2842, 2856, 2870, 2882, 2890, 2897,
1866 2903, 2909, 2915, 2930, 3015, 3020, 3024, 3031, 3038, 3046,
1867 3053, 3061, 3069, 3083, 3100
Anton Korobeynikov66e28652007-11-14 09:53:48 +00001868};
1869#endif
1870
1871#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1872/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1873 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1874static const char *const yytname[] =
1875{
1876 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1877 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1878 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1879 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1880 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1881 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1882 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1883 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1884 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1885 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1886 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1887 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1888 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1889 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1890 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1891 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1892 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1893 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1894 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1895 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1896 "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN",
1897 "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "CONST", "PURE",
1898 "DEFAULT", "HIDDEN", "PROTECTED", "'='", "','", "'*'", "'\\\\'", "'('",
1899 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1900 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1901 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1902 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1903 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1904 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1905 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1906 "SectionString", "OptSection", "GlobalVarAttributes",
1907 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1908 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1909 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1910 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1911 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1912 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1913 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1914 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1915 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1916 "PHIList", "ParamList", "IndexList", "OptTailCall", "InstVal",
1917 "OptVolatile", "MemoryInst", 0
1918};
1919#endif
1920
1921# ifdef YYPRINT
1922/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1923 token YYLEX-NUM. */
1924static const yytype_uint16 yytoknum[] =
1925{
1926 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1927 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1928 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1929 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1930 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1931 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1932 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1933 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1934 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1935 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1936 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1937 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1938 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1939 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1940 395, 396, 397, 398, 399, 400, 401, 402, 61, 44,
1941 42, 92, 40, 41, 91, 120, 93, 60, 62, 123,
1942 125, 99
1943};
1944# endif
1945
1946/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1947static const yytype_uint8 yyr1[] =
1948{
1949 0, 162, 163, 163, 163, 163, 163, 163, 163, 163,
1950 163, 164, 164, 164, 164, 164, 164, 165, 165, 165,
1951 165, 165, 165, 165, 165, 165, 165, 165, 165, 166,
1952 166, 166, 166, 166, 166, 166, 166, 166, 166, 167,
1953 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
1954 167, 167, 167, 167, 167, 168, 169, 169, 169, 169,
1955 169, 170, 170, 170, 171, 171, 172, 172, 173, 173,
1956 174, 174, 175, 176, 176, 176, 176, 176, 177, 177,
1957 177, 178, 178, 178, 178, 179, 179, 179, 180, 180,
1958 180, 180, 180, 181, 181, 181, 182, 182, 182, 182,
1959 182, 182, 182, 183, 183, 183, 183, 183, 183, 183,
1960 183, 183, 184, 184, 185, 185, 185, 185, 185, 185,
1961 186, 186, 187, 187, 188, 188, 189, 190, 190, 191,
1962 191, 192, 192, 193, 193, 193, 193, 193, 193, 193,
1963 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
1964 194, 194, 194, 195, 196, 196, 197, 197, 198, 198,
1965 198, 198, 199, 199, 200, 200, 200, 200, 200, 200,
1966 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
1967 200, 200, 200, 200, 201, 201, 201, 201, 201, 201,
1968 201, 201, 201, 201, 202, 202, 203, 203, 204, 204,
1969 205, 205, 206, 206, 207, 207, 209, 208, 210, 208,
1970 208, 208, 208, 211, 208, 212, 208, 213, 208, 208,
1971 208, 208, 214, 215, 215, 216, 217, 217, 217, 218,
1972 218, 219, 219, 219, 219, 220, 221, 221, 222, 223,
1973 223, 224, 225, 226, 226, 227, 227, 227, 227, 227,
1974 227, 227, 227, 227, 227, 227, 228, 228, 228, 228,
1975 229, 229, 230, 231, 231, 232, 233, 233, 233, 234,
1976 234, 234, 234, 234, 234, 234, 234, 234, 235, 235,
1977 236, 237, 237, 238, 238, 238, 238, 238, 239, 239,
1978 240, 240, 241, 241, 241, 241, 241, 241, 241, 241,
1979 241, 241, 241, 241, 241, 242, 242, 243, 243, 243,
1980 243, 243, 243, 243, 243
1981};
1982
1983/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1984static const yytype_uint8 yyr2[] =
1985{
1986 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1987 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1992 1, 1, 1, 1, 1, 0, 2, 0, 1, 1,
1993 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1994 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1995 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1996 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1997 1, 1, 0, 2, 1, 1, 1, 1, 1, 1,
1998 0, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1999 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
2000 1, 1, 2, 1, 2, 5, 5, 5, 5, 3,
2001 2, 5, 4, 2, 1, 1, 1, 3, 1, 3,
2002 1, 0, 1, 3, 4, 3, 3, 4, 4, 3,
2003 6, 5, 2, 2, 2, 2, 2, 2, 2, 2,
2004 2, 2, 2, 2, 6, 5, 8, 6, 6, 7,
2005 7, 6, 8, 8, 3, 1, 1, 1, 1, 0,
2006 2, 6, 1, 0, 1, 2, 0, 3, 0, 3,
2007 3, 3, 3, 0, 7, 0, 8, 0, 8, 5,
2008 2, 3, 1, 3, 3, 3, 3, 1, 0, 5,
2009 3, 1, 3, 1, 0, 9, 1, 1, 4, 1,
2010 1, 2, 3, 0, 1, 1, 1, 1, 1, 1,
2011 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
2012 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
2013 2, 3, 9, 9, 8, 14, 1, 1, 6, 5,
2014 2, 6, 7, 3, 3, 5, 5, 0, 0, 3,
2015 2, 1, 5, 5, 6, 6, 4, 6, 4, 4,
2016 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
2017 6, 2, 5, 7, 4
2018};
2019
2020/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2021 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2022 means the default is an error. */
2023static const yytype_uint16 yydefact[] =
2024{
2025 71, 61, 68, 62, 69, 63, 208, 206, 0, 0,
2026 0, 0, 0, 0, 81, 70, 0, 71, 204, 85,
2027 88, 0, 0, 220, 0, 0, 66, 0, 72, 73,
2028 75, 74, 76, 78, 77, 79, 80, 82, 83, 84,
2029 81, 81, 199, 1, 205, 86, 87, 81, 209, 89,
2030 90, 91, 92, 81, 267, 207, 267, 0, 0, 228,
2031 221, 222, 210, 256, 257, 212, 133, 134, 135, 138,
2032 137, 136, 139, 140, 0, 0, 0, 0, 258, 259,
2033 141, 211, 143, 199, 199, 93, 198, 0, 96, 96,
2034 268, 264, 67, 239, 240, 241, 263, 223, 224, 227,
2035 0, 161, 144, 0, 0, 0, 0, 150, 162, 0,
2036 142, 161, 0, 0, 95, 94, 0, 196, 197, 0,
2037 0, 97, 98, 99, 100, 101, 0, 242, 0, 306,
2038 266, 0, 225, 160, 112, 156, 158, 0, 0, 0,
2039 0, 0, 0, 149, 0, 0, 0, 155, 0, 154,
2040 0, 219, 133, 134, 135, 138, 137, 136, 0, 0,
2041 0, 213, 102, 0, 236, 237, 238, 305, 291, 0,
2042 0, 0, 0, 96, 276, 277, 2, 3, 4, 5,
2043 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
2044 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
2045 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
2046 0, 0, 0, 0, 0, 0, 0, 0, 265, 96,
2047 280, 0, 304, 226, 153, 0, 120, 0, 0, 152,
2048 0, 163, 120, 215, 217, 0, 200, 181, 182, 177,
2049 179, 178, 180, 183, 176, 172, 173, 0, 0, 0,
2050 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2051 0, 175, 174, 129, 0, 290, 270, 0, 269, 0,
2052 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
2053 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
2054 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
2055 48, 0, 124, 124, 311, 0, 0, 302, 0, 0,
2056 0, 0, 0, 0, 0, 0, 0, 0, 0, 104,
2057 106, 105, 103, 107, 108, 109, 110, 111, 113, 159,
2058 157, 146, 147, 148, 151, 145, 129, 129, 0, 0,
2059 0, 0, 0, 0, 0, 0, 165, 195, 0, 0,
2060 0, 169, 0, 166, 0, 0, 0, 0, 214, 234,
2061 245, 246, 247, 252, 248, 249, 250, 251, 243, 0,
2062 254, 261, 260, 262, 0, 271, 0, 0, 0, 0,
2063 0, 307, 0, 309, 288, 0, 0, 0, 0, 0,
2064 0, 0, 0, 0, 0, 0, 0, 0, 117, 116,
2065 114, 115, 119, 118, 121, 216, 218, 0, 0, 0,
2066 288, 0, 0, 0, 0, 0, 164, 150, 162, 0,
2067 167, 168, 0, 0, 0, 0, 0, 131, 129, 233,
2068 112, 231, 0, 244, 0, 0, 0, 0, 0, 0,
2069 0, 0, 0, 0, 314, 0, 0, 0, 298, 299,
2070 0, 0, 0, 0, 296, 0, 124, 0, 0, 0,
2071 0, 0, 0, 0, 0, 0, 194, 171, 0, 0,
2072 0, 0, 126, 132, 130, 65, 0, 120, 0, 253,
2073 0, 0, 287, 0, 0, 124, 125, 124, 0, 0,
2074 0, 0, 0, 0, 292, 293, 287, 0, 312, 0,
2075 201, 0, 0, 185, 0, 0, 0, 0, 170, 0,
2076 0, 0, 64, 230, 232, 112, 127, 0, 0, 0,
2077 139, 0, 0, 294, 295, 308, 310, 289, 0, 0,
2078 297, 300, 301, 0, 124, 0, 0, 0, 191, 0,
2079 0, 187, 188, 184, 65, 128, 122, 255, 0, 0,
2080 112, 112, 0, 120, 281, 0, 120, 313, 189, 190,
2081 0, 0, 0, 229, 0, 235, 0, 274, 0, 0,
2082 284, 283, 139, 0, 0, 282, 303, 186, 192, 193,
2083 123, 272, 0, 273, 0, 112, 112, 0, 0, 0,
2084 286, 285, 0, 0, 0, 0, 279, 0, 0, 278,
2085 0, 275
2086};
2087
2088/* YYDEFGOTO[NTERM-NUM]. */
2089static const yytype_int16 yydefgoto[] =
2090{
2091 -1, 258, 259, 260, 284, 301, 158, 159, 78, 513,
2092 12, 79, 14, 15, 40, 41, 42, 47, 53, 116,
2093 126, 328, 224, 404, 331, 565, 381, 427, 546, 358,
2094 428, 80, 160, 135, 150, 136, 137, 109, 347, 370,
2095 348, 119, 87, 151, 16, 17, 18, 20, 19, 263,
2096 336, 337, 62, 23, 60, 100, 431, 432, 127, 166,
2097 54, 95, 55, 48, 434, 371, 82, 373, 268, 56,
2098 91, 92, 218, 569, 130, 307, 522, 444, 219, 220,
2099 221, 222
2100};
2101
2102/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2103 STATE-NUM. */
2104#define YYPACT_NINF -549
2105static const yytype_int16 yypact[] =
2106{
2107 322, -549, -549, -549, -549, -549, -549, -549, -18, -120,
2108 6, -117, 62, -60, 224, -549, 111, 464, -549, 103,
2109 184, -12, -7, -549, 21, 133, -549, 1309, -549, -549,
2110 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2111 140, 140, 211, -549, -549, -549, -549, 140, -549, -549,
2112 -549, -549, -549, 140, 139, -549, -14, 157, 174, 182,
2113 -549, -549, -549, -549, -549, 60, -549, -549, -549, -549,
2114 -549, -549, -549, -549, 215, 233, 2, 526, -549, -549,
2115 -549, 150, -549, 178, 178, 269, -549, 14, 274, 274,
2116 -549, -549, 134, -549, -549, -549, -549, -549, -549, -549,
2117 -23, 54, -549, 97, 105, 993, 60, -549, 150, -125,
2118 -549, 54, 14, 14, -549, -549, 1093, -549, -549, 1340,
2119 260, -549, -549, -549, -549, -549, 1358, -549, -17, 1584,
2120 -549, 251, -549, -549, 150, -549, 128, 146, 1380, 1380,
2121 145, -106, 1380, -549, 151, 1340, 1380, 60, 155, 150,
2122 231, -549, 101, 303, 305, 308, 312, 315, 229, 320,
2123 808, -549, -549, 187, -549, -549, -549, -549, -549, 275,
2124 1423, 85, 321, 274, -549, -549, -549, -549, -549, -549,
2125 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2126 -549, 461, 481, 1380, 1380, 1380, 1380, -549, -549, -549,
2127 -549, -549, -549, -549, -549, -549, -549, -549, -549, 1380,
2128 1380, 1380, 1380, 1380, 1380, 1380, 1380, 1380, -549, 274,
2129 -549, 110, -549, -549, -85, 1116, -549, -2, -33, -549,
2130 173, 150, -549, -549, 150, 1093, -549, -549, -549, -549,
2131 -549, -549, -549, -549, -549, -549, -549, 461, 481, 191,
2132 198, 199, 203, 204, 1156, 1534, 1033, 335, 206, 207,
2133 208, -549, -549, 217, 223, -549, 60, 649, -549, 785,
2134 785, -549, 785, 1358, -549, -549, -549, -549, -549, -549,
2135 -549, -549, -549, -549, 1380, -549, -549, -549, -549, -549,
2136 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2137 -549, 1380, 107, 113, -549, 649, 26, 218, 236, 237,
2138 238, 239, 240, 649, 649, 340, 1358, 1380, 1380, -549,
2139 -549, -549, -549, -549, -549, -549, -549, -549, -549, -549,
2140 -549, 162, -549, -549, -549, 162, 217, 217, 344, 242,
2141 243, 1340, 1340, 1340, 1340, 1340, -549, -549, -9, 1073,
2142 -50, -549, -63, -549, 1340, 1340, 1340, -11, -549, 1187,
2143 -549, -549, -549, -549, -549, -549, -549, -549, 333, 1340,
2144 -549, -549, -549, -549, 247, -549, 248, 785, 649, 649,
2145 7, -549, 34, -549, -549, 785, 244, 1380, 1380, 1380,
2146 1380, 1380, 256, 257, 1380, 785, 649, 258, -549, -549,
2147 -549, -549, -549, -549, -549, -549, -549, 1380, 1340, 1340,
2148 -549, 261, 264, 267, 268, 1340, -549, 263, 808, -51,
2149 -549, -549, 270, 273, 362, 396, 419, -549, 217, -549,
2150 150, 276, 271, -549, 405, -48, 411, 412, 280, 284,
2151 287, 785, 433, 785, 289, 290, 785, 293, 150, -549,
2152 294, 295, 785, 785, 150, 296, 297, 1380, 90, 298,
2153 300, 13, 1340, 1340, 1340, 1340, -549, -549, 299, 1340,
2154 1340, 1380, -549, -549, -549, -3, 1269, -549, 304, -549,
2155 785, 785, 1577, 785, 785, 297, -549, 297, 1380, 785,
2156 306, 1380, 1380, 1380, -549, -549, 1577, 401, -549, 649,
2157 -549, 1340, 1340, -549, 309, 310, 319, 323, -549, 316,
2158 318, 126, -549, -549, -549, 150, 38, 437, 324, 307,
2159 785, 649, 44, -549, -549, -549, -549, -549, 325, 785,
2160 -549, -549, -549, 53, 297, 327, 332, 1340, -549, 1340,
2161 1340, -549, -549, -549, -3, -549, 421, -549, 460, 1,
2162 -549, -549, 1595, -549, -549, 334, -549, -549, -549, -549,
2163 336, 338, 339, -549, 489, -549, 785, -549, 945, 3,
2164 -85, -85, 785, 649, 86, -549, 162, -549, -549, -549,
2165 -549, -549, 347, -549, 945, -549, -549, 484, 485, 356,
2166 -85, -85, 785, 785, 492, 439, -549, 785, 494, -549,
2167 785, -549
2168};
2169
2170/* YYPGOTO[NTERM-NUM]. */
2171static const yytype_int16 yypgoto[] =
2172{
2173 -549, 383, 384, 385, 272, 277, -170, -549, 0, -24,
2174 429, 8, -549, -549, -549, -549, 42, -549, -549, -549,
2175 -160, -549, -421, -549, -228, -549, -293, 11, -549, -310,
2176 -549, -549, -26, 341, -121, -549, 418, 425, -61, -157,
2177 -226, 9, 205, 326, -549, -549, 515, -549, -549, -549,
2178 -549, -549, -549, -549, -549, -549, -549, -549, 446, -549,
2179 -549, -549, -549, -549, -549, -548, -69, 121, -173, -549,
2180 491, -549, -549, -549, -549, -549, 67, 158, -549, -549,
2181 -549, -549
2182};
2183
2184/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2185 positive, shift that token. If negative, reduce the rule which
2186 number is the opposite. If zero, do what YYDEFACT says.
2187 If YYTABLE_NINF, syntax error. */
2188#define YYTABLE_NINF -204
2189static const yytype_int16 yytable[] =
2190{
2191 11, 81, 272, 261, 335, 163, 104, 90, 13, 475,
2192 383, 164, 271, 273, 271, 93, 1, 11, 441, 3,
2193 582, 5, 304, 425, 142, 13, 405, 406, 24, 350,
2194 352, 26, 319, 320, 21, 143, 589, 308, 309, 310,
2195 311, 312, 426, 142, 315, 443, 117, 118, 22, 321,
2196 322, 108, 323, 324, 230, 325, 326, 327, 161, 316,
2197 442, 63, 64, 25, 106, 66, 67, 68, 69, 70,
2198 71, 72, 425, 1, 2, 134, 3, 4, 5, 108,
2199 27, 236, 83, 84, 233, 134, 415, 442, 28, 88,
2200 149, 262, 11, 133, 544, 89, 269, 421, 415, 415,
2201 149, 415, 270, 73, -55, -55, -55, -55, 420, 468,
2202 479, 43, 227, 228, 319, 320, 231, 110, 474, 111,
2203 234, 145, 146, 419, 587, 333, 131, 237, 238, 570,
2204 571, 321, 322, 132, 323, 324, 57, 325, 326, 327,
2205 415, 58, 165, 435, 267, 397, 94, 416, 110, 45,
2206 111, 46, 377, 1, 332, 61, 3, 567, 5, 583,
2207 90, 105, 488, 498, 590, 591, 503, 302, 303, 267,
2208 305, 264, 398, 399, 400, 59, 110, 401, 111, 97,
2209 385, 402, 403, 306, 267, 267, 267, 267, 267, 313,
2210 314, 267, 525, 552, 526, 395, 98, 553, 372, 134,
2211 372, 372, 552, 372, 99, 74, 556, 2, 75, 149,
2212 4, 76, 101, 77, 447, 86, 449, 450, 451, 102,
2213 398, 399, 400, 317, 318, 401, 49, 50, 51, 402,
2214 403, 52, 239, 240, 241, 242, 372, 103, 63, 64,
2215 110, 557, 111, 500, 372, 372, 85, 149, 86, 516,
2216 1, 2, 138, 3, 4, 5, 380, 110, 378, 111,
2217 139, 261, 382, 110, 162, 111, 29, 30, 31, 32,
2218 33, 34, 35, 223, 36, 379, 110, 225, 111, 543,
2219 410, 411, 412, 413, 414, 37, 38, 39, 112, 113,
2220 149, 396, 267, 422, 423, 424, 398, 399, 400, 226,
2221 110, 401, 111, 229, 232, 402, 403, 235, 372, 372,
2222 372, 114, -56, 115, -57, 527, 372, -60, 530, 531,
2223 532, -59, -203, 418, -58, 574, 372, 372, 576, 243,
2224 265, 334, 271, 430, 120, 121, 122, 123, 124, 125,
2225 -67, 1, 2, 341, 3, 4, 5, 459, 460, 262,
2226 342, 343, 6, 7, 466, 344, 345, 353, 354, 355,
2227 356, 267, 448, 267, 267, 267, 357, 386, 454, 37,
2228 38, 39, 372, 8, 372, 359, 9, 372, 394, 568,
2229 10, 458, 407, 372, 372, 387, 388, 389, 390, 391,
2230 374, 375, 433, 376, 408, 409, 436, 437, 446, 584,
2231 471, 504, 505, 506, 507, 452, 453, 457, 509, 510,
2232 462, 372, 372, 463, 372, 372, 464, 465, 472, 469,
2233 372, 467, 470, 473, 477, 476, 384, 478, 480, 481,
2234 372, 499, 482, 483, 392, 393, 484, 486, 488, 489,
2235 535, 536, 491, 492, 493, 511, 497, 501, 496, 502,
2236 515, 372, 372, 517, 442, 529, 521, 508, 537, 547,
2237 372, 549, 267, 538, -202, 267, 267, 267, 539, 541,
2238 521, 542, 540, 548, 564, 512, 560, 566, 561, 562,
2239 558, 554, -67, 1, 2, 559, 3, 4, 5, 577,
2240 575, 578, 579, 580, 6, 7, 588, 372, 438, 439,
2241 440, 592, 593, 372, 372, 594, 445, 285, 286, 597,
2242 598, 600, 215, 216, 217, 8, 455, 456, 9, 339,
2243 563, 129, 10, 372, 372, 340, 573, 545, 372, 144,
2244 141, 372, 44, 63, 64, 128, 106, 66, 67, 68,
2245 69, 70, 71, 72, 512, 1, 2, 96, 3, 4,
2246 5, 274, 275, 276, 277, 278, 279, 280, 281, 282,
2247 283, 338, 485, 533, 487, 0, 330, 490, 461, 0,
2248 0, 0, 0, 494, 495, 73, 0, 287, 288, 289,
2249 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
2250 300, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2251 0, 518, 519, 0, 523, 524, 0, 0, 0, 0,
2252 528, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2253 534, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2255 0, 550, 551, 0, 0, 0, 0, 0, 0, 0,
2256 555, 0, 360, 361, 0, 0, 63, 64, 362, 0,
2257 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2258 0, 3, 4, 5, 363, 364, 365, 74, 0, 0,
2259 75, 0, 0, 76, 0, 77, 107, 581, 0, 366,
2260 367, 0, 0, 585, 586, 0, 0, 0, 0, 0,
2261 0, 0, 0, 0, 0, 0, 368, 0, 0, 0,
2262 0, 0, 0, 595, 596, 0, 0, 0, 599, 0,
2263 0, 601, 176, 177, 178, 179, 180, 181, 182, 183,
2264 184, 185, 186, 187, 188, 189, 190, 247, 248, 0,
2265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2267 0, 0, 0, 0, 249, 197, 198, 199, 200, 201,
2268 202, 203, 204, 205, 206, 207, 208, 0, 250, 0,
2269 251, 252, 253, 0, 0, 0, 0, 0, 360, 361,
2270 0, 0, 63, 64, 362, 0, 0, 0, 0, 110,
2271 0, 111, 0, 0, 1, 2, 369, 3, 4, 5,
2272 363, 364, 365, 0, 0, 63, 64, 0, 0, 0,
2273 0, 0, 0, 0, 0, 366, 367, 1, 2, 0,
2274 3, 4, 5, 244, 0, 0, 0, 0, 0, 0,
2275 0, 0, 368, 0, 0, 0, 0, 0, 245, 246,
2276 0, 0, 0, 0, 0, 0, 0, 0, 176, 177,
2277 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2278 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2279 0, 176, 177, 178, 179, 180, 181, 182, 183, 184,
2280 185, 186, 187, 188, 189, 190, 247, 248, 0, 0,
2281 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2282 206, 207, 208, 0, 250, 0, 251, 252, 253, 0,
2283 0, 0, 0, 249, 197, 198, 199, 200, 201, 202,
2284 203, 204, 205, 206, 207, 208, 0, 250, 0, 251,
2285 252, 253, 369, 0, 0, 0, 0, 0, 360, 361,
2286 0, 0, 0, 0, 362, 0, 0, 0, 110, 0,
2287 111, 0, 254, 0, 0, 255, 0, 256, 0, 257,
2288 363, 364, 365, 0, 0, 0, 0, 0, 0, 0,
2289 0, 0, 0, 0, 0, 366, 367, 0, 0, 0,
2290 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2291 63, 64, 368, 106, 66, 67, 68, 69, 70, 71,
2292 72, 0, 1, 2, 0, 3, 4, 5, 176, 177,
2293 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2294 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2295 63, 64, 73, 106, 152, 153, 154, 155, 156, 157,
2296 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2297 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2298 206, 207, 208, 0, 250, 0, 251, 252, 253, 0,
2299 63, 64, 73, 106, 152, 153, 154, 155, 156, 157,
2300 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2301 63, 64, 369, 147, 66, 67, 68, 69, 70, 71,
2302 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2303 0, 0, 73, 63, 64, 0, 106, 66, 67, 68,
2304 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2305 5, 0, 73, 0, 74, 0, 0, 75, 0, 0,
2306 76, 0, 77, 140, 0, 329, 0, 0, 0, 0,
2307 0, 0, 0, 63, 64, 73, 106, 152, 153, 154,
2308 155, 156, 157, 72, 0, 1, 2, 0, 3, 4,
2309 5, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2310 76, 0, 77, 351, 63, 64, 0, 106, 66, 67,
2311 68, 69, 70, 71, 72, 73, 1, 2, 0, 3,
2312 4, 5, 0, 0, 148, 0, 0, 0, 0, 0,
2313 0, 0, 0, 0, 74, 0, 429, 75, 0, 0,
2314 76, 0, 77, 417, 0, 0, 73, 0, 0, 0,
2315 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2316 76, 0, 77, 0, 0, 0, 0, 0, 0, 0,
2317 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2318 75, 0, 0, 76, 0, 77, 63, 64, 0, 106,
2319 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2320 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 0, 74, 514, 0,
2322 75, 0, 346, 76, 0, 77, 63, 64, 73, 65,
2323 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2324 0, 3, 4, 5, 0, 0, 0, 0, 74, 0,
2325 0, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2326 106, 152, 153, 154, 155, 156, 157, 72, 73, 1,
2327 2, 0, 3, 4, 5, 63, 64, 0, 147, 66,
2328 67, 68, 69, 70, 71, 72, 0, 1, 2, 0,
2329 3, 4, 5, 0, 0, 0, 0, 63, 64, 73,
2330 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2331 2, 0, 3, 4, 5, 0, 0, 73, 0, 0,
2332 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2333 74, 0, 0, 75, 0, 0, 76, 0, 77, 73,
2334 63, 64, 0, 266, 66, 67, 68, 69, 70, 71,
2335 72, 0, 1, 2, 0, 3, 4, 5, 0, 0,
2336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2337 74, 0, 0, 75, 0, 0, 76, 0, 77, 0,
2338 0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
2339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2340 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2341 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2342 0, 0, 75, 0, 0, 76, 0, 77, 0, 0,
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2345 0, 63, 64, 0, 106, 152, 153, 154, 155, 156,
2346 157, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2348 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2349 76, 0, 77, 73, 63, 64, 0, 106, 66, 67,
2350 68, 69, 70, 71, 520, 0, 1, 2, 0, 3,
2351 4, 5, 63, 64, 0, 106, 66, 67, 68, 69,
2352 70, 71, 572, 0, 1, 2, 0, 3, 4, 5,
2353 167, 0, 0, 0, 0, 0, 73, 0, 0, 0,
2354 0, 0, 0, 0, 0, 0, 0, 0, 0, 168,
2355 169, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2356 0, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2357 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
2358 189, 190, 191, 192, 0, 0, 0, 0, 0, 0,
2359 0, 0, 0, 0, 0, 74, 0, 0, 75, 0,
2360 0, 76, 0, 349, 193, 194, 195, 0, 0, 196,
2361 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
2362 207, 208, 209, 210, 211, 212, 213, 214, 0, 0,
2363 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2364 0, 75, 0, 0, 76, 0, 77, 0, 0, 0,
2365 0, 0, 0, 0, 0, 0, 74, 0, 0, 75,
2366 0, 0, 76, 0, 77
2367};
2368
2369static const yytype_int16 yycheck[] =
2370{
2371 0, 27, 172, 160, 232, 126, 4, 21, 0, 430,
2372 303, 28, 11, 173, 11, 29, 19, 17, 11, 22,
2373 568, 24, 195, 34, 149, 17, 336, 337, 148, 255,
2374 256, 148, 117, 118, 52, 160, 584, 210, 211, 212,
2375 213, 214, 53, 149, 217, 11, 32, 33, 66, 134,
2376 135, 77, 137, 138, 160, 140, 141, 142, 119, 219,
2377 53, 7, 8, 57, 10, 11, 12, 13, 14, 15,
2378 16, 17, 34, 19, 20, 101, 22, 23, 24, 105,
2379 18, 150, 40, 41, 145, 111, 149, 53, 148, 47,
2380 116, 160, 92, 39, 515, 53, 11, 160, 149, 149,
2381 126, 149, 17, 49, 3, 4, 5, 6, 158, 160,
2382 158, 0, 138, 139, 117, 118, 142, 150, 428, 152,
2383 146, 112, 113, 349, 38, 158, 149, 26, 27, 550,
2384 551, 134, 135, 156, 137, 138, 148, 140, 141, 142,
2385 149, 148, 159, 369, 170, 318, 160, 156, 150, 46,
2386 152, 48, 273, 19, 156, 22, 22, 156, 24, 156,
2387 21, 159, 149, 456, 585, 586, 153, 193, 194, 195,
2388 196, 163, 134, 135, 136, 154, 150, 139, 152, 22,
2389 154, 143, 144, 209, 210, 211, 212, 213, 214, 215,
2390 216, 217, 485, 149, 487, 316, 22, 153, 267, 225,
2391 269, 270, 149, 272, 22, 151, 153, 20, 154, 235,
2392 23, 157, 152, 159, 387, 37, 389, 390, 391, 4,
2393 134, 135, 136, 113, 114, 139, 42, 43, 44, 143,
2394 144, 47, 3, 4, 5, 6, 305, 4, 7, 8,
2395 150, 534, 152, 153, 313, 314, 35, 273, 37, 477,
2396 19, 20, 155, 22, 23, 24, 149, 150, 284, 152,
2397 155, 418, 149, 150, 4, 152, 42, 43, 44, 45,
2398 46, 47, 48, 22, 50, 301, 150, 149, 152, 153,
2399 341, 342, 343, 344, 345, 145, 146, 147, 83, 84,
2400 316, 317, 318, 354, 355, 356, 134, 135, 136, 153,
2401 150, 139, 152, 158, 153, 143, 144, 152, 377, 378,
2402 379, 42, 9, 44, 9, 488, 385, 9, 491, 492,
2403 493, 9, 0, 349, 9, 553, 395, 396, 556, 9,
2404 55, 158, 11, 359, 60, 61, 62, 63, 64, 65,
2405 18, 19, 20, 152, 22, 23, 24, 408, 409, 418,
2406 152, 152, 30, 31, 415, 152, 152, 22, 152, 152,
2407 152, 387, 388, 389, 390, 391, 149, 149, 394, 145,
2408 146, 147, 441, 51, 443, 152, 54, 446, 38, 549,
2409 58, 407, 38, 452, 453, 149, 149, 149, 149, 149,
2410 269, 270, 59, 272, 152, 152, 149, 149, 154, 569,
2411 38, 462, 463, 464, 465, 149, 149, 149, 469, 470,
2412 149, 480, 481, 149, 483, 484, 149, 149, 22, 149,
2413 489, 158, 149, 4, 153, 149, 305, 22, 17, 17,
2414 499, 457, 152, 149, 313, 314, 149, 4, 149, 149,
2415 501, 502, 149, 149, 149, 471, 149, 149, 152, 149,
2416 476, 520, 521, 149, 53, 149, 482, 158, 149, 22,
2417 529, 154, 488, 153, 0, 491, 492, 493, 149, 153,
2418 496, 153, 149, 149, 53, 475, 537, 17, 539, 540,
2419 153, 156, 18, 19, 20, 153, 22, 23, 24, 153,
2420 156, 153, 153, 4, 30, 31, 149, 566, 377, 378,
2421 379, 17, 17, 572, 573, 149, 385, 26, 27, 17,
2422 71, 17, 129, 129, 129, 51, 395, 396, 54, 247,
2423 544, 92, 58, 592, 593, 248, 552, 516, 597, 111,
2424 105, 600, 17, 7, 8, 89, 10, 11, 12, 13,
2425 14, 15, 16, 17, 544, 19, 20, 56, 22, 23,
2426 24, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2427 99, 235, 441, 496, 443, -1, 225, 446, 410, -1,
2428 -1, -1, -1, 452, 453, 49, -1, 96, 97, 98,
2429 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2430 109, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2431 -1, 480, 481, -1, 483, 484, -1, -1, -1, -1,
2432 489, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2433 499, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2434 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2435 -1, 520, 521, -1, -1, -1, -1, -1, -1, -1,
2436 529, -1, 3, 4, -1, -1, 7, 8, 9, -1,
2437 -1, -1, -1, -1, -1, -1, -1, -1, 19, 20,
2438 -1, 22, 23, 24, 25, 26, 27, 151, -1, -1,
2439 154, -1, -1, 157, -1, 159, 160, 566, -1, 40,
2440 41, -1, -1, 572, 573, -1, -1, -1, -1, -1,
2441 -1, -1, -1, -1, -1, -1, 57, -1, -1, -1,
2442 -1, -1, -1, 592, 593, -1, -1, -1, 597, -1,
2443 -1, 600, 73, 74, 75, 76, 77, 78, 79, 80,
2444 81, 82, 83, 84, 85, 86, 87, 88, 89, -1,
2445 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2446 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2447 -1, -1, -1, -1, 115, 116, 117, 118, 119, 120,
2448 121, 122, 123, 124, 125, 126, 127, -1, 129, -1,
2449 131, 132, 133, -1, -1, -1, -1, -1, 3, 4,
2450 -1, -1, 7, 8, 9, -1, -1, -1, -1, 150,
2451 -1, 152, -1, -1, 19, 20, 157, 22, 23, 24,
2452 25, 26, 27, -1, -1, 7, 8, -1, -1, -1,
2453 -1, -1, -1, -1, -1, 40, 41, 19, 20, -1,
2454 22, 23, 24, 25, -1, -1, -1, -1, -1, -1,
2455 -1, -1, 57, -1, -1, -1, -1, -1, 40, 41,
2456 -1, -1, -1, -1, -1, -1, -1, -1, 73, 74,
2457 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2458 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2459 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2460 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
2461 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2462 125, 126, 127, -1, 129, -1, 131, 132, 133, -1,
2463 -1, -1, -1, 115, 116, 117, 118, 119, 120, 121,
2464 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
2465 132, 133, 157, -1, -1, -1, -1, -1, 3, 4,
2466 -1, -1, -1, -1, 9, -1, -1, -1, 150, -1,
2467 152, -1, 154, -1, -1, 157, -1, 159, -1, 161,
2468 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2469 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2470 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2471 7, 8, 57, 10, 11, 12, 13, 14, 15, 16,
2472 17, -1, 19, 20, -1, 22, 23, 24, 73, 74,
2473 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2474 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2475 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
2476 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2477 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2478 125, 126, 127, -1, 129, -1, 131, 132, 133, -1,
2479 7, 8, 49, 10, 11, 12, 13, 14, 15, 16,
2480 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2481 7, 8, 157, 10, 11, 12, 13, 14, 15, 16,
2482 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2483 -1, -1, 49, 7, 8, -1, 10, 11, 12, 13,
2484 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2485 24, -1, 49, -1, 151, -1, -1, 154, -1, -1,
2486 157, -1, 159, 160, -1, 39, -1, -1, -1, -1,
2487 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
2488 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2489 24, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2490 157, -1, 159, 160, 7, 8, -1, 10, 11, 12,
2491 13, 14, 15, 16, 17, 49, 19, 20, -1, 22,
2492 23, 24, -1, -1, 121, -1, -1, -1, -1, -1,
2493 -1, -1, -1, -1, 151, -1, 39, 154, -1, -1,
2494 157, -1, 159, 160, -1, -1, 49, -1, -1, -1,
2495 -1, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2496 157, -1, 159, -1, -1, -1, -1, -1, -1, -1,
2497 -1, -1, -1, -1, -1, -1, -1, 151, -1, -1,
2498 154, -1, -1, 157, -1, 159, 7, 8, -1, 10,
2499 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2500 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2501 -1, -1, -1, -1, -1, -1, -1, 151, 39, -1,
2502 154, -1, 156, 157, -1, 159, 7, 8, 49, 10,
2503 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2504 -1, 22, 23, 24, -1, -1, -1, -1, 151, -1,
2505 -1, 154, -1, -1, 157, -1, 159, 7, 8, -1,
2506 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
2507 20, -1, 22, 23, 24, 7, 8, -1, 10, 11,
2508 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2509 22, 23, 24, -1, -1, -1, -1, 7, 8, 49,
2510 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2511 20, -1, 22, 23, 24, -1, -1, 49, -1, -1,
2512 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2513 151, -1, -1, 154, -1, -1, 157, -1, 159, 49,
2514 7, 8, -1, 10, 11, 12, 13, 14, 15, 16,
2515 17, -1, 19, 20, -1, 22, 23, 24, -1, -1,
2516 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2517 151, -1, -1, 154, -1, -1, 157, -1, 159, -1,
2518 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2519 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2520 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2521 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
2522 -1, -1, 154, -1, -1, 157, -1, 159, -1, -1,
2523 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2524 -1, 151, -1, -1, 154, -1, -1, 157, -1, 159,
2525 -1, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2526 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2527 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2528 -1, -1, -1, -1, 151, -1, -1, 154, -1, -1,
2529 157, -1, 159, 49, 7, 8, -1, 10, 11, 12,
2530 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2531 23, 24, 7, 8, -1, 10, 11, 12, 13, 14,
2532 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2533 36, -1, -1, -1, -1, -1, 49, -1, -1, -1,
2534 -1, -1, -1, -1, -1, -1, -1, -1, -1, 55,
2535 56, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2536 -1, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2537 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
2538 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
2539 -1, -1, -1, -1, -1, 151, -1, -1, 154, -1,
2540 -1, 157, -1, 159, 110, 111, 112, -1, -1, 115,
2541 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2542 126, 127, 128, 129, 130, 131, 132, 133, -1, -1,
2543 -1, -1, -1, -1, -1, -1, -1, -1, 151, -1,
2544 -1, 154, -1, -1, 157, -1, 159, -1, -1, -1,
2545 -1, -1, -1, -1, -1, -1, 151, -1, -1, 154,
2546 -1, -1, 157, -1, 159
2547};
2548
2549/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2550 symbol of state STATE-NUM. */
2551static const yytype_uint8 yystos[] =
2552{
2553 0, 19, 20, 22, 23, 24, 30, 31, 51, 54,
2554 58, 170, 172, 173, 174, 175, 206, 207, 208, 210,
2555 209, 52, 66, 215, 148, 57, 148, 18, 148, 42,
2556 43, 44, 45, 46, 47, 48, 50, 145, 146, 147,
2557 176, 177, 178, 0, 208, 46, 48, 179, 225, 42,
2558 43, 44, 47, 180, 222, 224, 231, 148, 148, 154,
2559 216, 22, 214, 7, 8, 10, 11, 12, 13, 14,
2560 15, 16, 17, 49, 151, 154, 157, 159, 170, 173,
2561 193, 194, 228, 178, 178, 35, 37, 204, 178, 178,
2562 21, 232, 233, 29, 160, 223, 232, 22, 22, 22,
2563 217, 152, 4, 4, 4, 159, 10, 160, 194, 199,
2564 150, 152, 204, 204, 42, 44, 181, 32, 33, 203,
2565 60, 61, 62, 63, 64, 65, 182, 220, 220, 172,
2566 236, 149, 156, 39, 194, 195, 197, 198, 155, 155,
2567 160, 199, 149, 160, 198, 203, 203, 10, 121, 194,
2568 196, 205, 11, 12, 13, 14, 15, 16, 168, 169,
2569 194, 200, 4, 196, 28, 159, 221, 36, 55, 56,
2570 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2571 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2572 87, 88, 89, 110, 111, 112, 115, 116, 117, 118,
2573 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2574 129, 130, 131, 132, 133, 163, 164, 165, 234, 240,
2575 241, 242, 243, 22, 184, 149, 153, 194, 194, 158,
2576 160, 194, 153, 200, 194, 152, 228, 26, 27, 3,
2577 4, 5, 6, 9, 25, 40, 41, 88, 89, 115,
2578 129, 131, 132, 133, 154, 157, 159, 161, 163, 164,
2579 165, 201, 228, 211, 173, 55, 10, 194, 230, 11,
2580 17, 11, 168, 182, 90, 91, 92, 93, 94, 95,
2581 96, 97, 98, 99, 166, 26, 27, 96, 97, 98,
2582 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2583 109, 167, 194, 194, 230, 194, 194, 237, 230, 230,
2584 230, 230, 230, 194, 194, 230, 182, 113, 114, 117,
2585 118, 134, 135, 137, 138, 140, 141, 142, 183, 39,
2586 195, 186, 156, 158, 158, 186, 212, 213, 205, 166,
2587 167, 152, 152, 152, 152, 152, 156, 200, 202, 159,
2588 202, 160, 202, 22, 152, 152, 152, 149, 191, 152,
2589 3, 4, 9, 25, 26, 27, 40, 41, 57, 157,
2590 201, 227, 228, 229, 229, 229, 229, 196, 194, 194,
2591 149, 188, 149, 188, 229, 154, 149, 149, 149, 149,
2592 149, 149, 229, 229, 38, 196, 194, 230, 134, 135,
2593 136, 139, 143, 144, 185, 191, 191, 38, 152, 152,
2594 200, 200, 200, 200, 200, 149, 156, 160, 194, 202,
2595 158, 160, 200, 200, 200, 34, 53, 189, 192, 39,
2596 194, 218, 219, 59, 226, 202, 149, 149, 229, 229,
2597 229, 11, 53, 11, 239, 229, 154, 230, 194, 230,
2598 230, 230, 149, 149, 194, 229, 229, 149, 194, 200,
2599 200, 239, 149, 149, 149, 149, 200, 158, 160, 149,
2600 149, 38, 22, 4, 191, 184, 149, 153, 22, 158,
2601 17, 17, 152, 149, 149, 229, 4, 229, 149, 149,
2602 229, 149, 149, 149, 229, 229, 152, 149, 188, 194,
2603 153, 149, 149, 153, 200, 200, 200, 200, 158, 200,
2604 200, 194, 170, 171, 39, 194, 186, 149, 229, 229,
2605 17, 194, 238, 229, 229, 188, 188, 230, 229, 149,
2606 230, 230, 230, 238, 229, 200, 200, 149, 153, 149,
2607 149, 153, 153, 153, 184, 189, 190, 22, 149, 154,
2608 229, 229, 149, 153, 156, 229, 153, 188, 153, 153,
2609 200, 200, 200, 171, 53, 187, 17, 156, 168, 235,
2610 184, 184, 17, 194, 186, 156, 186, 153, 153, 153,
2611 4, 229, 227, 156, 168, 229, 229, 38, 149, 227,
2612 184, 184, 17, 17, 149, 229, 229, 17, 71, 229,
2613 17, 229
2614};
David Greene9145dd22007-08-01 03:59:32 +00002615
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616#define yyerrok (yyerrstatus = 0)
2617#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002618#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002619#define YYEOF 0
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002620
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621#define YYACCEPT goto yyacceptlab
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002622#define YYABORT goto yyabortlab
2623#define YYERROR goto yyerrorlab
2624
2625
2626/* Like YYERROR except do call yyerror. This remains here temporarily
2627 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002629
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630#define YYFAIL goto yyerrlab
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002631
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002633
2634#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635do \
2636 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002637 { \
2638 yychar = (Token); \
2639 yylval = (Value); \
2640 yytoken = YYTRANSLATE (yychar); \
2641 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642 goto yybackup; \
2643 } \
2644 else \
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002645 { \
2646 yyerror (YY_("syntax error: cannot back up")); \
2647 YYERROR; \
2648 } \
2649while (YYID (0))
2650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651
2652#define YYTERROR 1
2653#define YYERRCODE 256
2654
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002655
2656/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2657 If N is 0, then set CURRENT to the empty location which ends
2658 the previous symbol: RHS[0] (always defined). */
2659
2660#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2661#ifndef YYLLOC_DEFAULT
2662# define YYLLOC_DEFAULT(Current, Rhs, N) \
2663 do \
2664 if (YYID (N)) \
2665 { \
2666 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2667 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2668 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2669 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2670 } \
2671 else \
2672 { \
2673 (Current).first_line = (Current).last_line = \
2674 YYRHSLOC (Rhs, 0).last_line; \
2675 (Current).first_column = (Current).last_column = \
2676 YYRHSLOC (Rhs, 0).last_column; \
2677 } \
2678 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002679#endif
2680
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002681
2682/* YY_LOCATION_PRINT -- Print the location on the stream.
2683 This macro was not mandated originally: define only if we know
2684 we won't break user code: when these are the locations we know. */
2685
2686#ifndef YY_LOCATION_PRINT
Nate Begeman4a365ad2007-11-15 21:15:26 +00002687# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002688# define YY_LOCATION_PRINT(File, Loc) \
2689 fprintf (File, "%d.%d-%d.%d", \
2690 (Loc).first_line, (Loc).first_column, \
2691 (Loc).last_line, (Loc).last_column)
2692# else
2693# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2694# endif
2695#endif
2696
2697
2698/* YYLEX -- calling `yylex' with the right arguments. */
2699
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700#ifdef YYLEX_PARAM
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002701# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002703# define YYLEX yylex ()
Dale Johannesen3afee192007-09-07 21:07:57 +00002704#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002705
2706/* Enable debugging if requested. */
2707#if YYDEBUG
2708
2709# ifndef YYFPRINTF
2710# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2711# define YYFPRINTF fprintf
2712# endif
2713
2714# define YYDPRINTF(Args) \
2715do { \
2716 if (yydebug) \
2717 YYFPRINTF Args; \
2718} while (YYID (0))
2719
2720# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2721do { \
2722 if (yydebug) \
2723 { \
2724 YYFPRINTF (stderr, "%s ", Title); \
2725 yy_symbol_print (stderr, \
2726 Type, Value); \
2727 YYFPRINTF (stderr, "\n"); \
2728 } \
2729} while (YYID (0))
2730
2731
2732/*--------------------------------.
2733| Print this symbol on YYOUTPUT. |
2734`--------------------------------*/
2735
2736/*ARGSUSED*/
2737#if (defined __STDC__ || defined __C99__FUNC__ \
2738 || defined __cplusplus || defined _MSC_VER)
2739static void
2740yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Dale Johannesen3afee192007-09-07 21:07:57 +00002741#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002742static void
2743yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2744 FILE *yyoutput;
2745 int yytype;
2746 YYSTYPE const * const yyvaluep;
Dale Johannesen3afee192007-09-07 21:07:57 +00002747#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002748{
2749 if (!yyvaluep)
2750 return;
2751# ifdef YYPRINT
2752 if (yytype < YYNTOKENS)
2753 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2754# else
2755 YYUSE (yyoutput);
2756# endif
2757 switch (yytype)
2758 {
2759 default:
2760 break;
2761 }
2762}
2763
2764
2765/*--------------------------------.
2766| Print this symbol on YYOUTPUT. |
2767`--------------------------------*/
2768
2769#if (defined __STDC__ || defined __C99__FUNC__ \
2770 || defined __cplusplus || defined _MSC_VER)
2771static void
2772yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2773#else
2774static void
2775yy_symbol_print (yyoutput, yytype, yyvaluep)
2776 FILE *yyoutput;
2777 int yytype;
2778 YYSTYPE const * const yyvaluep;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002779#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002780{
2781 if (yytype < YYNTOKENS)
2782 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2783 else
2784 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
David Greene48556392007-09-04 18:46:50 +00002785
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002786 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2787 YYFPRINTF (yyoutput, ")");
2788}
David Greene48556392007-09-04 18:46:50 +00002789
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002790/*------------------------------------------------------------------.
2791| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2792| TOP (included). |
2793`------------------------------------------------------------------*/
David Greene48556392007-09-04 18:46:50 +00002794
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002795#if (defined __STDC__ || defined __C99__FUNC__ \
2796 || defined __cplusplus || defined _MSC_VER)
2797static void
2798yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2799#else
2800static void
2801yy_stack_print (bottom, top)
2802 yytype_int16 *bottom;
2803 yytype_int16 *top;
Chris Lattnerbb856a32007-08-06 21:00:46 +00002804#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002805{
2806 YYFPRINTF (stderr, "Stack now");
2807 for (; bottom <= top; ++bottom)
2808 YYFPRINTF (stderr, " %d", *bottom);
2809 YYFPRINTF (stderr, "\n");
2810}
David Greene48556392007-09-04 18:46:50 +00002811
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002812# define YY_STACK_PRINT(Bottom, Top) \
2813do { \
2814 if (yydebug) \
2815 yy_stack_print ((Bottom), (Top)); \
2816} while (YYID (0))
David Greene48556392007-09-04 18:46:50 +00002817
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002818
2819/*------------------------------------------------.
2820| Report that the YYRULE is going to be reduced. |
2821`------------------------------------------------*/
2822
2823#if (defined __STDC__ || defined __C99__FUNC__ \
2824 || defined __cplusplus || defined _MSC_VER)
2825static void
2826yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2827#else
2828static void
2829yy_reduce_print (yyvsp, yyrule)
2830 YYSTYPE *yyvsp;
2831 int yyrule;
Dale Johannesenf325d9f2007-08-03 01:03:46 +00002832#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002833{
2834 int yynrhs = yyr2[yyrule];
2835 int yyi;
2836 unsigned long int yylno = yyrline[yyrule];
2837 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2838 yyrule - 1, yylno);
2839 /* The symbols being reduced. */
2840 for (yyi = 0; yyi < yynrhs; yyi++)
2841 {
2842 fprintf (stderr, " $%d = ", yyi + 1);
2843 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2844 &(yyvsp[(yyi + 1) - (yynrhs)])
2845 );
2846 fprintf (stderr, "\n");
2847 }
2848}
Chandler Carruth563d4a42007-08-04 01:56:21 +00002849
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002850# define YY_REDUCE_PRINT(Rule) \
2851do { \
2852 if (yydebug) \
2853 yy_reduce_print (yyvsp, Rule); \
2854} while (YYID (0))
Chandler Carruth563d4a42007-08-04 01:56:21 +00002855
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002856/* Nonzero means print parse trace. It is left uninitialized so that
2857 multiple parsers can coexist. */
2858int yydebug;
2859#else /* !YYDEBUG */
2860# define YYDPRINTF(Args)
2861# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2862# define YY_STACK_PRINT(Bottom, Top)
2863# define YY_REDUCE_PRINT(Rule)
2864#endif /* !YYDEBUG */
2865
2866
2867/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868#ifndef YYINITDEPTH
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002869# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870#endif
2871
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002872/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2873 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002875 Do not make this value too large; the results are undefined if
2876 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2877 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002878
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879#ifndef YYMAXDEPTH
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002880# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002882
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002885#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002887# ifndef yystrlen
2888# if defined __GLIBC__ && defined _STRING_H
2889# define yystrlen strlen
2890# else
2891/* Return the length of YYSTR. */
2892#if (defined __STDC__ || defined __C99__FUNC__ \
2893 || defined __cplusplus || defined _MSC_VER)
2894static YYSIZE_T
2895yystrlen (const char *yystr)
Dale Johannesen3afee192007-09-07 21:07:57 +00002896#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002897static YYSIZE_T
2898yystrlen (yystr)
2899 const char *yystr;
2900#endif
2901{
2902 YYSIZE_T yylen;
2903 for (yylen = 0; yystr[yylen]; yylen++)
2904 continue;
2905 return yylen;
2906}
2907# endif
2908# endif
2909
2910# ifndef yystpcpy
2911# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2912# define yystpcpy stpcpy
2913# else
2914/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2915 YYDEST. */
2916#if (defined __STDC__ || defined __C99__FUNC__ \
2917 || defined __cplusplus || defined _MSC_VER)
2918static char *
2919yystpcpy (char *yydest, const char *yysrc)
2920#else
2921static char *
2922yystpcpy (yydest, yysrc)
2923 char *yydest;
2924 const char *yysrc;
2925#endif
2926{
2927 char *yyd = yydest;
2928 const char *yys = yysrc;
2929
2930 while ((*yyd++ = *yys++) != '\0')
2931 continue;
2932
2933 return yyd - 1;
2934}
2935# endif
2936# endif
2937
2938# ifndef yytnamerr
2939/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2940 quotes and backslashes, so that it's suitable for yyerror. The
2941 heuristic is that double-quoting is unnecessary unless the string
2942 contains an apostrophe, a comma, or backslash (other than
2943 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2944 null, do not copy; instead, return the length of what the result
2945 would have been. */
2946static YYSIZE_T
2947yytnamerr (char *yyres, const char *yystr)
2948{
2949 if (*yystr == '"')
2950 {
2951 YYSIZE_T yyn = 0;
2952 char const *yyp = yystr;
2953
2954 for (;;)
2955 switch (*++yyp)
2956 {
2957 case '\'':
2958 case ',':
2959 goto do_not_strip_quotes;
2960
2961 case '\\':
2962 if (*++yyp != '\\')
2963 goto do_not_strip_quotes;
2964 /* Fall through. */
2965 default:
2966 if (yyres)
2967 yyres[yyn] = *yyp;
2968 yyn++;
2969 break;
2970
2971 case '"':
2972 if (yyres)
2973 yyres[yyn] = '\0';
2974 return yyn;
2975 }
2976 do_not_strip_quotes: ;
2977 }
2978
2979 if (! yyres)
2980 return yystrlen (yystr);
2981
2982 return yystpcpy (yyres, yystr) - yyres;
2983}
2984# endif
2985
2986/* Copy into YYRESULT an error message about the unexpected token
2987 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2988 including the terminating null byte. If YYRESULT is null, do not
2989 copy anything; just return the number of bytes that would be
2990 copied. As a special case, return 0 if an ordinary "syntax error"
2991 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2992 size calculation. */
2993static YYSIZE_T
2994yysyntax_error (char *yyresult, int yystate, int yychar)
2995{
2996 int yyn = yypact[yystate];
2997
2998 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2999 return 0;
3000 else
3001 {
3002 int yytype = YYTRANSLATE (yychar);
3003 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3004 YYSIZE_T yysize = yysize0;
3005 YYSIZE_T yysize1;
3006 int yysize_overflow = 0;
3007 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3008 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3009 int yyx;
3010
3011# if 0
3012 /* This is so xgettext sees the translatable formats that are
3013 constructed on the fly. */
3014 YY_("syntax error, unexpected %s");
3015 YY_("syntax error, unexpected %s, expecting %s");
3016 YY_("syntax error, unexpected %s, expecting %s or %s");
3017 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3018 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3019# endif
3020 char *yyfmt;
3021 char const *yyf;
3022 static char const yyunexpected[] = "syntax error, unexpected %s";
3023 static char const yyexpecting[] = ", expecting %s";
3024 static char const yyor[] = " or %s";
3025 char yyformat[sizeof yyunexpected
3026 + sizeof yyexpecting - 1
3027 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3028 * (sizeof yyor - 1))];
3029 char const *yyprefix = yyexpecting;
3030
3031 /* Start YYX at -YYN if negative to avoid negative indexes in
3032 YYCHECK. */
3033 int yyxbegin = yyn < 0 ? -yyn : 0;
3034
3035 /* Stay within bounds of both yycheck and yytname. */
3036 int yychecklim = YYLAST - yyn + 1;
3037 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3038 int yycount = 1;
3039
3040 yyarg[0] = yytname[yytype];
3041 yyfmt = yystpcpy (yyformat, yyunexpected);
3042
3043 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3044 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3045 {
3046 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3047 {
3048 yycount = 1;
3049 yysize = yysize0;
3050 yyformat[sizeof yyunexpected - 1] = '\0';
3051 break;
3052 }
3053 yyarg[yycount++] = yytname[yyx];
3054 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3055 yysize_overflow |= (yysize1 < yysize);
3056 yysize = yysize1;
3057 yyfmt = yystpcpy (yyfmt, yyprefix);
3058 yyprefix = yyor;
3059 }
3060
3061 yyf = YY_(yyformat);
3062 yysize1 = yysize + yystrlen (yyf);
3063 yysize_overflow |= (yysize1 < yysize);
3064 yysize = yysize1;
3065
3066 if (yysize_overflow)
3067 return YYSIZE_MAXIMUM;
3068
3069 if (yyresult)
3070 {
3071 /* Avoid sprintf, as that infringes on the user's name space.
3072 Don't have undefined behavior even if the translation
3073 produced a string with the wrong number of "%s"s. */
3074 char *yyp = yyresult;
3075 int yyi = 0;
3076 while ((*yyp = *yyf) != '\0')
3077 {
3078 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3079 {
3080 yyp += yytnamerr (yyp, yyarg[yyi++]);
3081 yyf += 2;
3082 }
3083 else
3084 {
3085 yyp++;
3086 yyf++;
3087 }
3088 }
3089 }
3090 return yysize;
3091 }
3092}
3093#endif /* YYERROR_VERBOSE */
3094
3095
3096/*-----------------------------------------------.
3097| Release the memory associated to this symbol. |
3098`-----------------------------------------------*/
3099
3100/*ARGSUSED*/
3101#if (defined __STDC__ || defined __C99__FUNC__ \
3102 || defined __cplusplus || defined _MSC_VER)
3103static void
3104yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3105#else
3106static void
3107yydestruct (yymsg, yytype, yyvaluep)
3108 const char *yymsg;
3109 int yytype;
3110 YYSTYPE *yyvaluep;
3111#endif
3112{
3113 YYUSE (yyvaluep);
3114
3115 if (!yymsg)
3116 yymsg = "Deleting";
3117 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3118
3119 switch (yytype)
3120 {
3121
3122 default:
3123 break;
3124 }
3125}
3126
3127
3128/* Prevent warnings from -Wmissing-prototypes. */
3129
3130#ifdef YYPARSE_PARAM
3131#if defined __STDC__ || defined __cplusplus
3132int yyparse (void *YYPARSE_PARAM);
3133#else
3134int yyparse ();
3135#endif
3136#else /* ! YYPARSE_PARAM */
3137#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003138int yyparse (void);
Dale Johannesen3afee192007-09-07 21:07:57 +00003139#else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003140int yyparse ();
Dale Johannesen3afee192007-09-07 21:07:57 +00003141#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003142#endif /* ! YYPARSE_PARAM */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003143
Chandler Carruth563d4a42007-08-04 01:56:21 +00003144
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003145
3146/* The look-ahead symbol. */
3147int yychar;
3148
3149/* The semantic value of the look-ahead symbol. */
3150YYSTYPE yylval;
3151
3152/* Number of syntax errors so far. */
3153int yynerrs;
3154
3155
3156
3157/*----------.
3158| yyparse. |
3159`----------*/
3160
3161#ifdef YYPARSE_PARAM
3162#if (defined __STDC__ || defined __C99__FUNC__ \
3163 || defined __cplusplus || defined _MSC_VER)
3164int
3165yyparse (void *YYPARSE_PARAM)
3166#else
3167int
3168yyparse (YYPARSE_PARAM)
3169 void *YYPARSE_PARAM;
3170#endif
3171#else /* ! YYPARSE_PARAM */
3172#if (defined __STDC__ || defined __C99__FUNC__ \
3173 || defined __cplusplus || defined _MSC_VER)
3174int
3175yyparse (void)
3176#else
3177int
3178yyparse ()
3179
Dale Johannesen3afee192007-09-07 21:07:57 +00003180#endif
3181#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003182{
3183
3184 int yystate;
3185 int yyn;
3186 int yyresult;
3187 /* Number of tokens to shift before error messages enabled. */
3188 int yyerrstatus;
3189 /* Look-ahead token as an internal (translated) token number. */
3190 int yytoken = 0;
3191#if YYERROR_VERBOSE
3192 /* Buffer for error messages, and its allocated size. */
3193 char yymsgbuf[128];
3194 char *yymsg = yymsgbuf;
3195 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Dale Johannesen3afee192007-09-07 21:07:57 +00003196#endif
Chandler Carruth563d4a42007-08-04 01:56:21 +00003197
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003198 /* Three stacks and their tools:
3199 `yyss': related to states,
3200 `yyvs': related to semantic values,
3201 `yyls': related to locations.
3202
3203 Refer to the stacks thru separate pointers, to allow yyoverflow
3204 to reallocate them elsewhere. */
3205
3206 /* The state stack. */
3207 yytype_int16 yyssa[YYINITDEPTH];
3208 yytype_int16 *yyss = yyssa;
3209 yytype_int16 *yyssp;
3210
3211 /* The semantic value stack. */
3212 YYSTYPE yyvsa[YYINITDEPTH];
3213 YYSTYPE *yyvs = yyvsa;
3214 YYSTYPE *yyvsp;
3215
3216
3217
3218#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3219
3220 YYSIZE_T yystacksize = YYINITDEPTH;
3221
3222 /* The variables used to return semantic value and location from the
3223 action routines. */
3224 YYSTYPE yyval;
3225
3226
3227 /* The number of symbols on the RHS of the reduced rule.
3228 Keep to zero when no symbol should be popped. */
3229 int yylen = 0;
3230
3231 YYDPRINTF ((stderr, "Starting parse\n"));
3232
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003233 yystate = 0;
3234 yyerrstatus = 0;
3235 yynerrs = 0;
3236 yychar = YYEMPTY; /* Cause a token to be read. */
3237
3238 /* Initialize stack pointers.
3239 Waste one element of value and location stack
3240 so that they stay on the same level as the state stack.
3241 The wasted elements are never initialized. */
3242
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003243 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003244 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003245
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003246 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003248/*------------------------------------------------------------.
3249| yynewstate -- Push a new state, which is found in yystate. |
3250`------------------------------------------------------------*/
3251 yynewstate:
3252 /* In all cases, when you get here, the value and location stacks
3253 have just been pushed. So pushing a state here evens the stacks. */
3254 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003256 yysetstate:
3257 *yyssp = yystate;
3258
3259 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003260 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003262 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003263
3264#ifdef yyoverflow
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003265 {
3266 /* Give user a chance to reallocate the stack. Use copies of
3267 these so that the &'s don't force the real ones into
3268 memory. */
3269 YYSTYPE *yyvs1 = yyvs;
3270 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003272
3273 /* Each stack pointer address is followed by the size of the
3274 data in use in that stack, in bytes. This used to be a
3275 conditional around just the two extra args, but that might
3276 be undefined if yyoverflow is a macro. */
3277 yyoverflow (YY_("memory exhausted"),
3278 &yyss1, yysize * sizeof (*yyssp),
3279 &yyvs1, yysize * sizeof (*yyvsp),
3280
3281 &yystacksize);
3282
3283 yyss = yyss1;
3284 yyvs = yyvs1;
3285 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286#else /* no yyoverflow */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003287# ifndef YYSTACK_RELOCATE
3288 goto yyexhaustedlab;
3289# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 /* Extend the stack our own way. */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003291 if (YYMAXDEPTH <= yystacksize)
3292 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 yystacksize *= 2;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003294 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 yystacksize = YYMAXDEPTH;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003296
3297 {
3298 yytype_int16 *yyss1 = yyss;
3299 union yyalloc *yyptr =
3300 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3301 if (! yyptr)
3302 goto yyexhaustedlab;
3303 YYSTACK_RELOCATE (yyss);
3304 YYSTACK_RELOCATE (yyvs);
3305
3306# undef YYSTACK_RELOCATE
3307 if (yyss1 != yyssa)
3308 YYSTACK_FREE (yyss1);
3309 }
3310# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311#endif /* no yyoverflow */
3312
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003313 yyssp = yyss + yysize - 1;
3314 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003316
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003317 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3318 (unsigned long int) yystacksize));
3319
3320 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321 YYABORT;
3322 }
3323
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003324 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325
3326 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003328/*-----------.
3329| yybackup. |
3330`-----------*/
3331yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003333 /* Do appropriate processing given the current state. Read a
3334 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003335
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003336 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 yyn = yypact[yystate];
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003338 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 goto yydefault;
3340
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003341 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003342
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003343 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344 if (yychar == YYEMPTY)
3345 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003346 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003347 yychar = YYLEX;
3348 }
3349
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003350 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003352 yychar = yytoken = YYEOF;
3353 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354 }
3355 else
3356 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003357 yytoken = YYTRANSLATE (yychar);
3358 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003359 }
3360
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003361 /* If the proper action on seeing token YYTOKEN is to reduce or to
3362 detect an error, take that action. */
3363 yyn += yytoken;
3364 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 yyn = yytable[yyn];
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003367 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003368 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003369 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 goto yyerrlab;
3371 yyn = -yyn;
3372 goto yyreduce;
3373 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374
3375 if (yyn == YYFINAL)
3376 YYACCEPT;
3377
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003378 /* Count tokens shifted since error; after three, turn off error
3379 status. */
3380 if (yyerrstatus)
3381 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003382
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003383 /* Shift the look-ahead token. */
3384 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003385
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003386 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387 if (yychar != YYEOF)
3388 yychar = YYEMPTY;
3389
Chris Lattnerbb856a32007-08-06 21:00:46 +00003390 yystate = yyn;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003391 *++yyvsp = yylval;
3392
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 goto yynewstate;
3394
Dale Johannesen3afee192007-09-07 21:07:57 +00003395
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003396/*-----------------------------------------------------------.
3397| yydefault -- do the default action for the current state. |
3398`-----------------------------------------------------------*/
3399yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003400 yyn = yydefact[yystate];
3401 if (yyn == 0)
3402 goto yyerrlab;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003403 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003405
3406/*-----------------------------.
3407| yyreduce -- Do a reduction. |
3408`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003409yyreduce:
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003410 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003411 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003413 /* If YYLEN is nonzero, implement the default value of the action:
3414 `$$ = $1'.
3415
3416 Otherwise, the following line sets YYVAL to garbage.
3417 This behavior is undocumented and Bison
3418 users should not rely upon it. Assigning to YYVAL
3419 unconditionally makes the parser a bit smaller, and it avoids a
3420 GCC warning that YYVAL may be used uninitialized. */
3421 yyval = yyvsp[1-yylen];
3422
3423
3424 YY_REDUCE_PRINT (yyn);
3425 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003426 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003427 case 29:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003428#line 1134 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003429 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3430 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003431
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003432 case 30:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003433#line 1134 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003434 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3435 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003437 case 31:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003438#line 1135 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003439 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3440 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003441
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003442 case 32:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003443#line 1135 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003444 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3445 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003446
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003447 case 33:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003448#line 1136 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003449 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3450 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003452 case 34:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003453#line 1136 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003454 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3455 break;
3456
3457 case 35:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003458#line 1137 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003459 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3460 break;
3461
3462 case 36:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003463#line 1137 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003464 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3465 break;
3466
3467 case 37:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003468#line 1138 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003469 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3470 break;
3471
3472 case 38:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003473#line 1138 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003474 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3475 break;
3476
3477 case 39:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003478#line 1142 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003479 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3480 break;
3481
3482 case 40:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003483#line 1142 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003484 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3485 break;
3486
3487 case 41:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003488#line 1143 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003489 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3490 break;
3491
3492 case 42:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003493#line 1143 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003494 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3495 break;
3496
3497 case 43:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003498#line 1144 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003499 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3500 break;
3501
3502 case 44:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003503#line 1144 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003504 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3505 break;
3506
3507 case 45:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003508#line 1145 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003509 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3510 break;
3511
3512 case 46:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003513#line 1145 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003514 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3515 break;
3516
3517 case 47:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003518#line 1146 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003519 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3520 break;
3521
3522 case 48:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003523#line 1146 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003524 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3525 break;
3526
3527 case 49:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003528#line 1147 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003529 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3530 break;
3531
3532 case 50:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003533#line 1147 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003534 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3535 break;
3536
3537 case 51:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003538#line 1148 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003539 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3540 break;
3541
3542 case 52:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003543#line 1148 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003544 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3545 break;
3546
3547 case 53:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003548#line 1149 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003549 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3550 break;
3551
3552 case 54:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003553#line 1150 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003554 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3555 break;
3556
3557 case 65:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003558#line 1159 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003559 { (yyval.StrVal) = 0; ;}
3560 break;
3561
3562 case 66:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003563#line 1163 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003564 {
3565 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003566 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003567 ;}
3568 break;
3569
3570 case 67:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003571#line 1167 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003572 {
3573 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003574 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003575 ;}
3576 break;
3577
3578 case 71:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003579#line 1175 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003580 {
3581 (yyval.StrVal) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003582 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003583 ;}
3584 break;
3585
3586 case 72:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003587#line 1180 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003588 {
3589 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003590 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003591 ;}
3592 break;
3593
3594 case 73:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003595#line 1186 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003596 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3597 break;
3598
3599 case 74:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003600#line 1187 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003601 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3602 break;
3603
3604 case 75:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003605#line 1188 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003606 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3607 break;
3608
3609 case 76:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003610#line 1189 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003611 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3612 break;
3613
3614 case 77:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003615#line 1190 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003616 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3617 break;
3618
3619 case 78:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003620#line 1194 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003621 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3622 break;
3623
3624 case 79:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003625#line 1195 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003626 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3627 break;
3628
3629 case 80:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003630#line 1196 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003631 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3632 break;
3633
3634 case 81:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003635#line 1200 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003636 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3637 break;
3638
3639 case 82:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003640#line 1201 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003641 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3642 break;
3643
3644 case 83:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003645#line 1202 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003646 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3647 break;
3648
3649 case 84:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003650#line 1203 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003651 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3652 break;
3653
3654 case 85:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003655#line 1207 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003656 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3657 break;
3658
3659 case 86:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003660#line 1208 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003661 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3662 break;
3663
3664 case 87:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003665#line 1209 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003666 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3667 break;
3668
3669 case 88:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003670#line 1213 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003671 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3672 break;
3673
3674 case 89:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003675#line 1214 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003676 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3677 break;
3678
3679 case 90:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003680#line 1215 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003681 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3682 break;
3683
3684 case 91:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003685#line 1216 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003686 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3687 break;
3688
3689 case 92:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003690#line 1217 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003691 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3692 break;
3693
3694 case 93:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003695#line 1221 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003696 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3697 break;
3698
3699 case 94:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003700#line 1222 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003701 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3702 break;
3703
3704 case 95:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003705#line 1223 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003706 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3707 break;
3708
3709 case 96:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003710#line 1226 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003711 { (yyval.UIntVal) = CallingConv::C; ;}
3712 break;
3713
3714 case 97:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003715#line 1227 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003716 { (yyval.UIntVal) = CallingConv::C; ;}
3717 break;
3718
3719 case 98:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003720#line 1228 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003721 { (yyval.UIntVal) = CallingConv::Fast; ;}
3722 break;
3723
3724 case 99:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003725#line 1229 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003726 { (yyval.UIntVal) = CallingConv::Cold; ;}
3727 break;
3728
3729 case 100:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003730#line 1230 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003731 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3732 break;
3733
3734 case 101:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003735#line 1231 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003736 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3737 break;
3738
3739 case 102:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003740#line 1232 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003741 {
3742 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003743 GEN_ERROR("Calling conv too large");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003744 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003745 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003746 ;}
3747 break;
3748
3749 case 103:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003750#line 1239 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003751 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3752 break;
3753
3754 case 104:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003755#line 1240 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003756 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3757 break;
3758
3759 case 105:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003760#line 1241 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003761 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3762 break;
3763
3764 case 106:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003765#line 1242 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003766 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3767 break;
3768
3769 case 107:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003770#line 1243 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003771 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3772 break;
3773
3774 case 108:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003775#line 1244 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003776 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3777 break;
3778
3779 case 109:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003780#line 1245 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003781 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3782 break;
3783
3784 case 110:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003785#line 1246 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003786 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3787 break;
3788
3789 case 111:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003790#line 1247 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003791 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3792 break;
3793
3794 case 112:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003795#line 1250 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003796 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3797 break;
3798
3799 case 113:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003800#line 1251 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003801 {
3802 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3803 ;}
3804 break;
3805
3806 case 114:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003807#line 1256 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003808 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3809 break;
3810
3811 case 115:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003812#line 1257 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003813 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3814 break;
3815
3816 case 116:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003817#line 1258 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003818 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3819 break;
3820
3821 case 117:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003822#line 1259 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003823 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3824 break;
3825
3826 case 118:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003827#line 1260 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003828 { (yyval.ParamAttrs) = ParamAttr::Pure; ;}
3829 break;
3830
3831 case 119:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003832#line 1261 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003833 { (yyval.ParamAttrs) = ParamAttr::Const; ;}
3834 break;
3835
3836 case 120:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003837#line 1264 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003838 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3839 break;
3840
3841 case 121:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003842#line 1265 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003843 {
3844 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3845 ;}
3846 break;
3847
3848 case 122:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003849#line 1272 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003850 { (yyval.UIntVal) = 0; ;}
3851 break;
3852
3853 case 123:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003854#line 1273 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003855 {
3856 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3857 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003858 GEN_ERROR("Alignment must be a power of two");
3859 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003860;}
3861 break;
3862
3863 case 124:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003864#line 1279 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003865 { (yyval.UIntVal) = 0; ;}
3866 break;
3867
3868 case 125:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003869#line 1280 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003870 {
3871 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3872 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003873 GEN_ERROR("Alignment must be a power of two");
3874 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003875;}
3876 break;
3877
3878 case 126:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003879#line 1288 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003880 {
3881 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3882 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003883 GEN_ERROR("Invalid character in section name");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003884 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003885 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003886;}
3887 break;
3888
3889 case 127:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003890#line 1296 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003891 { (yyval.StrVal) = 0; ;}
3892 break;
3893
3894 case 128:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003895#line 1297 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003896 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3897 break;
3898
3899 case 129:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003900#line 1302 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003901 {;}
3902 break;
3903
3904 case 130:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003905#line 1303 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003906 {;}
3907 break;
3908
3909 case 131:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003910#line 1304 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003911 {
3912 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3913 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003914 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003915 ;}
3916 break;
3917
3918 case 132:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003919#line 1309 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003920 {
3921 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003922 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003923 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003924 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003925 ;}
3926 break;
3927
3928 case 140:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003929#line 1325 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003930 {
3931 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003932 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003933 ;}
3934 break;
3935
3936 case 141:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003937#line 1329 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003938 {
3939 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003940 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003941 ;}
3942 break;
3943
3944 case 142:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003945#line 1333 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003946 { // Pointer type?
3947 if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948 GEN_ERROR("Cannot form a pointer to a basic block");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003949 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal))));
3950 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003951 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003952 ;}
3953 break;
3954
3955 case 143:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003956#line 1340 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003957 { // Named types are also simple types...
3958 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003959 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003960 (yyval.TypeVal) = new PATypeHolder(tmp);
3961 ;}
3962 break;
3963
3964 case 144:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003965#line 1345 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003966 { // Type UpReference
3967 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003968 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003969 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
3970 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003971 UR_OUT("New Upreference!\n");
3972 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003973 ;}
3974 break;
3975
3976 case 145:
Nate Begeman4a365ad2007-11-15 21:15:26 +00003977#line 1353 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003978 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003979 std::vector<const Type*> Params;
3980 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003981 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
3982 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003983 Attrs.push_back(X);
3984 }
3985 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003986 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003987 for (; I != E; ++I, ++index) {
3988 const Type *Ty = I->Ty->get();
3989 Params.push_back(Ty);
3990 if (Ty != Type::VoidTy)
3991 if (I->Attrs != ParamAttr::None) {
3992 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3993 Attrs.push_back(X);
3994 }
3995 }
3996 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3997 if (isVarArg) Params.pop_back();
3998
3999 ParamAttrsList *ActualAttrs = 0;
4000 if (!Attrs.empty())
4001 ActualAttrs = ParamAttrsList::get(Attrs);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004002 FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs);
4003 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4004 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4005 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004006 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004007 ;}
4008 break;
4009
4010 case 146:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004011#line 1383 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004012 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004013 std::vector<const Type*> Params;
4014 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004015 if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) {
4016 ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004017 Attrs.push_back(X);
4018 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004019 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004020 unsigned index = 1;
4021 for ( ; I != E; ++I, ++index) {
4022 const Type* Ty = I->Ty->get();
4023 Params.push_back(Ty);
4024 if (Ty != Type::VoidTy)
4025 if (I->Attrs != ParamAttr::None) {
4026 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
4027 Attrs.push_back(X);
4028 }
4029 }
4030 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4031 if (isVarArg) Params.pop_back();
4032
4033 ParamAttrsList *ActualAttrs = 0;
4034 if (!Attrs.empty())
4035 ActualAttrs = ParamAttrsList::get(Attrs);
4036
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004037 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs);
4038 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4039 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004040 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004041 ;}
4042 break;
4043
4044 case 147:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004045#line 1414 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004046 { // Sized array type?
4047 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4048 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004049 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004050 ;}
4051 break;
4052
4053 case 148:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004054#line 1419 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004055 { // Vector type?
4056 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4057 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004058 GEN_ERROR("Unsigned result not equal to signed result");
4059 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4060 GEN_ERROR("Element type of a VectorType must be primitive");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004061 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4062 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004063 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004064 ;}
4065 break;
4066
4067 case 149:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004068#line 1429 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004069 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004070 std::vector<const Type*> Elements;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004071 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4072 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004073 Elements.push_back(*I);
4074
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004075 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4076 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004077 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004078 ;}
4079 break;
4080
4081 case 150:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004082#line 1439 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004083 { // Empty structure type?
4084 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004085 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004086 ;}
4087 break;
4088
4089 case 151:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004090#line 1443 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004091 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004092 std::vector<const Type*> Elements;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004093 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4094 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004095 Elements.push_back(*I);
4096
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004097 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4098 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004099 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004100 ;}
4101 break;
4102
4103 case 152:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004104#line 1453 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004105 { // Empty structure type?
4106 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004107 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004108 ;}
4109 break;
4110
4111 case 153:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004112#line 1460 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004113 {
4114 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4115 (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs);
4116 ;}
4117 break;
4118
4119 case 154:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004120#line 1467 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004121 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004122 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004123 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4124 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004125 GEN_ERROR("LLVM functions cannot return aggregate types");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004126 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4127 ;}
4128 break;
4129
4130 case 155:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004131#line 1474 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004132 {
4133 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4134 ;}
4135 break;
4136
4137 case 156:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004138#line 1479 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004139 {
4140 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4141 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004142 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004143 ;}
4144 break;
4145
4146 case 157:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004147#line 1484 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004148 {
4149 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004150 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004151 ;}
4152 break;
4153
4154 case 159:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004155#line 1492 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004156 {
4157 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004158 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4159 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004160 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004161 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004162 ;}
4163 break;
4164
4165 case 160:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004166#line 1499 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004167 {
4168 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004169 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4170 TWA.Ty = new PATypeHolder(Type::VoidTy);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004171 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004172 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004173 ;}
4174 break;
4175
4176 case 161:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004177#line 1506 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004178 {
4179 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004180 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004181 ;}
4182 break;
4183
4184 case 162:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004185#line 1514 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004186 {
4187 (yyval.TypeList) = new std::list<PATypeHolder>();
4188 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4189 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004190 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004191 ;}
4192 break;
4193
4194 case 163:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004195#line 1520 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004196 {
4197 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4198 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004199 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004200 ;}
4201 break;
4202
4203 case 164:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004204#line 1532 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004205 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004206 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004207 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4208 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004209 if (ATy == 0)
4210 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004211 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004212 const Type *ETy = ATy->getElementType();
4213 int NumElements = ATy->getNumElements();
4214
4215 // Verify that we have the correct size...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004216 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004217 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004218 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004219 itostr(NumElements) + "");
4220
4221 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004222 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4223 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004224 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4225 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004226 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004227 }
4228
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004229 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4230 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004231 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004232 ;}
4233 break;
4234
4235 case 165:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004236#line 1560 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004237 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004238 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004239 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4240 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004241 if (ATy == 0)
4242 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004243 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004244
4245 int NumElements = ATy->getNumElements();
4246 if (NumElements != -1 && NumElements != 0)
4247 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4248 " arguments, but has size of " + itostr(NumElements) +"");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004249 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4250 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004251 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004252 ;}
4253 break;
4254
4255 case 166:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004256#line 1576 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004257 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004258 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004259 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4260 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004261 if (ATy == 0)
4262 GEN_ERROR("Cannot make array constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004263 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004264
4265 int NumElements = ATy->getNumElements();
4266 const Type *ETy = ATy->getElementType();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004267 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004268 GEN_ERROR("Can't build string constant of size " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004269 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270 " when array has size " + itostr(NumElements) + "");
4271 std::vector<Constant*> Vals;
4272 if (ETy == Type::Int8Ty) {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004273 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4274 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004275 } else {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004276 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4278 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004279 delete (yyvsp[(3) - (3)].StrVal);
4280 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4281 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004282 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004283 ;}
4284 break;
4285
4286 case 167:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004287#line 1603 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004288 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004289 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004290 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4291 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292 if (PTy == 0)
4293 GEN_ERROR("Cannot make packed constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004294 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 const Type *ETy = PTy->getElementType();
4296 int NumElements = PTy->getNumElements();
4297
4298 // Verify that we have the correct size...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004299 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004300 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004301 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004302 itostr(NumElements) + "");
4303
4304 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004305 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4306 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004307 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4308 ETy->getDescription() +"' as required!\nIt is of type '"+
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004309 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004310 }
4311
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004312 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4313 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004314 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004315 ;}
4316 break;
4317
4318 case 168:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004319#line 1631 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004320 {
4321 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004322 if (STy == 0)
4323 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004324 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004325
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004326 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004327 GEN_ERROR("Illegal number of initializers for structure type");
4328
4329 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004330 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4331 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004332 GEN_ERROR("Expected type '" +
4333 STy->getElementType(i)->getDescription() +
4334 "' for element #" + utostr(i) +
4335 " of structure initializer");
4336
4337 // Check to ensure that Type is not packed
4338 if (STy->isPacked())
4339 GEN_ERROR("Unpacked Initializer to vector type '" +
4340 STy->getDescription() + "'");
4341
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004342 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4343 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004344 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004345 ;}
4346 break;
4347
4348 case 169:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004349#line 1657 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004350 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004351 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004352 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4353 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004354 if (STy == 0)
4355 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004356 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004357
4358 if (STy->getNumContainedTypes() != 0)
4359 GEN_ERROR("Illegal number of initializers for structure type");
4360
4361 // Check to ensure that Type is not packed
4362 if (STy->isPacked())
4363 GEN_ERROR("Unpacked Initializer to vector type '" +
4364 STy->getDescription() + "'");
4365
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004366 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4367 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004369 ;}
4370 break;
4371
4372 case 170:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004373#line 1677 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004374 {
4375 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004376 if (STy == 0)
4377 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004378 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004379
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004380 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004381 GEN_ERROR("Illegal number of initializers for structure type");
4382
4383 // Check to ensure that constants are compatible with the type initializer!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004384 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4385 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386 GEN_ERROR("Expected type '" +
4387 STy->getElementType(i)->getDescription() +
4388 "' for element #" + utostr(i) +
4389 " of structure initializer");
4390
4391 // Check to ensure that Type is packed
4392 if (!STy->isPacked())
4393 GEN_ERROR("Vector initializer to non-vector type '" +
4394 STy->getDescription() + "'");
4395
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004396 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4397 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004398 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004399 ;}
4400 break;
4401
4402 case 171:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004403#line 1703 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004404 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004405 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004406 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4407 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004408 if (STy == 0)
4409 GEN_ERROR("Cannot make struct constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004410 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004411
4412 if (STy->getNumContainedTypes() != 0)
4413 GEN_ERROR("Illegal number of initializers for structure type");
4414
4415 // Check to ensure that Type is packed
4416 if (!STy->isPacked())
4417 GEN_ERROR("Vector initializer to non-vector type '" +
4418 STy->getDescription() + "'");
4419
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004420 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4421 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004422 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004423 ;}
4424 break;
4425
4426 case 172:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004427#line 1723 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004428 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004429 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004430 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4431 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004432 if (PTy == 0)
4433 GEN_ERROR("Cannot make null pointer constant with type: '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004434 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004435
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004436 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4437 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004438 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004439 ;}
4440 break;
4441
4442 case 173:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004443#line 1735 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004444 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004445 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004446 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4447 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4448 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004449 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004450 ;}
4451 break;
4452
4453 case 174:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004454#line 1742 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004455 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004456 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004457 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4458 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004459 if (Ty == 0)
4460 GEN_ERROR("Global const reference must be a pointer type");
4461
4462 // ConstExprs can exist in the body of a function, thus creating
4463 // GlobalValues whenever they refer to a variable. Because we are in
4464 // the context of a function, getExistingVal will search the functions
4465 // symbol table instead of the module symbol table for the global symbol,
4466 // which throws things all off. To get around this, we just tell
4467 // getExistingVal that we are at global scope here.
4468 //
4469 Function *SavedCurFn = CurFun.CurrentFunction;
4470 CurFun.CurrentFunction = 0;
4471
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004472 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004473 CHECK_FOR_ERROR
4474
4475 CurFun.CurrentFunction = SavedCurFn;
4476
4477 // If this is an initializer for a constant pointer, which is referencing a
4478 // (currently) undefined variable, create a stub now that shall be replaced
4479 // in the future with the right type of variable.
4480 //
4481 if (V == 0) {
4482 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4483 const PointerType *PT = cast<PointerType>(Ty);
4484
4485 // First check to see if the forward references value is already created!
4486 PerModuleInfo::GlobalRefsType::iterator I =
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004487 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004488
4489 if (I != CurModule.GlobalRefs.end()) {
4490 V = I->second; // Placeholder already exists, use it...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004491 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004492 } else {
4493 std::string Name;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004494 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4495 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4496 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004497 GEN_ERROR("Invalid reference to global");
4498
4499 // Create the forward referenced global.
4500 GlobalValue *GV;
4501 if (const FunctionType *FTy =
4502 dyn_cast<FunctionType>(PT->getElementType())) {
4503 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
4504 CurModule.CurrentModule);
4505 } else {
4506 GV = new GlobalVariable(PT->getElementType(), false,
4507 GlobalValue::ExternalWeakLinkage, 0,
4508 Name, CurModule.CurrentModule);
4509 }
4510
4511 // Keep track of the fact that we have a forward ref to recycle it
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004512 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004513 V = GV;
4514 }
4515 }
4516
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004517 (yyval.ConstVal) = cast<GlobalValue>(V);
4518 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004519 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004520 ;}
4521 break;
4522
4523 case 175:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004524#line 1808 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004525 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004526 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004527 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4528 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004529 GEN_ERROR("Mismatched types for constant expression: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004530 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4531 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4532 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004533 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004534 ;}
4535 break;
4536
4537 case 176:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004538#line 1818 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004539 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004540 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004541 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4542 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004543 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4544 GEN_ERROR("Cannot create a null initialized value of this type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004545 (yyval.ConstVal) = Constant::getNullValue(Ty);
4546 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004547 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004548 ;}
4549 break;
4550
4551 case 177:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004552#line 1828 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004553 { // integral constants
4554 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004555 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004556 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004557 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004558 ;}
4559 break;
4560
4561 case 178:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004562#line 1834 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004563 { // arbitrary precision integer constants
4564 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4565 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004566 GEN_ERROR("Constant value does not fit in type");
4567 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004568 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4569 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4570 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004571 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004572 ;}
4573 break;
4574
4575 case 179:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004576#line 1844 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004577 { // integral constants
4578 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004579 GEN_ERROR("Constant value doesn't fit in type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004580 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004581 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004582 ;}
4583 break;
4584
4585 case 180:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004586#line 1850 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004587 { // arbitrary precision integer constants
4588 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4589 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004590 GEN_ERROR("Constant value does not fit in type");
4591 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004592 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4593 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4594 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004595 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004596 ;}
4597 break;
4598
4599 case 181:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004600#line 1860 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004601 { // Boolean constants
4602 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4603 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004604 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004605 ;}
4606 break;
4607
4608 case 182:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004609#line 1865 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004610 { // Boolean constants
4611 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4612 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004613 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004614 ;}
4615 break;
4616
4617 case 183:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004618#line 1870 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004619 { // Floating point constants
4620 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004621 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004622 // Lexer has no type info, so builds all float and double FP constants
4623 // as double. Fix this here. Long double is done right.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004624 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4625 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4626 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal));
4627 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004628 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004629 ;}
4630 break;
4631
4632 case 184:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004633#line 1883 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004634 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004635 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004636 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4637 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4638 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4639 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004640 GEN_ERROR("invalid cast opcode for cast from '" +
4641 Val->getType()->getDescription() + "' to '" +
4642 DestTy->getDescription() + "'");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004643 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4644 delete (yyvsp[(5) - (6)].TypeVal);
4645 ;}
4646 break;
4647
4648 case 185:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004649#line 1895 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004650 {
4651 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004652 GEN_ERROR("GetElementPtr requires a pointer operand");
4653
4654 const Type *IdxTy =
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004655 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004656 true);
4657 if (!IdxTy)
4658 GEN_ERROR("Index list invalid for constant getelementptr");
4659
4660 SmallVector<Constant*, 8> IdxVec;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004661 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4662 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004663 IdxVec.push_back(C);
4664 else
4665 GEN_ERROR("Indices to constant getelementptr must be constants");
4666
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004667 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004668
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004669 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004670 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004671 ;}
4672 break;
4673
4674 case 186:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004675#line 1917 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004676 {
4677 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004678 GEN_ERROR("Select condition must be of boolean type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004679 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004680 GEN_ERROR("Select operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004681 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004682 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004683 ;}
4684 break;
4685
4686 case 187:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004687#line 1925 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004688 {
4689 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004690 GEN_ERROR("Binary operator types must match");
4691 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004692 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4693 ;}
4694 break;
4695
4696 case 188:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004697#line 1931 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004698 {
4699 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004700 GEN_ERROR("Logical operator types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004701 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4702 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4703 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004704 GEN_ERROR("Logical operator requires integral operands");
4705 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004706 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004707 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004708 ;}
4709 break;
4710
4711 case 189:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004712#line 1942 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004713 {
4714 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004715 GEN_ERROR("icmp operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004716 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4717 ;}
4718 break;
4719
4720 case 190:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004721#line 1947 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004722 {
4723 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004724 GEN_ERROR("fcmp operand types must match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004725 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4726 ;}
4727 break;
4728
4729 case 191:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004730#line 1952 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004731 {
4732 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004733 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004734 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004735 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004736 ;}
4737 break;
4738
4739 case 192:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004740#line 1958 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004741 {
4742 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004743 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004744 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004745 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004746 ;}
4747 break;
4748
4749 case 193:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004750#line 1964 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004751 {
4752 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004753 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004754 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004755 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004756 ;}
4757 break;
4758
4759 case 194:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004760#line 1973 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004761 {
4762 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004763 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004764 ;}
4765 break;
4766
4767 case 195:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004768#line 1977 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004769 {
4770 (yyval.ConstVector) = new std::vector<Constant*>();
4771 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004772 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004773 ;}
4774 break;
4775
4776 case 196:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004777#line 1985 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004778 { (yyval.BoolVal) = false; ;}
4779 break;
4780
4781 case 197:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004782#line 1985 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004783 { (yyval.BoolVal) = true; ;}
4784 break;
4785
4786 case 198:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004787#line 1988 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004788 { (yyval.BoolVal) = true; ;}
4789 break;
4790
4791 case 199:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004792#line 1988 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004793 { (yyval.BoolVal) = false; ;}
4794 break;
4795
4796 case 200:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004797#line 1991 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004798 {
4799 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4800 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00004801 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004802 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4803 if (!Aliasee)
4804 GEN_ERROR("Aliases can be created only to global values");
4805
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004806 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004807 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004808 delete (yyvsp[(1) - (2)].TypeVal);
4809 ;}
4810 break;
4811
4812 case 201:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004813#line 2003 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004814 {
4815 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4816 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4817 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004818 GEN_ERROR("invalid cast opcode for cast from '" +
4819 Val->getType()->getDescription() + "' to '" +
4820 DestTy->getDescription() + "'");
4821
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004822 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004823 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004824 delete (yyvsp[(5) - (6)].TypeVal);
4825 ;}
4826 break;
4827
4828 case 202:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004829#line 2024 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004830 {
4831 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer47470022007-07-31 14:41:17 +00004832 CurModule.ModuleDone();
4833 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004834 ;}
4835 break;
4836
4837 case 203:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004838#line 2029 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004839 {
4840 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004841 CurModule.ModuleDone();
4842 CHECK_FOR_ERROR;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004843 ;}
4844 break;
4845
4846 case 206:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004847#line 2042 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004848 { CurFun.isDeclare = false; ;}
4849 break;
4850
4851 case 207:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004852#line 2042 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004853 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004854 CurFun.FunctionDone();
4855 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004856 ;}
4857 break;
4858
4859 case 208:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004860#line 2046 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004861 { CurFun.isDeclare = true; ;}
4862 break;
4863
4864 case 209:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004865#line 2046 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004866 {
Reid Spencer47470022007-07-31 14:41:17 +00004867 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004868 ;}
4869 break;
4870
4871 case 210:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004872#line 2049 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004873 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004874 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004875 ;}
4876 break;
4877
4878 case 211:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004879#line 2052 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004880 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004881 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004882 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004883 // Eagerly resolve types. This is not an optimization, this is a
4884 // requirement that is due to the fact that we could have this:
4885 //
4886 // %list = type { %list * }
4887 // %list = type { %list * } ; repeated type decl
4888 //
4889 // If types are not resolved eagerly, then the two types will not be
4890 // determined to be the same type!
4891 //
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004892 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004893
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004894 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004895 CHECK_FOR_ERROR
4896 // If this is a named type that is not a redefinition, add it to the slot
4897 // table.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004898 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004899 }
4900
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004901 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004902 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004903 ;}
4904 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004905
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004906 case 212:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004907#line 2076 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004908 {
4909 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4910
4911 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004912 CHECK_FOR_ERROR
4913 // If this is a named type that is not a redefinition, add it to the slot
4914 // table.
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004915 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004916 }
4917 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004918 ;}
4919 break;
4920
4921 case 213:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004922#line 2087 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004923 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004924 /* "Externally Visible" Linkage */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004925 if ((yyvsp[(5) - (5)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004926 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004927 CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage,
4928 (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004929 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004930 ;}
4931 break;
4932
4933 case 214:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004934#line 2094 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004935 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004936 CurGV = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004937 ;}
4938 break;
4939
4940 case 215:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004941#line 2098 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004942 {
4943 if ((yyvsp[(6) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004944 GEN_ERROR("Global value initializer is not a constant");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004945 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004946 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004947 ;}
4948 break;
4949
4950 case 216:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004951#line 2103 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004952 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004953 CurGV = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004954 ;}
4955 break;
4956
4957 case 217:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004958#line 2107 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004959 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004960 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004961 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription());
4962 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), *(yyvsp[(6) - (6)].TypeVal), 0, (yyvsp[(4) - (6)].BoolVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004963 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004964 delete (yyvsp[(6) - (6)].TypeVal);
4965 ;}
4966 break;
4967
4968 case 218:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004969#line 2113 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004970 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004971 CurGV = 0;
4972 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004973 ;}
4974 break;
4975
4976 case 219:
Nate Begeman4a365ad2007-11-15 21:15:26 +00004977#line 2117 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004978 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004979 std::string Name;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004980 if ((yyvsp[(1) - (5)].StrVal)) {
4981 Name = *(yyvsp[(1) - (5)].StrVal);
4982 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004983 }
4984 if (Name.empty())
4985 GEN_ERROR("Alias name cannot be empty");
4986
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004987 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004988 if (Aliasee == 0)
4989 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
4990
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004991 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004992 CurModule.CurrentModule);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00004993 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004994 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00004995
4996
4997 // If there was a forward reference of this alias, resolve it now.
4998
4999 ValID ID;
5000 if (!Name.empty())
5001 ID = ValID::createGlobalName(Name);
5002 else
5003 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5004
5005 if (GlobalValue *FWGV =
5006 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5007 // Replace uses of the fwdref with the actual alias.
5008 FWGV->replaceAllUsesWith(GA);
5009 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5010 GV->eraseFromParent();
5011 else
5012 cast<Function>(FWGV)->eraseFromParent();
5013 }
5014 ID.destroy();
5015
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005016 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005017 ;}
5018 break;
5019
5020 case 220:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005021#line 2157 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005022 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005023 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005024 ;}
5025 break;
5026
5027 case 221:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005028#line 2160 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005029 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005030 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005031 ;}
5032 break;
5033
5034 case 222:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005035#line 2166 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005036 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005037 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5038 if (AsmSoFar.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005039 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005040 else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005041 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5042 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005043 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005044;}
5045 break;
5046
5047 case 223:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005048#line 2176 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005049 {
5050 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5051 delete (yyvsp[(3) - (3)].StrVal);
5052 ;}
5053 break;
5054
5055 case 224:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005056#line 2180 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005057 {
5058 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5059 delete (yyvsp[(3) - (3)].StrVal);
5060 ;}
5061 break;
5062
5063 case 226:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005064#line 2187 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005065 {
5066 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5067 delete (yyvsp[(3) - (3)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005068 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005069 ;}
5070 break;
5071
5072 case 227:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005073#line 2192 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005074 {
5075 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5076 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005077 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005078 ;}
5079 break;
5080
5081 case 228:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005082#line 2197 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005083 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005084 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005085 ;}
5086 break;
5087
5088 case 229:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005089#line 2206 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005090 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005091 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005092 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5093 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005094 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005095 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5096 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5097 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005098 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005099 ;}
5100 break;
5101
5102 case 230:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005103#line 2216 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005104 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005105 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005106 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5107 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005108 GEN_ERROR("void typed arguments are invalid");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005109 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5110 (yyval.ArgList) = new ArgListType;
5111 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005112 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005113 ;}
5114 break;
5115
5116 case 231:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005117#line 2227 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005118 {
5119 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005120 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005121 ;}
5122 break;
5123
5124 case 232:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005125#line 2231 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005126 {
5127 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005128 struct ArgListEntry E;
5129 E.Ty = new PATypeHolder(Type::VoidTy);
5130 E.Name = 0;
5131 E.Attrs = ParamAttr::None;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005132 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005133 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005134 ;}
5135 break;
5136
5137 case 233:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005138#line 2240 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005139 {
5140 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005141 struct ArgListEntry E;
5142 E.Ty = new PATypeHolder(Type::VoidTy);
5143 E.Name = 0;
5144 E.Attrs = ParamAttr::None;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005145 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005146 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005147 ;}
5148 break;
5149
5150 case 234:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005151#line 2249 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005152 {
5153 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005154 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005155 ;}
5156 break;
5157
5158 case 235:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005159#line 2255 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005160 {
5161 std::string FunctionName(*(yyvsp[(3) - (9)].StrVal));
5162 delete (yyvsp[(3) - (9)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005163
5164 // Check the function result for abstractness if this is a define. We should
5165 // have no abstract types at this point
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005166 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal)))
5167 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005168
5169 std::vector<const Type*> ParamTypeList;
5170 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005171 if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) {
5172 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005173 Attrs.push_back(PAWI);
5174 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005175 if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005176 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005177 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005178 const Type* Ty = I->Ty->get();
5179 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5180 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5181 ParamTypeList.push_back(Ty);
5182 if (Ty != Type::VoidTy)
5183 if (I->Attrs != ParamAttr::None) {
5184 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5185 Attrs.push_back(PAWI);
5186 }
5187 }
5188 }
5189
5190 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5191 if (isVarArg) ParamTypeList.pop_back();
5192
5193 ParamAttrsList *PAL = 0;
5194 if (!Attrs.empty())
5195 PAL = ParamAttrsList::get(Attrs);
5196
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005197 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 const PointerType *PFT = PointerType::get(FT);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005199 delete (yyvsp[(2) - (9)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005200
5201 ValID ID;
5202 if (!FunctionName.empty()) {
5203 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5204 } else {
5205 ID = ValID::createGlobalID(CurModule.Values.size());
5206 }
5207
5208 Function *Fn = 0;
5209 // See if this function was forward referenced. If so, recycle the object.
5210 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5211 // Move the function to the end of the list, from whereever it was
5212 // previously inserted.
5213 Fn = cast<Function>(FWRef);
5214 CurModule.CurrentModule->getFunctionList().remove(Fn);
5215 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5216 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5217 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
5218 if (Fn->getFunctionType() != FT) {
5219 // The existing function doesn't have the same type. This is an overload
5220 // error.
5221 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
5222 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5223 // Neither the existing or the current function is a declaration and they
5224 // have the same name and same type. Clearly this is a redefinition.
5225 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
5226 } if (Fn->isDeclaration()) {
5227 // Make sure to strip off any argument names so we can't get conflicts.
5228 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5229 AI != AE; ++AI)
5230 AI->setName("");
5231 }
5232 } else { // Not already defined?
5233 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5234 CurModule.CurrentModule);
5235
5236 InsertValue(Fn, CurModule.Values);
5237 }
5238
5239 CurFun.FunctionStart(Fn);
5240
5241 if (CurFun.isDeclare) {
5242 // If we have declaration, always overwrite linkage. This will allow us to
5243 // correctly handle cases, when pointer to function is passed as argument to
5244 // another function.
5245 Fn->setLinkage(CurFun.Linkage);
5246 Fn->setVisibility(CurFun.Visibility);
5247 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005248 Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal));
5249 Fn->setAlignment((yyvsp[(9) - (9)].UIntVal));
5250 if ((yyvsp[(8) - (9)].StrVal)) {
5251 Fn->setSection(*(yyvsp[(8) - (9)].StrVal));
5252 delete (yyvsp[(8) - (9)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005253 }
5254
5255 // Add all of the arguments we parsed to the function...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005256 if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005257 if (isVarArg) { // Nuke the last entry
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005258 assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005259 "Not a varargs marker!");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005260 delete (yyvsp[(5) - (9)].ArgList)->back().Ty;
5261 (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005262 }
5263 Function::arg_iterator ArgIt = Fn->arg_begin();
5264 Function::arg_iterator ArgEnd = Fn->arg_end();
5265 unsigned Idx = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005266 for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin();
5267 I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005268 delete I->Ty; // Delete the typeholder...
5269 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5270 CHECK_FOR_ERROR
5271 InsertValue(ArgIt);
5272 Idx++;
5273 }
5274
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005275 delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005276 }
5277 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005278;}
5279 break;
5280
5281 case 238:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005282#line 2377 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005283 {
5284 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005285
5286 // Make sure that we keep track of the linkage type even if there was a
5287 // previous "declare".
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005288 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5289 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5290;}
5291 break;
5292
5293 case 241:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005294#line 2388 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005295 {
5296 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005297 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005298;}
5299 break;
5300
5301 case 242:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005302#line 2393 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005303 {
5304 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5305 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5306 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005307 CurFun.FunctionDone();
5308 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005309 ;}
5310 break;
5311
5312 case 243:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005313#line 2405 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005314 {
5315 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005316 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005317 ;}
5318 break;
5319
5320 case 244:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005321#line 2409 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005322 {
5323 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005324 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005325 ;}
5326 break;
5327
5328 case 245:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005329#line 2414 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005330 { // A reference to a direct constant
5331 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005332 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005333 ;}
5334 break;
5335
5336 case 246:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005337#line 2418 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005338 {
5339 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005340 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005341 ;}
5342 break;
5343
5344 case 247:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005345#line 2422 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005346 { // Perhaps it's an FP constant?
5347 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005348 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005349 ;}
5350 break;
5351
5352 case 248:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005353#line 2426 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005354 {
5355 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005356 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005357 ;}
5358 break;
5359
5360 case 249:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005361#line 2430 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005362 {
5363 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005364 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005365 ;}
5366 break;
5367
5368 case 250:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005369#line 2434 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005370 {
5371 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005372 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005373 ;}
5374 break;
5375
5376 case 251:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005377#line 2438 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005378 {
5379 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005380 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005381 ;}
5382 break;
5383
5384 case 252:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005385#line 2442 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005386 { // A vector zero constant.
5387 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005388 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005389 ;}
5390 break;
5391
5392 case 253:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005393#line 2446 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005394 { // Nonempty unsized packed vector
5395 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5396 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005397
5398 VectorType* pt = VectorType::get(ETy, NumElements);
5399 PATypeHolder* PTy = new PATypeHolder(
5400 HandleUpRefs(
5401 VectorType::get(
5402 ETy,
5403 NumElements)
5404 )
5405 );
5406
5407 // Verify all elements are correct type!
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005408 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5409 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005410 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5411 ETy->getDescription() +"' as required!\nIt is of type '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005412 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005413 }
5414
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005415 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5416 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005417 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005418 ;}
5419 break;
5420
5421 case 254:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005422#line 2471 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005423 {
5424 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005425 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005426 ;}
5427 break;
5428
5429 case 255:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005430#line 2475 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005431 {
5432 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5433 delete (yyvsp[(3) - (5)].StrVal);
5434 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005435 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005436 ;}
5437 break;
5438
5439 case 256:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005440#line 2485 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005441 { // Is it an integer reference...?
5442 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005443 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005444 ;}
5445 break;
5446
5447 case 257:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005448#line 2489 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005449 {
5450 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005451 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005452 ;}
5453 break;
5454
5455 case 258:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005456#line 2493 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005457 { // Is it a named reference...?
5458 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5459 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005460 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005461 ;}
5462 break;
5463
5464 case 259:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005465#line 2498 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005466 { // Is it a named reference...?
5467 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5468 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005469 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005470 ;}
5471 break;
5472
5473 case 262:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005474#line 2511 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005475 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005476 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005477 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5478 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5479 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005480 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005481 ;}
5482 break;
5483
5484 case 263:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005485#line 2520 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005486 {
5487 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005488 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005489 ;}
5490 break;
5491
5492 case 264:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005493#line 2524 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005494 { // Do not allow functions with 0 basic blocks
5495 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005496 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005497 ;}
5498 break;
5499
5500 case 265:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005501#line 2533 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005502 {
5503 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005504 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005505 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5506 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5507 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005508 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005509 ;}
5510 break;
5511
5512 case 266:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005513#line 2542 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005514 {
5515 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005516 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5517 if (CI2->getParent() == 0)
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005518 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5519 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5520 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005521 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005522 ;}
5523 break;
5524
5525 case 267:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005526#line 2551 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005527 { // Empty space between instruction lists
5528 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005529 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005530 ;}
5531 break;
5532
5533 case 268:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005534#line 2555 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005535 { // Labelled (named) basic block
5536 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5537 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005538 CHECK_FOR_ERROR
5539
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005540 ;}
5541 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005542
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005543 case 269:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005544#line 2562 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005545 { // Return with a result...
5546 (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal));
5547 CHECK_FOR_ERROR
5548 ;}
5549 break;
5550
5551 case 270:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005552#line 2566 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005553 { // Return with no result...
5554 (yyval.TermInstVal) = new ReturnInst();
5555 CHECK_FOR_ERROR
5556 ;}
5557 break;
5558
5559 case 271:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005560#line 2570 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005561 { // Unconditional Branch...
5562 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5563 CHECK_FOR_ERROR
5564 (yyval.TermInstVal) = new BranchInst(tmpBB);
5565 ;}
5566 break;
5567
5568 case 272:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005569#line 2575 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005570 {
5571 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5572 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5573 CHECK_FOR_ERROR
5574 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5575 CHECK_FOR_ERROR
5576 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5577 CHECK_FOR_ERROR
5578 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5579 ;}
5580 break;
5581
5582 case 273:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005583#line 2585 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005584 {
5585 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5586 CHECK_FOR_ERROR
5587 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5588 CHECK_FOR_ERROR
5589 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5590 (yyval.TermInstVal) = S;
5591
5592 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5593 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005594 for (; I != E; ++I) {
5595 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5596 S->addCase(CI, I->second);
5597 else
5598 GEN_ERROR("Switch case is constant, but not a simple integer");
5599 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005600 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005601 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005602 ;}
5603 break;
5604
5605 case 274:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005606#line 2604 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005607 {
5608 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005609 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005610 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005611 CHECK_FOR_ERROR
5612 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005613 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005614 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005615 ;}
5616 break;
5617
5618 case 275:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005619#line 2614 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005620 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005621
5622 // Handle the short syntax
5623 const PointerType *PFTy = 0;
5624 const FunctionType *Ty = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005625 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005626 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5627 // Pull out the types of all of the arguments...
5628 std::vector<const Type*> ParamTypes;
5629 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005630 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5631 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005632 Attrs.push_back(PAWI);
5633 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005634 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005635 unsigned index = 1;
5636 for (; I != E; ++I, ++index) {
5637 const Type *Ty = I->Val->getType();
5638 if (Ty == Type::VoidTy)
5639 GEN_ERROR("Short call syntax cannot be used with varargs");
5640 ParamTypes.push_back(Ty);
5641 if (I->Attrs != ParamAttr::None) {
5642 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5643 Attrs.push_back(PAWI);
5644 }
5645 }
5646
5647 ParamAttrsList *PAL = 0;
5648 if (!Attrs.empty())
5649 PAL = ParamAttrsList::get(Attrs);
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005650 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005651 PFTy = PointerType::get(Ty);
5652 }
5653
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005654 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005655
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005656 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005657 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005658 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005659 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005660 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005661 CHECK_FOR_ERROR
5662
5663 // Check the arguments
5664 ValueList Args;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005665 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005666 // Make sure no arguments is a good thing!
5667 if (Ty->getNumParams() != 0)
5668 GEN_ERROR("No arguments passed to a function that "
5669 "expects arguments");
5670 } else { // Has arguments?
5671 // Loop through FunctionType's arguments and ensure they are specified
5672 // correctly!
5673 FunctionType::param_iterator I = Ty->param_begin();
5674 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005675 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005676
5677 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5678 if (ArgI->Val->getType() != *I)
5679 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5680 (*I)->getDescription() + "'");
5681 Args.push_back(ArgI->Val);
5682 }
5683
5684 if (Ty->isVarArg()) {
5685 if (I == E)
5686 for (; ArgI != ArgE; ++ArgI)
5687 Args.push_back(ArgI->Val); // push the remaining varargs
5688 } else if (I != E || ArgI != ArgE)
5689 GEN_ERROR("Invalid number of parameters detected");
5690 }
5691
5692 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00005693 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005694 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
5695 (yyval.TermInstVal) = II;
5696 delete (yyvsp[(6) - (14)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005697 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005698 ;}
5699 break;
5700
5701 case 276:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005702#line 2693 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005703 {
5704 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005705 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005706 ;}
5707 break;
5708
5709 case 277:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005710#line 2697 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005711 {
5712 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005713 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005714 ;}
5715 break;
5716
5717 case 278:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005718#line 2704 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005719 {
5720 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5721 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005722 CHECK_FOR_ERROR
5723 if (V == 0)
5724 GEN_ERROR("May only switch on a constant pool value");
5725
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005726 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005727 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005728 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5729 ;}
5730 break;
5731
5732 case 279:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005733#line 2715 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005734 {
5735 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5736 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005737 CHECK_FOR_ERROR
5738
5739 if (V == 0)
5740 GEN_ERROR("May only switch on a constant pool value");
5741
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005742 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005743 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005744 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5745 ;}
5746 break;
5747
5748 case 280:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005749#line 2728 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005750 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005751 // Is this definition named?? if so, assign the name...
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005752 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005753 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005754 InsertValue((yyvsp[(2) - (2)].InstVal));
5755 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005756 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005757 ;}
5758 break;
5759
5760 case 281:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005761#line 2738 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005762 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005763 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005764 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5765 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5766 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005767 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005768 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005769 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005770 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5771 delete (yyvsp[(1) - (6)].TypeVal);
5772 ;}
5773 break;
5774
5775 case 282:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005776#line 2749 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005777 {
5778 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5779 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005780 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005781 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005782 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005783 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5784 ;}
5785 break;
5786
5787 case 283:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005788#line 2759 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005789 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005790 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005791 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005792 // Used for call and invoke instructions
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005793 (yyval.ParamList) = new ParamList();
5794 ParamListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal));
5795 (yyval.ParamList)->push_back(E);
5796 delete (yyvsp[(1) - (3)].TypeVal);
5797 ;}
5798 break;
5799
5800 case 284:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005801#line 2768 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005802 {
Dale Johannesencfb19e62007-11-05 21:20:28 +00005803 // Labels are only valid in ASMs
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005804 (yyval.ParamList) = new ParamList();
5805 ParamListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getBBVal((yyvsp[(2) - (3)].ValIDVal));
5806 (yyval.ParamList)->push_back(E);
5807 ;}
5808 break;
5809
5810 case 285:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005811#line 2774 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005812 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005813 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005814 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5815 (yyval.ParamList) = (yyvsp[(1) - (5)].ParamList);
5816 ParamListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal));
5817 (yyval.ParamList)->push_back(E);
5818 delete (yyvsp[(3) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005819 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005820 ;}
5821 break;
5822
5823 case 286:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005824#line 2783 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005825 {
5826 (yyval.ParamList) = (yyvsp[(1) - (5)].ParamList);
5827 ParamListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getBBVal((yyvsp[(4) - (5)].ValIDVal));
5828 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00005829 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005830 ;}
5831 break;
5832
5833 case 287:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005834#line 2789 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005835 { (yyval.ParamList) = new ParamList(); ;}
5836 break;
5837
5838 case 288:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005839#line 2792 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005840 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5841 break;
5842
5843 case 289:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005844#line 2793 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005845 {
5846 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5847 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005848 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005849 ;}
5850 break;
5851
5852 case 290:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005853#line 2800 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005854 {
5855 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005856 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005857 ;}
5858 break;
5859
5860 case 291:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005861#line 2804 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005862 {
5863 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005864 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005865 ;}
5866 break;
5867
5868 case 292:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005869#line 2809 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005870 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005871 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005872 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5873 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5874 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005875 GEN_ERROR(
5876 "Arithmetic operator requires integer, FP, or packed operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005877 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005878 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005879 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005880 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005881 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5882 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005883 GEN_ERROR("binary operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005884 delete (yyvsp[(2) - (5)].TypeVal);
5885 ;}
5886 break;
5887
5888 case 293:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005889#line 2825 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005890 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005891 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005892 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5893 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
5894 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
5895 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005896 GEN_ERROR("Logical operator requires integral operands");
5897 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005898 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005899 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005900 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005901 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005902 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
5903 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005904 GEN_ERROR("binary operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005905 delete (yyvsp[(2) - (5)].TypeVal);
5906 ;}
5907 break;
5908
5909 case 294:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005910#line 2842 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005911 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005912 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005913 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5914 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005915 GEN_ERROR("Vector types not supported by icmp instruction");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005916 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005917 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005918 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005919 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005920 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
5921 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005922 GEN_ERROR("icmp operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005923 delete (yyvsp[(3) - (6)].TypeVal);
5924 ;}
5925 break;
5926
5927 case 295:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005928#line 2856 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005929 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005930 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005931 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5932 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005933 GEN_ERROR("Vector types not supported by fcmp instruction");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005934 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005935 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005936 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005937 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005938 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
5939 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005940 GEN_ERROR("fcmp operator returned null");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005941 delete (yyvsp[(3) - (6)].TypeVal);
5942 ;}
5943 break;
5944
5945 case 296:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005946#line 2870 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005947 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005948 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005949 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5950 Value* Val = (yyvsp[(2) - (4)].ValueVal);
5951 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
5952 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005953 GEN_ERROR("invalid cast opcode for cast from '" +
5954 Val->getType()->getDescription() + "' to '" +
5955 DestTy->getDescription() + "'");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005956 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
5957 delete (yyvsp[(4) - (4)].TypeVal);
5958 ;}
5959 break;
5960
5961 case 297:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005962#line 2882 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005963 {
5964 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005965 GEN_ERROR("select condition must be boolean");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005966 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005967 GEN_ERROR("select value types should match");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005968 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005969 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005970 ;}
5971 break;
5972
5973 case 298:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005974#line 2890 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005975 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005976 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005977 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
5978 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
5979 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005980 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005981 ;}
5982 break;
5983
5984 case 299:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005985#line 2897 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005986 {
5987 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005988 GEN_ERROR("Invalid extractelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005989 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005990 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005991 ;}
5992 break;
5993
5994 case 300:
Nate Begeman4a365ad2007-11-15 21:15:26 +00005995#line 2903 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005996 {
5997 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005998 GEN_ERROR("Invalid insertelement operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00005999 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006000 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006001 ;}
6002 break;
6003
6004 case 301:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006005#line 2909 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006006 {
6007 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006008 GEN_ERROR("Invalid shufflevector operands");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006009 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006010 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006011 ;}
6012 break;
6013
6014 case 302:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006015#line 2915 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006016 {
6017 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006018 if (!Ty->isFirstClassType())
6019 GEN_ERROR("PHI node operands must be of first class type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006020 (yyval.InstVal) = new PHINode(Ty);
6021 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6022 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6023 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006024 GEN_ERROR("All elements of a PHI node must be of the same type");
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006025 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6026 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006027 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006028 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006029 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006030 ;}
6031 break;
6032
6033 case 303:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006034#line 2931 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006035 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006036
6037 // Handle the short syntax
6038 const PointerType *PFTy = 0;
6039 const FunctionType *Ty = 0;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006040 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006041 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6042 // Pull out the types of all of the arguments...
6043 std::vector<const Type*> ParamTypes;
6044 ParamAttrsVector Attrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006045 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
6046 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006047 Attrs.push_back(PAWI);
6048 }
6049 unsigned index = 1;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006050 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006051 for (; I != E; ++I, ++index) {
6052 const Type *Ty = I->Val->getType();
6053 if (Ty == Type::VoidTy)
6054 GEN_ERROR("Short call syntax cannot be used with varargs");
6055 ParamTypes.push_back(Ty);
6056 if (I->Attrs != ParamAttr::None) {
6057 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
6058 Attrs.push_back(PAWI);
6059 }
6060 }
6061
6062 ParamAttrsList *PAL = 0;
6063 if (!Attrs.empty())
6064 PAL = ParamAttrsList::get(Attrs);
6065
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006066 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006067 PFTy = PointerType::get(Ty);
6068 }
6069
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006070 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006071 CHECK_FOR_ERROR
6072
6073 // Check for call to invalid intrinsic to avoid crashing later.
6074 if (Function *theF = dyn_cast<Function>(V)) {
6075 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6076 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6077 !theF->getIntrinsicID(true))
6078 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6079 theF->getName() + "'");
6080 }
6081
6082 // Check the arguments
6083 ValueList Args;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006084 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006085 // Make sure no arguments is a good thing!
6086 if (Ty->getNumParams() != 0)
6087 GEN_ERROR("No arguments passed to a function that "
6088 "expects arguments");
6089 } else { // Has arguments?
6090 // Loop through FunctionType's arguments and ensure they are specified
6091 // correctly!
6092 //
6093 FunctionType::param_iterator I = Ty->param_begin();
6094 FunctionType::param_iterator E = Ty->param_end();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006095 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006096
6097 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
6098 if (ArgI->Val->getType() != *I)
6099 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6100 (*I)->getDescription() + "'");
6101 Args.push_back(ArgI->Val);
6102 }
6103 if (Ty->isVarArg()) {
6104 if (I == E)
6105 for (; ArgI != ArgE; ++ArgI)
6106 Args.push_back(ArgI->Val); // push the remaining varargs
6107 } else if (I != E || ArgI != ArgE)
6108 GEN_ERROR("Invalid number of parameters detected");
6109 }
6110 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00006111 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006112 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6113 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
6114 (yyval.InstVal) = CI;
6115 delete (yyvsp[(6) - (8)].ParamList);
6116 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006117 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006118 ;}
6119 break;
6120
6121 case 304:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006122#line 3015 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006123 {
6124 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006125 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006126 ;}
6127 break;
6128
6129 case 305:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006130#line 3020 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006131 {
6132 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006133 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006134 ;}
6135 break;
6136
6137 case 306:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006138#line 3024 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006139 {
6140 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006141 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006142 ;}
6143 break;
6144
6145 case 307:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006146#line 3031 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006147 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006148 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006149 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6150 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6151 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006152 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006153 ;}
6154 break;
6155
6156 case 308:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006157#line 3038 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006158 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006159 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006160 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6161 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006162 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006163 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6164 delete (yyvsp[(2) - (6)].TypeVal);
6165 ;}
6166 break;
6167
6168 case 309:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006169#line 3046 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006170 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006171 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006172 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6173 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6174 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006175 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006176 ;}
6177 break;
6178
6179 case 310:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006180#line 3053 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006181 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006182 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006183 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6184 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006185 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006186 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6187 delete (yyvsp[(2) - (6)].TypeVal);
6188 ;}
6189 break;
6190
6191 case 311:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006192#line 3061 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006193 {
6194 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006195 GEN_ERROR("Trying to free nonpointer type " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006196 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6197 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006198 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006199 ;}
6200 break;
6201
6202 case 312:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006203#line 3069 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006204 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006205 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006206 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6207 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006208 GEN_ERROR("Can't load from nonpointer type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006209 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6210 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006211 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006212 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6213 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006214 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006215 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6216 delete (yyvsp[(3) - (5)].TypeVal);
6217 ;}
6218 break;
6219
6220 case 313:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006221#line 3083 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006222 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006223 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006224 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6225 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006226 if (!PT)
6227 GEN_ERROR("Can't store to a nonpointer type: " +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006228 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006229 const Type *ElTy = PT->getElementType();
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006230 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6231 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006232 "' into space of type '" + ElTy->getDescription() + "'");
6233
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006234 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006235 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006236 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6237 delete (yyvsp[(5) - (7)].TypeVal);
6238 ;}
6239 break;
6240
6241 case 314:
Nate Begeman4a365ad2007-11-15 21:15:26 +00006242#line 3100 "/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006243 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006244 if (!UpRefs.empty())
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006245 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6246 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006247 GEN_ERROR("getelementptr insn requires pointer operand");
6248
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006249 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 +00006250 GEN_ERROR("Invalid getelementptr indices for type '" +
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006251 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6252 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006253 CHECK_FOR_ERROR
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006254 (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6255 delete (yyvsp[(2) - (4)].TypeVal);
6256 delete (yyvsp[(4) - (4)].ValueList);
6257 ;}
6258 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006259
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006260
6261/* Line 1267 of yacc.c. */
Nate Begeman4a365ad2007-11-15 21:15:26 +00006262#line 6263 "llvmAsmParser.tab.c"
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006263 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00006264 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006265 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6266
6267 YYPOPSTACK (yylen);
6268 yylen = 0;
6269 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006270
6271 *++yyvsp = yyval;
6272
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006273
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006274 /* Now `shift' the result of the reduction. Determine what state
6275 that goes to, based on the state we popped back to and the rule
6276 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006277
6278 yyn = yyr1[yyn];
6279
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006280 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6281 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006282 yystate = yytable[yystate];
6283 else
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006284 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006285
6286 goto yynewstate;
6287
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006288
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006289/*------------------------------------.
6290| yyerrlab -- here on detecting error |
6291`------------------------------------*/
6292yyerrlab:
6293 /* If not already recovering from an error, report this error. */
6294 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006295 {
6296 ++yynerrs;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006297#if ! YYERROR_VERBOSE
6298 yyerror (YY_("syntax error"));
6299#else
6300 {
6301 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6302 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6303 {
6304 YYSIZE_T yyalloc = 2 * yysize;
6305 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6306 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6307 if (yymsg != yymsgbuf)
6308 YYSTACK_FREE (yymsg);
6309 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6310 if (yymsg)
6311 yymsg_alloc = yyalloc;
6312 else
6313 {
6314 yymsg = yymsgbuf;
6315 yymsg_alloc = sizeof yymsgbuf;
6316 }
6317 }
Dale Johannesen3afee192007-09-07 21:07:57 +00006318
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006319 if (0 < yysize && yysize <= yymsg_alloc)
6320 {
6321 (void) yysyntax_error (yymsg, yystate, yychar);
6322 yyerror (yymsg);
6323 }
6324 else
6325 {
6326 yyerror (YY_("syntax error"));
6327 if (yysize != 0)
6328 goto yyexhaustedlab;
6329 }
6330 }
6331#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006332 }
6333
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006334
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006335
6336 if (yyerrstatus == 3)
6337 {
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006338 /* If just tried and failed to reuse look-ahead token after an
6339 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006340
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006341 if (yychar <= YYEOF)
6342 {
6343 /* Return failure if at end of input. */
6344 if (yychar == YYEOF)
6345 YYABORT;
6346 }
6347 else
6348 {
6349 yydestruct ("Error: discarding",
6350 yytoken, &yylval);
6351 yychar = YYEMPTY;
6352 }
6353 }
6354
6355 /* Else will try to reuse look-ahead token after shifting the error
6356 token. */
6357 goto yyerrlab1;
6358
6359
6360/*---------------------------------------------------.
6361| yyerrorlab -- error raised explicitly by YYERROR. |
6362`---------------------------------------------------*/
6363yyerrorlab:
6364
6365 /* Pacify compilers like GCC when the user code never invokes
6366 YYERROR and the label yyerrorlab therefore never appears in user
6367 code. */
6368 if (/*CONSTCOND*/ 0)
6369 goto yyerrorlab;
6370
6371 /* Do not reclaim the symbols of the rule which action triggered
6372 this YYERROR. */
6373 YYPOPSTACK (yylen);
6374 yylen = 0;
6375 YY_STACK_PRINT (yyss, yyssp);
6376 yystate = *yyssp;
6377 goto yyerrlab1;
6378
6379
6380/*-------------------------------------------------------------.
6381| yyerrlab1 -- common code for both syntax error and YYERROR. |
6382`-------------------------------------------------------------*/
6383yyerrlab1:
6384 yyerrstatus = 3; /* Each real token shifted decrements this. */
6385
6386 for (;;)
6387 {
6388 yyn = yypact[yystate];
6389 if (yyn != YYPACT_NINF)
6390 {
6391 yyn += YYTERROR;
6392 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6393 {
6394 yyn = yytable[yyn];
6395 if (0 < yyn)
6396 break;
6397 }
6398 }
6399
6400 /* Pop the current state because it cannot handle the error token. */
6401 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006402 YYABORT;
6403
Dale Johannesen3afee192007-09-07 21:07:57 +00006404
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006405 yydestruct ("Error: popping",
6406 yystos[yystate], yyvsp);
6407 YYPOPSTACK (1);
6408 yystate = *yyssp;
6409 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006410 }
6411
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006412 if (yyn == YYFINAL)
6413 YYACCEPT;
6414
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006415 *++yyvsp = yylval;
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006416
6417
6418 /* Shift the error token. */
6419 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006420
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006421 yystate = yyn;
6422 goto yynewstate;
6423
David Greene48556392007-09-04 18:46:50 +00006424
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006425/*-------------------------------------.
6426| yyacceptlab -- YYACCEPT comes here. |
6427`-------------------------------------*/
6428yyacceptlab:
6429 yyresult = 0;
6430 goto yyreturn;
6431
6432/*-----------------------------------.
6433| yyabortlab -- YYABORT comes here. |
6434`-----------------------------------*/
6435yyabortlab:
6436 yyresult = 1;
6437 goto yyreturn;
6438
6439#ifndef yyoverflow
6440/*-------------------------------------------------.
6441| yyexhaustedlab -- memory exhaustion comes here. |
6442`-------------------------------------------------*/
6443yyexhaustedlab:
6444 yyerror (YY_("memory exhausted"));
6445 yyresult = 2;
6446 /* Fall through. */
David Greene48556392007-09-04 18:46:50 +00006447#endif
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006448
6449yyreturn:
6450 if (yychar != YYEOF && yychar != YYEMPTY)
6451 yydestruct ("Cleanup: discarding lookahead",
6452 yytoken, &yylval);
6453 /* Do not reclaim the symbols of the rule which action triggered
6454 this YYABORT or YYACCEPT. */
6455 YYPOPSTACK (yylen);
6456 YY_STACK_PRINT (yyss, yyssp);
6457 while (yyssp != yyss)
6458 {
6459 yydestruct ("Cleanup: popping",
6460 yystos[*yyssp], yyvsp);
6461 YYPOPSTACK (1);
Dale Johannesen3afee192007-09-07 21:07:57 +00006462 }
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006463#ifndef yyoverflow
6464 if (yyss != yyssa)
6465 YYSTACK_FREE (yyss);
6466#endif
6467#if YYERROR_VERBOSE
6468 if (yymsg != yymsgbuf)
6469 YYSTACK_FREE (yymsg);
6470#endif
6471 /* Make sure YYID is used. */
6472 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006473}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006474
6475
Nate Begeman4a365ad2007-11-15 21:15:26 +00006476#line 3117 "/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006477
6478
6479// common code from the two 'RunVMAsmParser' functions
6480static Module* RunParser(Module * M) {
6481
6482 llvmAsmlineno = 1; // Reset the current line number...
6483 CurModule.CurrentModule = M;
6484#if YYDEBUG
6485 yydebug = Debug;
6486#endif
6487
6488 // Check to make sure the parser succeeded
6489 if (yyparse()) {
6490 if (ParserResult)
6491 delete ParserResult;
6492 return 0;
6493 }
6494
6495 // Emit an error if there are any unresolved types left.
6496 if (!CurModule.LateResolveTypes.empty()) {
6497 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6498 if (DID.Type == ValID::LocalName) {
6499 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6500 } else {
6501 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6502 }
6503 if (ParserResult)
6504 delete ParserResult;
6505 return 0;
6506 }
6507
6508 // Emit an error if there are any unresolved values left.
6509 if (!CurModule.LateResolveValues.empty()) {
6510 Value *V = CurModule.LateResolveValues.back();
6511 std::map<Value*, std::pair<ValID, int> >::iterator I =
6512 CurModule.PlaceHolderInfo.find(V);
6513
6514 if (I != CurModule.PlaceHolderInfo.end()) {
6515 ValID &DID = I->second.first;
6516 if (DID.Type == ValID::LocalName) {
6517 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6518 } else {
6519 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6520 }
6521 if (ParserResult)
6522 delete ParserResult;
6523 return 0;
6524 }
6525 }
6526
6527 // Check to make sure that parsing produced a result
6528 if (!ParserResult)
6529 return 0;
6530
6531 // Reset ParserResult variable while saving its value for the result.
6532 Module *Result = ParserResult;
6533 ParserResult = 0;
6534
6535 return Result;
6536}
6537
6538void llvm::GenerateError(const std::string &message, int LineNo) {
6539 if (LineNo == -1) LineNo = llvmAsmlineno;
6540 // TODO: column number in exception
6541 if (TheParseError)
6542 TheParseError->setError(CurFilename, message, LineNo);
6543 TriggerError = 1;
6544}
6545
6546int yyerror(const char *ErrorMsg) {
6547 std::string where
6548 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6549 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
6550 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6551 if (yychar != YYEMPTY && yychar != 0)
6552 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6553 "'";
6554 GenerateError(errMsg);
6555 return 0;
6556}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00006557