blob: 6d924c4a7e8275e87ccf801dbf80bcdc546d04d6 [file] [log] [blame]
Dan Gohman54392c12008-04-19 00:24:39 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Dan Gohman54392c12008-04-19 00:24:39 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Dan Gohman54392c12008-04-19 00:24:39 +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
Dan Gohman54392c12008-04-19 00:24:39 +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
Dan Gohman54392c12008-04-19 00:24:39 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Dan Gohman54392c12008-04-19 00:24:39 +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
Dan Gohman54392c12008-04-19 00:24:39 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 ADDRSPACE = 309,
129 DEPLIBS = 310,
130 CALL = 311,
131 TAIL = 312,
132 ASM_TOK = 313,
133 MODULE = 314,
134 SIDEEFFECT = 315,
135 CC_TOK = 316,
136 CCC_TOK = 317,
137 FASTCC_TOK = 318,
138 COLDCC_TOK = 319,
139 X86_STDCALLCC_TOK = 320,
140 X86_FASTCALLCC_TOK = 321,
141 DATALAYOUT = 322,
Chris Lattnere7e9b602008-05-04 17:18:47 +0000142 RET = 323,
143 BR = 324,
144 SWITCH = 325,
145 INVOKE = 326,
146 UNWIND = 327,
147 UNREACHABLE = 328,
148 ADD = 329,
149 SUB = 330,
150 MUL = 331,
151 UDIV = 332,
152 SDIV = 333,
153 FDIV = 334,
154 UREM = 335,
155 SREM = 336,
156 FREM = 337,
157 AND = 338,
158 OR = 339,
159 XOR = 340,
160 SHL = 341,
161 LSHR = 342,
162 ASHR = 343,
163 ICMP = 344,
164 FCMP = 345,
165 EQ = 346,
166 NE = 347,
167 SLT = 348,
168 SGT = 349,
169 SLE = 350,
170 SGE = 351,
171 ULT = 352,
172 UGT = 353,
173 ULE = 354,
174 UGE = 355,
175 OEQ = 356,
176 ONE = 357,
177 OLT = 358,
178 OGT = 359,
179 OLE = 360,
180 OGE = 361,
181 ORD = 362,
182 UNO = 363,
183 UEQ = 364,
184 UNE = 365,
185 MALLOC = 366,
186 ALLOCA = 367,
187 FREE = 368,
188 LOAD = 369,
189 STORE = 370,
190 GETELEMENTPTR = 371,
191 TRUNC = 372,
192 ZEXT = 373,
193 SEXT = 374,
194 FPTRUNC = 375,
195 FPEXT = 376,
196 BITCAST = 377,
197 UITOFP = 378,
198 SITOFP = 379,
199 FPTOUI = 380,
200 FPTOSI = 381,
201 INTTOPTR = 382,
202 PTRTOINT = 383,
203 PHI_TOK = 384,
204 SELECT = 385,
205 VAARG = 386,
206 EXTRACTELEMENT = 387,
207 INSERTELEMENT = 388,
208 SHUFFLEVECTOR = 389,
209 GETRESULT = 390,
210 SIGNEXT = 391,
211 ZEROEXT = 392,
212 NORETURN = 393,
213 INREG = 394,
214 SRET = 395,
215 NOUNWIND = 396,
216 NOALIAS = 397,
217 BYVAL = 398,
218 NEST = 399,
219 READNONE = 400,
220 READONLY = 401,
221 GC = 402,
222 DEFAULT = 403,
223 HIDDEN = 404,
224 PROTECTED = 405
Dan Gohman54392c12008-04-19 00:24:39 +0000225 };
226#endif
227/* Tokens. */
228#define ESINT64VAL 258
229#define EUINT64VAL 259
230#define ESAPINTVAL 260
231#define EUAPINTVAL 261
232#define LOCALVAL_ID 262
233#define GLOBALVAL_ID 263
234#define FPVAL 264
235#define VOID 265
236#define INTTYPE 266
237#define FLOAT 267
238#define DOUBLE 268
239#define X86_FP80 269
240#define FP128 270
241#define PPC_FP128 271
242#define LABEL 272
243#define TYPE 273
244#define LOCALVAR 274
245#define GLOBALVAR 275
246#define LABELSTR 276
247#define STRINGCONSTANT 277
248#define ATSTRINGCONSTANT 278
249#define PCTSTRINGCONSTANT 279
250#define ZEROINITIALIZER 280
251#define TRUETOK 281
252#define FALSETOK 282
253#define BEGINTOK 283
254#define ENDTOK 284
255#define DECLARE 285
256#define DEFINE 286
257#define GLOBAL 287
258#define CONSTANT 288
259#define SECTION 289
260#define ALIAS 290
261#define VOLATILE 291
262#define THREAD_LOCAL 292
263#define TO 293
264#define DOTDOTDOT 294
265#define NULL_TOK 295
266#define UNDEF 296
267#define INTERNAL 297
268#define LINKONCE 298
269#define WEAK 299
270#define APPENDING 300
271#define DLLIMPORT 301
272#define DLLEXPORT 302
273#define EXTERN_WEAK 303
274#define OPAQUE 304
275#define EXTERNAL 305
276#define TARGET 306
277#define TRIPLE 307
278#define ALIGN 308
279#define ADDRSPACE 309
280#define DEPLIBS 310
281#define CALL 311
282#define TAIL 312
283#define ASM_TOK 313
284#define MODULE 314
285#define SIDEEFFECT 315
286#define CC_TOK 316
287#define CCC_TOK 317
288#define FASTCC_TOK 318
289#define COLDCC_TOK 319
290#define X86_STDCALLCC_TOK 320
291#define X86_FASTCALLCC_TOK 321
292#define DATALAYOUT 322
Chris Lattnere7e9b602008-05-04 17:18:47 +0000293#define RET 323
294#define BR 324
295#define SWITCH 325
296#define INVOKE 326
297#define UNWIND 327
298#define UNREACHABLE 328
299#define ADD 329
300#define SUB 330
301#define MUL 331
302#define UDIV 332
303#define SDIV 333
304#define FDIV 334
305#define UREM 335
306#define SREM 336
307#define FREM 337
308#define AND 338
309#define OR 339
310#define XOR 340
311#define SHL 341
312#define LSHR 342
313#define ASHR 343
314#define ICMP 344
315#define FCMP 345
316#define EQ 346
317#define NE 347
318#define SLT 348
319#define SGT 349
320#define SLE 350
321#define SGE 351
322#define ULT 352
323#define UGT 353
324#define ULE 354
325#define UGE 355
326#define OEQ 356
327#define ONE 357
328#define OLT 358
329#define OGT 359
330#define OLE 360
331#define OGE 361
332#define ORD 362
333#define UNO 363
334#define UEQ 364
335#define UNE 365
336#define MALLOC 366
337#define ALLOCA 367
338#define FREE 368
339#define LOAD 369
340#define STORE 370
341#define GETELEMENTPTR 371
342#define TRUNC 372
343#define ZEXT 373
344#define SEXT 374
345#define FPTRUNC 375
346#define FPEXT 376
347#define BITCAST 377
348#define UITOFP 378
349#define SITOFP 379
350#define FPTOUI 380
351#define FPTOSI 381
352#define INTTOPTR 382
353#define PTRTOINT 383
354#define PHI_TOK 384
355#define SELECT 385
356#define VAARG 386
357#define EXTRACTELEMENT 387
358#define INSERTELEMENT 388
359#define SHUFFLEVECTOR 389
360#define GETRESULT 390
361#define SIGNEXT 391
362#define ZEROEXT 392
363#define NORETURN 393
364#define INREG 394
365#define SRET 395
366#define NOUNWIND 396
367#define NOALIAS 397
368#define BYVAL 398
369#define NEST 399
370#define READNONE 400
371#define READONLY 401
372#define GC 402
373#define DEFAULT 403
374#define HIDDEN 404
375#define PROTECTED 405
Dan Gohman54392c12008-04-19 00:24:39 +0000376
377
378
379
380/* Copy the first part of user declarations. */
Chris Lattnere7e9b602008-05-04 17:18:47 +0000381#line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382
383#include "ParserInternals.h"
384#include "llvm/CallingConv.h"
385#include "llvm/InlineAsm.h"
386#include "llvm/Instructions.h"
387#include "llvm/Module.h"
388#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000389#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390#include "llvm/Support/GetElementPtrTypeIterator.h"
391#include "llvm/Support/CommandLine.h"
392#include "llvm/ADT/SmallVector.h"
393#include "llvm/ADT/STLExtras.h"
394#include "llvm/Support/MathExtras.h"
395#include "llvm/Support/Streams.h"
396#include <algorithm>
397#include <list>
398#include <map>
399#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400
401// The following is a gross hack. In order to rid the libAsmParser library of
402// exceptions, we have to have a way of getting the yyparse function to go into
403// an error situation. So, whenever we want an error to occur, the GenerateError
404// function (see bottom of file) sets TriggerError. Then, at the end of each
405// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
406// (a goto) to put YACC in error state. Furthermore, several calls to
407// GenerateError are made from inside productions and they must simulate the
408// previous exception behavior by exiting the production immediately. We have
409// replaced these with the GEN_ERROR macro which calls GeneratError and then
410// immediately invokes YYERROR. This would be so much cleaner if it was a
411// recursive descent parser.
412static bool TriggerError = false;
413#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
414#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
415
416int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
417int yylex(); // declaration" of xxx warnings.
418int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419using namespace llvm;
420
421static Module *ParserResult;
422
423// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
424// relating to upreferences in the input stream.
425//
426//#define DEBUG_UPREFS 1
427#ifdef DEBUG_UPREFS
428#define UR_OUT(X) cerr << X
429#else
430#define UR_OUT(X)
431#endif
432
433#define YYERROR_VERBOSE 1
434
435static GlobalVariable *CurGV;
436
437
438// This contains info used when building the body of a function. It is
439// destroyed when the function is completed.
440//
441typedef std::vector<Value *> ValueList; // Numbered defs
442
443static void
444ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
445
446static struct PerModuleInfo {
447 Module *CurrentModule;
448 ValueList Values; // Module level numbered definitions
449 ValueList LateResolveValues;
450 std::vector<PATypeHolder> Types;
451 std::map<ValID, PATypeHolder> LateResolveTypes;
452
453 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
454 /// how they were referenced and on which line of the input they came from so
455 /// that we can resolve them later and print error messages as appropriate.
456 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
457
458 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
459 // references to global values. Global values may be referenced before they
460 // are defined, and if so, the temporary object that they represent is held
461 // here. This is used for forward references of GlobalValues.
462 //
463 typedef std::map<std::pair<const PointerType *,
464 ValID>, GlobalValue*> GlobalRefsType;
465 GlobalRefsType GlobalRefs;
466
467 void ModuleDone() {
468 // If we could not resolve some functions at function compilation time
469 // (calls to functions before they are defined), resolve them now... Types
470 // are resolved when the constant pool has been completely parsed.
471 //
472 ResolveDefinitions(LateResolveValues);
473 if (TriggerError)
474 return;
475
476 // Check to make sure that all global value forward references have been
477 // resolved!
478 //
479 if (!GlobalRefs.empty()) {
480 std::string UndefinedReferences = "Unresolved global references exist:\n";
481
482 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
483 I != E; ++I) {
484 UndefinedReferences += " " + I->first.first->getDescription() + " " +
485 I->first.second.getName() + "\n";
486 }
487 GenerateError(UndefinedReferences);
488 return;
489 }
490
Chandler Carruth563d4a42007-08-04 01:56:21 +0000491 // Look for intrinsic functions and CallInst that need to be upgraded
492 for (Module::iterator FI = CurrentModule->begin(),
493 FE = CurrentModule->end(); FI != FE; )
494 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
495
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 Values.clear(); // Clear out function local definitions
497 Types.clear();
498 CurrentModule = 0;
499 }
500
501 // GetForwardRefForGlobal - Check to see if there is a forward reference
502 // for this global. If so, remove it from the GlobalRefs map and return it.
503 // If not, just return null.
504 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
505 // Check to see if there is a forward reference to this global variable...
506 // if there is, eliminate it and patch the reference to use the new def'n.
507 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
508 GlobalValue *Ret = 0;
509 if (I != GlobalRefs.end()) {
510 Ret = I->second;
511 GlobalRefs.erase(I);
512 }
513 return Ret;
514 }
515
516 bool TypeIsUnresolved(PATypeHolder* PATy) {
517 // If it isn't abstract, its resolved
518 const Type* Ty = PATy->get();
519 if (!Ty->isAbstract())
520 return false;
521 // Traverse the type looking for abstract types. If it isn't abstract then
522 // we don't need to traverse that leg of the type.
523 std::vector<const Type*> WorkList, SeenList;
524 WorkList.push_back(Ty);
525 while (!WorkList.empty()) {
526 const Type* Ty = WorkList.back();
527 SeenList.push_back(Ty);
528 WorkList.pop_back();
529 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
530 // Check to see if this is an unresolved type
531 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
532 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
533 for ( ; I != E; ++I) {
534 if (I->second.get() == OpTy)
535 return true;
536 }
537 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
538 const Type* TheTy = SeqTy->getElementType();
539 if (TheTy->isAbstract() && TheTy != Ty) {
540 std::vector<const Type*>::iterator I = SeenList.begin(),
541 E = SeenList.end();
542 for ( ; I != E; ++I)
543 if (*I == TheTy)
544 break;
545 if (I == E)
546 WorkList.push_back(TheTy);
547 }
548 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
549 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
550 const Type* TheTy = StrTy->getElementType(i);
551 if (TheTy->isAbstract() && TheTy != Ty) {
552 std::vector<const Type*>::iterator I = SeenList.begin(),
553 E = SeenList.end();
554 for ( ; I != E; ++I)
555 if (*I == TheTy)
556 break;
557 if (I == E)
558 WorkList.push_back(TheTy);
559 }
560 }
561 }
562 }
563 return false;
564 }
565} CurModule;
566
567static struct PerFunctionInfo {
568 Function *CurrentFunction; // Pointer to current function being created
569
570 ValueList Values; // Keep track of #'d definitions
571 unsigned NextValNum;
572 ValueList LateResolveValues;
573 bool isDeclare; // Is this function a forward declararation?
574 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
575 GlobalValue::VisibilityTypes Visibility;
576
577 /// BBForwardRefs - When we see forward references to basic blocks, keep
578 /// track of them here.
579 std::map<ValID, BasicBlock*> BBForwardRefs;
580
581 inline PerFunctionInfo() {
582 CurrentFunction = 0;
583 isDeclare = false;
584 Linkage = GlobalValue::ExternalLinkage;
585 Visibility = GlobalValue::DefaultVisibility;
586 }
587
588 inline void FunctionStart(Function *M) {
589 CurrentFunction = M;
590 NextValNum = 0;
591 }
592
593 void FunctionDone() {
594 // Any forward referenced blocks left?
595 if (!BBForwardRefs.empty()) {
596 GenerateError("Undefined reference to label " +
597 BBForwardRefs.begin()->second->getName());
598 return;
599 }
600
601 // Resolve all forward references now.
602 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
603
604 Values.clear(); // Clear out function local definitions
605 BBForwardRefs.clear();
606 CurrentFunction = 0;
607 isDeclare = false;
608 Linkage = GlobalValue::ExternalLinkage;
609 Visibility = GlobalValue::DefaultVisibility;
610 }
611} CurFun; // Info for the current function...
612
613static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
614
615
616//===----------------------------------------------------------------------===//
617// Code to handle definitions of all the types
618//===----------------------------------------------------------------------===//
619
620static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
621 // Things that have names or are void typed don't get slot numbers
622 if (V->hasName() || (V->getType() == Type::VoidTy))
623 return;
624
625 // In the case of function values, we have to allow for the forward reference
626 // of basic blocks, which are included in the numbering. Consequently, we keep
627 // track of the next insertion location with NextValNum. When a BB gets
628 // inserted, it could change the size of the CurFun.Values vector.
629 if (&ValueTab == &CurFun.Values) {
630 if (ValueTab.size() <= CurFun.NextValNum)
631 ValueTab.resize(CurFun.NextValNum+1);
632 ValueTab[CurFun.NextValNum++] = V;
633 return;
634 }
635 // For all other lists, its okay to just tack it on the back of the vector.
636 ValueTab.push_back(V);
637}
638
639static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
640 switch (D.Type) {
641 case ValID::LocalID: // Is it a numbered definition?
642 // Module constants occupy the lowest numbered slots...
643 if (D.Num < CurModule.Types.size())
644 return CurModule.Types[D.Num];
645 break;
646 case ValID::LocalName: // Is it a named definition?
647 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
648 D.destroy(); // Free old strdup'd memory...
649 return N;
650 }
651 break;
652 default:
653 GenerateError("Internal parser error: Invalid symbol type reference");
654 return 0;
655 }
656
657 // If we reached here, we referenced either a symbol that we don't know about
658 // or an id number that hasn't been read yet. We may be referencing something
659 // forward, so just create an entry to be resolved later and get to it...
660 //
661 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
662
663
664 if (inFunctionScope()) {
665 if (D.Type == ValID::LocalName) {
666 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
667 return 0;
668 } else {
669 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
670 return 0;
671 }
672 }
673
674 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
675 if (I != CurModule.LateResolveTypes.end())
676 return I->second;
677
678 Type *Typ = OpaqueType::get();
679 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
680 return Typ;
681 }
682
683// getExistingVal - Look up the value specified by the provided type and
684// the provided ValID. If the value exists and has already been defined, return
685// it. Otherwise return null.
686//
687static Value *getExistingVal(const Type *Ty, const ValID &D) {
688 if (isa<FunctionType>(Ty)) {
689 GenerateError("Functions are not values and "
690 "must be referenced as pointers");
691 return 0;
692 }
693
694 switch (D.Type) {
695 case ValID::LocalID: { // Is it a numbered definition?
696 // Check that the number is within bounds.
697 if (D.Num >= CurFun.Values.size())
698 return 0;
699 Value *Result = CurFun.Values[D.Num];
700 if (Ty != Result->getType()) {
701 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
702 Result->getType()->getDescription() + "' does not match "
703 "expected type, '" + Ty->getDescription() + "'");
704 return 0;
705 }
706 return Result;
707 }
708 case ValID::GlobalID: { // Is it a numbered definition?
709 if (D.Num >= CurModule.Values.size())
710 return 0;
711 Value *Result = CurModule.Values[D.Num];
712 if (Ty != Result->getType()) {
713 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
714 Result->getType()->getDescription() + "' does not match "
715 "expected type, '" + Ty->getDescription() + "'");
716 return 0;
717 }
718 return Result;
719 }
720
721 case ValID::LocalName: { // Is it a named definition?
722 if (!inFunctionScope())
723 return 0;
724 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
725 Value *N = SymTab.lookup(D.getName());
726 if (N == 0)
727 return 0;
728 if (N->getType() != Ty)
729 return 0;
730
731 D.destroy(); // Free old strdup'd memory...
732 return N;
733 }
734 case ValID::GlobalName: { // Is it a named definition?
735 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
736 Value *N = SymTab.lookup(D.getName());
737 if (N == 0)
738 return 0;
739 if (N->getType() != Ty)
740 return 0;
741
742 D.destroy(); // Free old strdup'd memory...
743 return N;
744 }
745
746 // Check to make sure that "Ty" is an integral type, and that our
747 // value will fit into the specified type...
748 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner59363a32008-02-19 04:36:25 +0000749 if (!isa<IntegerType>(Ty) ||
750 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 GenerateError("Signed integral constant '" +
752 itostr(D.ConstPool64) + "' is invalid for type '" +
753 Ty->getDescription() + "'");
754 return 0;
755 }
756 return ConstantInt::get(Ty, D.ConstPool64, true);
757
758 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000759 if (isa<IntegerType>(Ty) &&
760 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner59363a32008-02-19 04:36:25 +0000762
763 if (!isa<IntegerType>(Ty) ||
764 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
765 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
766 "' is invalid or out of range for type '" +
767 Ty->getDescription() + "'");
768 return 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 }
Chris Lattner59363a32008-02-19 04:36:25 +0000770 // This is really a signed reference. Transmogrify.
771 return ConstantInt::get(Ty, D.ConstPool64, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772
773 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000774 if (!Ty->isFloatingPoint() ||
775 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 GenerateError("FP constant invalid for type");
777 return 0;
778 }
Chris Lattner05ba86e2008-04-20 00:41:19 +0000779 // Lexer has no type info, so builds all float and double FP constants
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000780 // as double. Fix this here. Long double does not need this.
781 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
782 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000783 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattner05ba86e2008-04-20 00:41:19 +0000784 return ConstantFP::get(*D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785
786 case ValID::ConstNullVal: // Is it a null value?
787 if (!isa<PointerType>(Ty)) {
788 GenerateError("Cannot create a a non pointer null");
789 return 0;
790 }
791 return ConstantPointerNull::get(cast<PointerType>(Ty));
792
793 case ValID::ConstUndefVal: // Is it an undef value?
794 return UndefValue::get(Ty);
795
796 case ValID::ConstZeroVal: // Is it a zero value?
797 return Constant::getNullValue(Ty);
798
799 case ValID::ConstantVal: // Fully resolved constant?
800 if (D.ConstantValue->getType() != Ty) {
801 GenerateError("Constant expression type different from required type");
802 return 0;
803 }
804 return D.ConstantValue;
805
806 case ValID::InlineAsmVal: { // Inline asm expression
807 const PointerType *PTy = dyn_cast<PointerType>(Ty);
808 const FunctionType *FTy =
809 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
810 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
811 GenerateError("Invalid type for asm constraint string");
812 return 0;
813 }
814 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
815 D.IAD->HasSideEffects);
816 D.destroy(); // Free InlineAsmDescriptor.
817 return IA;
818 }
819 default:
820 assert(0 && "Unhandled case!");
821 return 0;
822 } // End of switch
823
824 assert(0 && "Unhandled case!");
825 return 0;
826}
827
828// getVal - This function is identical to getExistingVal, except that if a
829// value is not already defined, it "improvises" by creating a placeholder var
830// that looks and acts just like the requested variable. When the value is
831// defined later, all uses of the placeholder variable are replaced with the
832// real thing.
833//
834static Value *getVal(const Type *Ty, const ValID &ID) {
835 if (Ty == Type::LabelTy) {
836 GenerateError("Cannot use a basic block here");
837 return 0;
838 }
839
840 // See if the value has already been defined.
841 Value *V = getExistingVal(Ty, ID);
842 if (V) return V;
843 if (TriggerError) return 0;
844
845 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
846 GenerateError("Invalid use of a composite type");
847 return 0;
848 }
849
850 // If we reached here, we referenced either a symbol that we don't know about
851 // or an id number that hasn't been read yet. We may be referencing something
852 // forward, so just create an entry to be resolved later and get to it...
853 //
854 switch (ID.Type) {
855 case ValID::GlobalName:
856 case ValID::GlobalID: {
857 const PointerType *PTy = dyn_cast<PointerType>(Ty);
858 if (!PTy) {
859 GenerateError("Invalid type for reference to global" );
860 return 0;
861 }
862 const Type* ElTy = PTy->getElementType();
863 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
Gabor Greif89f01162008-04-06 23:07:54 +0000864 V = Function::Create(FTy, GlobalValue::ExternalLinkage);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000866 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
867 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 break;
869 }
870 default:
871 V = new Argument(Ty);
872 }
873
874 // Remember where this forward reference came from. FIXME, shouldn't we try
875 // to recycle these things??
876 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000877 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878
879 if (inFunctionScope())
880 InsertValue(V, CurFun.LateResolveValues);
881 else
882 InsertValue(V, CurModule.LateResolveValues);
883 return V;
884}
885
886/// defineBBVal - This is a definition of a new basic block with the specified
887/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Chris Lattnere7e9b602008-05-04 17:18:47 +0000888static BasicBlock *defineBBVal(const ValID &ID) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 assert(inFunctionScope() && "Can't get basic block at global scope!");
890
891 BasicBlock *BB = 0;
892
893 // First, see if this was forward referenced
894
895 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
896 if (BBI != CurFun.BBForwardRefs.end()) {
897 BB = BBI->second;
898 // The forward declaration could have been inserted anywhere in the
899 // function: insert it into the correct place now.
900 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
901 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
902
903 // We're about to erase the entry, save the key so we can clean it up.
904 ValID Tmp = BBI->first;
905
906 // Erase the forward ref from the map as its no longer "forward"
907 CurFun.BBForwardRefs.erase(ID);
908
909 // The key has been removed from the map but so we don't want to leave
910 // strdup'd memory around so destroy it too.
911 Tmp.destroy();
912
913 // If its a numbered definition, bump the number and set the BB value.
914 if (ID.Type == ValID::LocalID) {
915 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
916 InsertValue(BB);
917 }
Devang Patel890cc572008-03-03 18:58:47 +0000918 } else {
919 // We haven't seen this BB before and its first mention is a definition.
920 // Just create it and return it.
921 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Gabor Greif89f01162008-04-06 23:07:54 +0000922 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Devang Patel890cc572008-03-03 18:58:47 +0000923 if (ID.Type == ValID::LocalID) {
924 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
925 InsertValue(BB);
926 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 }
928
Devang Patel890cc572008-03-03 18:58:47 +0000929 ID.destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 return BB;
931}
932
933/// getBBVal - get an existing BB value or create a forward reference for it.
934///
935static BasicBlock *getBBVal(const ValID &ID) {
936 assert(inFunctionScope() && "Can't get basic block at global scope!");
937
938 BasicBlock *BB = 0;
939
940 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
941 if (BBI != CurFun.BBForwardRefs.end()) {
942 BB = BBI->second;
943 } if (ID.Type == ValID::LocalName) {
944 std::string Name = ID.getName();
945 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000946 if (N) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 if (N->getType()->getTypeID() == Type::LabelTyID)
948 BB = cast<BasicBlock>(N);
949 else
950 GenerateError("Reference to label '" + Name + "' is actually of type '"+
951 N->getType()->getDescription() + "'");
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000952 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 } else if (ID.Type == ValID::LocalID) {
954 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
955 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
956 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
957 else
958 GenerateError("Reference to label '%" + utostr(ID.Num) +
959 "' is actually of type '"+
960 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
961 }
962 } else {
963 GenerateError("Illegal label reference " + ID.getName());
964 return 0;
965 }
966
967 // If its already been defined, return it now.
968 if (BB) {
969 ID.destroy(); // Free strdup'd memory.
970 return BB;
971 }
972
973 // Otherwise, this block has not been seen before, create it.
974 std::string Name;
975 if (ID.Type == ValID::LocalName)
976 Name = ID.getName();
Gabor Greif89f01162008-04-06 23:07:54 +0000977 BB = BasicBlock::Create(Name, CurFun.CurrentFunction);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978
979 // Insert it in the forward refs map.
980 CurFun.BBForwardRefs[ID] = BB;
981
982 return BB;
983}
984
985
986//===----------------------------------------------------------------------===//
987// Code to handle forward references in instructions
988//===----------------------------------------------------------------------===//
989//
990// This code handles the late binding needed with statements that reference
991// values not defined yet... for example, a forward branch, or the PHI node for
992// a loop body.
993//
994// This keeps a table (CurFun.LateResolveValues) of all such forward references
995// and back patchs after we are done.
996//
997
998// ResolveDefinitions - If we could not resolve some defs at parsing
999// time (forward branches, phi functions for loops, etc...) resolve the
1000// defs now...
1001//
1002static void
1003ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1004 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1005 while (!LateResolvers.empty()) {
1006 Value *V = LateResolvers.back();
1007 LateResolvers.pop_back();
1008
1009 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1010 CurModule.PlaceHolderInfo.find(V);
1011 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1012
1013 ValID &DID = PHI->second.first;
1014
1015 Value *TheRealValue = getExistingVal(V->getType(), DID);
1016 if (TriggerError)
1017 return;
1018 if (TheRealValue) {
1019 V->replaceAllUsesWith(TheRealValue);
1020 delete V;
1021 CurModule.PlaceHolderInfo.erase(PHI);
1022 } else if (FutureLateResolvers) {
1023 // Functions have their unresolved items forwarded to the module late
1024 // resolver table
1025 InsertValue(V, *FutureLateResolvers);
1026 } else {
1027 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1028 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1029 "' of type '" + V->getType()->getDescription() + "'",
1030 PHI->second.second);
1031 return;
1032 } else {
1033 GenerateError("Reference to an invalid definition: #" +
1034 itostr(DID.Num) + " of type '" +
1035 V->getType()->getDescription() + "'",
1036 PHI->second.second);
1037 return;
1038 }
1039 }
1040 }
1041 LateResolvers.clear();
1042}
1043
1044// ResolveTypeTo - A brand new type was just declared. This means that (if
1045// name is not null) things referencing Name can be resolved. Otherwise, things
1046// refering to the number can be resolved. Do this now.
1047//
1048static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1049 ValID D;
1050 if (Name)
1051 D = ValID::createLocalName(*Name);
1052 else
1053 D = ValID::createLocalID(CurModule.Types.size());
1054
1055 std::map<ValID, PATypeHolder>::iterator I =
1056 CurModule.LateResolveTypes.find(D);
1057 if (I != CurModule.LateResolveTypes.end()) {
1058 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1059 CurModule.LateResolveTypes.erase(I);
1060 }
1061}
1062
1063// setValueName - Set the specified value to the name given. The name may be
1064// null potentially, in which case this is a noop. The string passed in is
1065// assumed to be a malloc'd string buffer, and is free'd by this function.
1066//
1067static void setValueName(Value *V, std::string *NameStr) {
1068 if (!NameStr) return;
1069 std::string Name(*NameStr); // Copy string
1070 delete NameStr; // Free old string
1071
1072 if (V->getType() == Type::VoidTy) {
1073 GenerateError("Can't assign name '" + Name+"' to value with void type");
1074 return;
1075 }
1076
1077 assert(inFunctionScope() && "Must be in function scope!");
1078 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1079 if (ST.lookup(Name)) {
1080 GenerateError("Redefinition of value '" + Name + "' of type '" +
1081 V->getType()->getDescription() + "'");
1082 return;
1083 }
1084
1085 // Set the name.
1086 V->setName(Name);
1087}
1088
1089/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1090/// this is a declaration, otherwise it is a definition.
1091static GlobalVariable *
1092ParseGlobalVariable(std::string *NameStr,
1093 GlobalValue::LinkageTypes Linkage,
1094 GlobalValue::VisibilityTypes Visibility,
1095 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +00001096 Constant *Initializer, bool IsThreadLocal,
1097 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 if (isa<FunctionType>(Ty)) {
1099 GenerateError("Cannot declare global vars of function type");
1100 return 0;
1101 }
1102
Christopher Lamb0a243582007-12-11 09:02:08 +00001103 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104
1105 std::string Name;
1106 if (NameStr) {
1107 Name = *NameStr; // Copy string
1108 delete NameStr; // Free old string
1109 }
1110
1111 // See if this global value was forward referenced. If so, recycle the
1112 // object.
1113 ValID ID;
1114 if (!Name.empty()) {
1115 ID = ValID::createGlobalName(Name);
1116 } else {
1117 ID = ValID::createGlobalID(CurModule.Values.size());
1118 }
1119
1120 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1121 // Move the global to the end of the list, from whereever it was
1122 // previously inserted.
1123 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1124 CurModule.CurrentModule->getGlobalList().remove(GV);
1125 CurModule.CurrentModule->getGlobalList().push_back(GV);
1126 GV->setInitializer(Initializer);
1127 GV->setLinkage(Linkage);
1128 GV->setVisibility(Visibility);
1129 GV->setConstant(isConstantGlobal);
1130 GV->setThreadLocal(IsThreadLocal);
1131 InsertValue(GV, CurModule.Values);
1132 return GV;
1133 }
1134
1135 // If this global has a name
1136 if (!Name.empty()) {
1137 // if the global we're parsing has an initializer (is a definition) and
1138 // has external linkage.
1139 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1140 // If there is already a global with external linkage with this name
1141 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1142 // If we allow this GVar to get created, it will be renamed in the
1143 // symbol table because it conflicts with an existing GVar. We can't
1144 // allow redefinition of GVars whose linking indicates that their name
1145 // must stay the same. Issue the error.
1146 GenerateError("Redefinition of global variable named '" + Name +
1147 "' of type '" + Ty->getDescription() + "'");
1148 return 0;
1149 }
1150 }
1151
1152 // Otherwise there is no existing GV to use, create one now.
1153 GlobalVariable *GV =
1154 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +00001155 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 GV->setVisibility(Visibility);
1157 InsertValue(GV, CurModule.Values);
1158 return GV;
1159}
1160
1161// setTypeName - Set the specified type to the name given. The name may be
1162// null potentially, in which case this is a noop. The string passed in is
1163// assumed to be a malloc'd string buffer, and is freed by this function.
1164//
1165// This function returns true if the type has already been defined, but is
1166// allowed to be redefined in the specified context. If the name is a new name
1167// for the type plane, it is inserted and false is returned.
1168static bool setTypeName(const Type *T, std::string *NameStr) {
1169 assert(!inFunctionScope() && "Can't give types function-local names!");
1170 if (NameStr == 0) return false;
1171
1172 std::string Name(*NameStr); // Copy string
1173 delete NameStr; // Free old string
1174
1175 // We don't allow assigning names to void type
1176 if (T == Type::VoidTy) {
1177 GenerateError("Can't assign name '" + Name + "' to the void type");
1178 return false;
1179 }
1180
1181 // Set the type name, checking for conflicts as we do so.
1182 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1183
1184 if (AlreadyExists) { // Inserting a name that is already defined???
1185 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1186 assert(Existing && "Conflict but no matching type?!");
1187
1188 // There is only one case where this is allowed: when we are refining an
1189 // opaque type. In this case, Existing will be an opaque type.
1190 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1191 // We ARE replacing an opaque type!
1192 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1193 return true;
1194 }
1195
1196 // Otherwise, this is an attempt to redefine a type. That's okay if
1197 // the redefinition is identical to the original. This will be so if
1198 // Existing and T point to the same Type object. In this one case we
1199 // allow the equivalent redefinition.
1200 if (Existing == T) return true; // Yes, it's equal.
1201
1202 // Any other kind of (non-equivalent) redefinition is an error.
1203 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1204 T->getDescription() + "'");
1205 }
1206
1207 return false;
1208}
1209
1210//===----------------------------------------------------------------------===//
1211// Code for handling upreferences in type names...
1212//
1213
1214// TypeContains - Returns true if Ty directly contains E in it.
1215//
1216static bool TypeContains(const Type *Ty, const Type *E) {
1217 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1218 E) != Ty->subtype_end();
1219}
1220
1221namespace {
1222 struct UpRefRecord {
1223 // NestingLevel - The number of nesting levels that need to be popped before
1224 // this type is resolved.
1225 unsigned NestingLevel;
1226
1227 // LastContainedTy - This is the type at the current binding level for the
1228 // type. Every time we reduce the nesting level, this gets updated.
1229 const Type *LastContainedTy;
1230
1231 // UpRefTy - This is the actual opaque type that the upreference is
1232 // represented with.
1233 OpaqueType *UpRefTy;
1234
1235 UpRefRecord(unsigned NL, OpaqueType *URTy)
1236 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1237 };
1238}
1239
1240// UpRefs - A list of the outstanding upreferences that need to be resolved.
1241static std::vector<UpRefRecord> UpRefs;
1242
1243/// HandleUpRefs - Every time we finish a new layer of types, this function is
1244/// called. It loops through the UpRefs vector, which is a list of the
1245/// currently active types. For each type, if the up reference is contained in
1246/// the newly completed type, we decrement the level count. When the level
1247/// count reaches zero, the upreferenced type is the type that is passed in:
1248/// thus we can complete the cycle.
1249///
1250static PATypeHolder HandleUpRefs(const Type *ty) {
1251 // If Ty isn't abstract, or if there are no up-references in it, then there is
1252 // nothing to resolve here.
1253 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1254
1255 PATypeHolder Ty(ty);
1256 UR_OUT("Type '" << Ty->getDescription() <<
1257 "' newly formed. Resolving upreferences.\n" <<
1258 UpRefs.size() << " upreferences active!\n");
1259
1260 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1261 // to zero), we resolve them all together before we resolve them to Ty. At
1262 // the end of the loop, if there is anything to resolve to Ty, it will be in
1263 // this variable.
1264 OpaqueType *TypeToResolve = 0;
1265
1266 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1267 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1268 << UpRefs[i].second->getDescription() << ") = "
1269 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1270 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1271 // Decrement level of upreference
1272 unsigned Level = --UpRefs[i].NestingLevel;
1273 UpRefs[i].LastContainedTy = Ty;
1274 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1275 if (Level == 0) { // Upreference should be resolved!
1276 if (!TypeToResolve) {
1277 TypeToResolve = UpRefs[i].UpRefTy;
1278 } else {
1279 UR_OUT(" * Resolving upreference for "
1280 << UpRefs[i].second->getDescription() << "\n";
1281 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1282 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1283 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1284 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1285 }
1286 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1287 --i; // Do not skip the next element...
1288 }
1289 }
1290 }
1291
1292 if (TypeToResolve) {
1293 UR_OUT(" * Resolving upreference for "
1294 << UpRefs[i].second->getDescription() << "\n";
1295 std::string OldName = TypeToResolve->getDescription());
1296 TypeToResolve->refineAbstractTypeTo(Ty);
1297 }
1298
1299 return Ty;
1300}
1301
1302//===----------------------------------------------------------------------===//
1303// RunVMAsmParser - Define an interface to this parser
1304//===----------------------------------------------------------------------===//
1305//
1306static Module* RunParser(Module * M);
1307
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001308Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1309 InitLLLexer(MB);
1310 Module *M = RunParser(new Module(LLLgetFilename()));
1311 FreeLexer();
1312 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313}
1314
1315
Dan Gohman54392c12008-04-19 00:24:39 +00001316
1317/* Enabling traces. */
1318#ifndef YYDEBUG
1319# define YYDEBUG 0
1320#endif
1321
1322/* Enabling verbose error messages. */
1323#ifdef YYERROR_VERBOSE
1324# undef YYERROR_VERBOSE
1325# define YYERROR_VERBOSE 1
1326#else
1327# define YYERROR_VERBOSE 0
1328#endif
1329
1330/* Enabling the token table. */
1331#ifndef YYTOKEN_TABLE
1332# define YYTOKEN_TABLE 0
1333#endif
1334
1335#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1336typedef union YYSTYPE
Chris Lattnere7e9b602008-05-04 17:18:47 +00001337#line 949 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00001338{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 llvm::Module *ModuleVal;
1340 llvm::Function *FunctionVal;
1341 llvm::BasicBlock *BasicBlockVal;
1342 llvm::TerminatorInst *TermInstVal;
1343 llvm::Instruction *InstVal;
1344 llvm::Constant *ConstVal;
1345
1346 const llvm::Type *PrimType;
1347 std::list<llvm::PATypeHolder> *TypeList;
1348 llvm::PATypeHolder *TypeVal;
1349 llvm::Value *ValueVal;
1350 std::vector<llvm::Value*> *ValueList;
1351 llvm::ArgListType *ArgList;
1352 llvm::TypeWithAttrs TypeWithAttrs;
1353 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001354 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355
1356 // Represent the RHS of PHI node
1357 std::list<std::pair<llvm::Value*,
1358 llvm::BasicBlock*> > *PHIList;
1359 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1360 std::vector<llvm::Constant*> *ConstVector;
1361
1362 llvm::GlobalValue::LinkageTypes Linkage;
1363 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesend915ee52008-02-19 21:40:51 +00001364 llvm::ParameterAttributes ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 llvm::APInt *APIntVal;
1366 int64_t SInt64Val;
1367 uint64_t UInt64Val;
1368 int SIntVal;
1369 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001370 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 bool BoolVal;
1372
1373 std::string *StrVal; // This memory must be deleted
1374 llvm::ValID ValIDVal;
1375
1376 llvm::Instruction::BinaryOps BinaryOpVal;
1377 llvm::Instruction::TermOps TermOpVal;
1378 llvm::Instruction::MemoryOps MemOpVal;
1379 llvm::Instruction::CastOps CastOpVal;
1380 llvm::Instruction::OtherOps OtherOpVal;
1381 llvm::ICmpInst::Predicate IPredicate;
1382 llvm::FCmpInst::Predicate FPredicate;
Dan Gohman54392c12008-04-19 00:24:39 +00001383}
1384/* Line 193 of yacc.c. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001385#line 1386 "llvmAsmParser.tab.c"
Dan Gohman54392c12008-04-19 00:24:39 +00001386 YYSTYPE;
1387# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1388# define YYSTYPE_IS_DECLARED 1
1389# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390#endif
1391
1392
1393
Dan Gohman54392c12008-04-19 00:24:39 +00001394/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396
Dan Gohman54392c12008-04-19 00:24:39 +00001397/* Line 216 of yacc.c. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001398#line 1399 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001399
Dan Gohman54392c12008-04-19 00:24:39 +00001400#ifdef short
1401# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402#endif
1403
Dan Gohman54392c12008-04-19 00:24:39 +00001404#ifdef YYTYPE_UINT8
1405typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406#else
Dan Gohman54392c12008-04-19 00:24:39 +00001407typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408#endif
1409
Dan Gohman54392c12008-04-19 00:24:39 +00001410#ifdef YYTYPE_INT8
1411typedef YYTYPE_INT8 yytype_int8;
1412#elif (defined __STDC__ || defined __C99__FUNC__ \
1413 || defined __cplusplus || defined _MSC_VER)
1414typedef signed char yytype_int8;
1415#else
1416typedef short int yytype_int8;
1417#endif
1418
1419#ifdef YYTYPE_UINT16
1420typedef YYTYPE_UINT16 yytype_uint16;
1421#else
1422typedef unsigned short int yytype_uint16;
1423#endif
1424
1425#ifdef YYTYPE_INT16
1426typedef YYTYPE_INT16 yytype_int16;
1427#else
1428typedef short int yytype_int16;
1429#endif
1430
1431#ifndef YYSIZE_T
1432# ifdef __SIZE_TYPE__
1433# define YYSIZE_T __SIZE_TYPE__
1434# elif defined size_t
1435# define YYSIZE_T size_t
1436# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1437 || defined __cplusplus || defined _MSC_VER)
1438# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1439# define YYSIZE_T size_t
1440# else
1441# define YYSIZE_T unsigned int
1442# endif
1443#endif
1444
1445#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1446
1447#ifndef YY_
1448# if defined YYENABLE_NLS && YYENABLE_NLS
1449# if ENABLE_NLS
1450# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1451# define YY_(msgid) dgettext ("bison-runtime", msgid)
1452# endif
1453# endif
1454# ifndef YY_
1455# define YY_(msgid) msgid
1456# endif
1457#endif
1458
1459/* Suppress unused-variable warnings by "using" E. */
1460#if ! defined lint || defined __GNUC__
1461# define YYUSE(e) ((void) (e))
1462#else
1463# define YYUSE(e) /* empty */
1464#endif
1465
1466/* Identity function, used to suppress warnings about constant conditions. */
1467#ifndef lint
1468# define YYID(n) (n)
1469#else
1470#if (defined __STDC__ || defined __C99__FUNC__ \
1471 || defined __cplusplus || defined _MSC_VER)
1472static int
1473YYID (int i)
1474#else
1475static int
1476YYID (i)
1477 int i;
1478#endif
1479{
1480 return i;
1481}
1482#endif
1483
1484#if ! defined yyoverflow || YYERROR_VERBOSE
1485
1486/* The parser invokes alloca or malloc; define the necessary symbols. */
1487
1488# ifdef YYSTACK_USE_ALLOCA
1489# if YYSTACK_USE_ALLOCA
1490# ifdef __GNUC__
1491# define YYSTACK_ALLOC __builtin_alloca
1492# elif defined __BUILTIN_VA_ARG_INCR
1493# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1494# elif defined _AIX
1495# define YYSTACK_ALLOC __alloca
1496# elif defined _MSC_VER
1497# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1498# define alloca _alloca
1499# else
1500# define YYSTACK_ALLOC alloca
1501# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1502 || defined __cplusplus || defined _MSC_VER)
1503# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1504# ifndef _STDLIB_H
1505# define _STDLIB_H 1
1506# endif
1507# endif
1508# endif
1509# endif
1510# endif
1511
1512# ifdef YYSTACK_ALLOC
1513 /* Pacify GCC's `empty if-body' warning. */
1514# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1515# ifndef YYSTACK_ALLOC_MAXIMUM
1516 /* The OS might guarantee only one guard page at the bottom of the stack,
1517 and a page size can be as small as 4096 bytes. So we cannot safely
1518 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1519 to allow for a few compiler-allocated temporary stack slots. */
1520# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1521# endif
1522# else
1523# define YYSTACK_ALLOC YYMALLOC
1524# define YYSTACK_FREE YYFREE
1525# ifndef YYSTACK_ALLOC_MAXIMUM
1526# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1527# endif
1528# if (defined __cplusplus && ! defined _STDLIB_H \
1529 && ! ((defined YYMALLOC || defined malloc) \
1530 && (defined YYFREE || defined free)))
1531# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1532# ifndef _STDLIB_H
1533# define _STDLIB_H 1
1534# endif
1535# endif
1536# ifndef YYMALLOC
1537# define YYMALLOC malloc
1538# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1539 || defined __cplusplus || defined _MSC_VER)
1540void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1541# endif
1542# endif
1543# ifndef YYFREE
1544# define YYFREE free
1545# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1546 || defined __cplusplus || defined _MSC_VER)
1547void free (void *); /* INFRINGES ON USER NAME SPACE */
1548# endif
1549# endif
1550# endif
1551#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1552
1553
1554#if (! defined yyoverflow \
1555 && (! defined __cplusplus \
1556 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1557
1558/* A type that is properly aligned for any stack member. */
1559union yyalloc
1560{
1561 yytype_int16 yyss;
1562 YYSTYPE yyvs;
1563 };
1564
1565/* The size of the maximum gap between one aligned stack and the next. */
1566# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1567
1568/* The size of an array large to enough to hold all stacks, each with
1569 N elements. */
1570# define YYSTACK_BYTES(N) \
1571 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1572 + YYSTACK_GAP_MAXIMUM)
1573
1574/* Copy COUNT objects from FROM to TO. The source and destination do
1575 not overlap. */
1576# ifndef YYCOPY
1577# if defined __GNUC__ && 1 < __GNUC__
1578# define YYCOPY(To, From, Count) \
1579 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1580# else
1581# define YYCOPY(To, From, Count) \
1582 do \
1583 { \
1584 YYSIZE_T yyi; \
1585 for (yyi = 0; yyi < (Count); yyi++) \
1586 (To)[yyi] = (From)[yyi]; \
1587 } \
1588 while (YYID (0))
1589# endif
1590# endif
1591
1592/* Relocate STACK from its old location to the new one. The
1593 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1594 elements in the stack, and YYPTR gives the new location of the
1595 stack. Advance YYPTR to a properly aligned location for the next
1596 stack. */
1597# define YYSTACK_RELOCATE(Stack) \
1598 do \
1599 { \
1600 YYSIZE_T yynewbytes; \
1601 YYCOPY (&yyptr->Stack, Stack, yysize); \
1602 Stack = &yyptr->Stack; \
1603 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1604 yyptr += yynewbytes / sizeof (*yyptr); \
1605 } \
1606 while (YYID (0))
1607
1608#endif
1609
1610/* YYFINAL -- State number of the termination state. */
1611#define YYFINAL 43
1612/* YYLAST -- Last index in YYTABLE. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001613#define YYLAST 1978
Dan Gohman54392c12008-04-19 00:24:39 +00001614
1615/* YYNTOKENS -- Number of terminals. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001616#define YYNTOKENS 165
Dan Gohman54392c12008-04-19 00:24:39 +00001617/* YYNNTS -- Number of nonterminals. */
1618#define YYNNTS 85
1619/* YYNRULES -- Number of rules. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001620#define YYNRULES 322
Dan Gohman54392c12008-04-19 00:24:39 +00001621/* YYNRULES -- Number of states. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00001622#define YYNSTATES 629
Dan Gohman54392c12008-04-19 00:24:39 +00001623
1624/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1625#define YYUNDEFTOK 2
Chris Lattnere7e9b602008-05-04 17:18:47 +00001626#define YYMAXUTOK 405
Dan Gohman54392c12008-04-19 00:24:39 +00001627
1628#define YYTRANSLATE(YYX) \
1629 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1630
1631/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1632static const yytype_uint8 yytranslate[] =
1633{
1634 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001638 151, 152, 155, 2, 154, 2, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001640 160, 153, 161, 2, 2, 2, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001643 2, 157, 156, 159, 2, 2, 2, 2, 2, 164,
Dan Gohman54392c12008-04-19 00:24:39 +00001644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001646 158, 2, 2, 162, 2, 163, 2, 2, 2, 2,
Dan Gohman54392c12008-04-19 00:24:39 +00001647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1660 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1661 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1662 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1663 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1664 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1665 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1666 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1667 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1668 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1669 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1670 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1671 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1672 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1673 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001674 145, 146, 147, 148, 149, 150
Dan Gohman54392c12008-04-19 00:24:39 +00001675};
1676
1677#if YYDEBUG
1678/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1679 YYRHS. */
1680static const yytype_uint16 yyprhs[] =
1681{
1682 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1683 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1684 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1685 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1686 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1687 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1688 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
1689 140, 142, 144, 146, 147, 150, 152, 154, 156, 158,
1690 160, 162, 164, 166, 167, 169, 171, 173, 174, 176,
1691 178, 179, 181, 183, 185, 187, 188, 190, 192, 193,
1692 195, 197, 199, 201, 203, 206, 208, 210, 212, 214,
1693 216, 218, 220, 222, 224, 227, 228, 231, 233, 235,
1694 237, 239, 241, 243, 244, 247, 248, 251, 252, 255,
1695 256, 260, 263, 264, 266, 267, 271, 273, 276, 278,
1696 280, 282, 284, 286, 288, 290, 292, 294, 298, 300,
1697 303, 309, 315, 321, 327, 331, 334, 340, 345, 348,
1698 350, 352, 354, 358, 360, 364, 366, 367, 369, 373,
1699 378, 382, 386, 391, 396, 400, 407, 413, 416, 419,
1700 422, 425, 428, 431, 434, 437, 440, 443, 446, 449,
1701 456, 462, 471, 478, 485, 493, 501, 508, 517, 526,
1702 530, 532, 534, 536, 538, 539, 542, 549, 551, 552,
1703 554, 557, 558, 562, 563, 567, 571, 575, 579, 580,
1704 589, 590, 600, 601, 611, 617, 620, 624, 626, 630,
1705 634, 638, 642, 644, 645, 651, 655, 657, 661, 663,
1706 664, 675, 677, 679, 684, 686, 688, 691, 695, 696,
1707 698, 700, 702, 704, 706, 708, 710, 712, 714, 718,
1708 720, 726, 728, 730, 732, 734, 736, 738, 741, 743,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001709 747, 750, 753, 757, 760, 761, 763, 766, 769, 773,
1710 783, 793, 802, 817, 819, 821, 828, 834, 837, 844,
1711 852, 857, 862, 869, 876, 877, 878, 882, 885, 887,
1712 893, 899, 906, 913, 918, 925, 930, 935, 942, 949,
1713 952, 961, 963, 965, 966, 970, 977, 981, 988, 991,
1714 997, 1005, 1011
Dan Gohman54392c12008-04-19 00:24:39 +00001715};
1716
1717/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1718static const yytype_int16 yyrhs[] =
1719{
Chris Lattnere7e9b602008-05-04 17:18:47 +00001720 211, 0, -1, 74, -1, 75, -1, 76, -1, 77,
1721 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1722 -1, 86, -1, 87, -1, 88, -1, 83, -1, 84,
1723 -1, 85, -1, 117, -1, 118, -1, 119, -1, 120,
1724 -1, 121, -1, 122, -1, 123, -1, 124, -1, 125,
1725 -1, 126, -1, 127, -1, 128, -1, 91, -1, 92,
1726 -1, 93, -1, 94, -1, 95, -1, 96, -1, 97,
1727 -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
1728 -1, 103, -1, 104, -1, 105, -1, 106, -1, 107,
1729 -1, 108, -1, 109, -1, 110, -1, 97, -1, 98,
1730 -1, 99, -1, 100, -1, 26, -1, 27, -1, 11,
Dan Gohman54392c12008-04-19 00:24:39 +00001731 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001732 -1, 19, -1, 22, -1, 24, -1, 173, -1, -1,
1733 54, 151, 4, 152, -1, -1, 173, 153, -1, -1,
1734 20, -1, 23, -1, 179, -1, -1, 177, 153, -1,
Dan Gohman54392c12008-04-19 00:24:39 +00001735 42, -1, 44, -1, 43, -1, 45, -1, 47, -1,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001736 46, -1, 48, -1, 50, -1, -1, 148, -1, 149,
1737 -1, 150, -1, -1, 46, -1, 48, -1, -1, 42,
Dan Gohman54392c12008-04-19 00:24:39 +00001738 -1, 43, -1, 44, -1, 47, -1, -1, 44, -1,
1739 42, -1, -1, 62, -1, 63, -1, 64, -1, 65,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001740 -1, 66, -1, 61, 4, -1, 137, -1, 118, -1,
1741 136, -1, 119, -1, 139, -1, 140, -1, 142, -1,
1742 143, -1, 144, -1, 53, 4, -1, -1, 188, 187,
1743 -1, 138, -1, 141, -1, 137, -1, 136, -1, 145,
1744 -1, 146, -1, -1, 190, 189, -1, -1, 147, 22,
1745 -1, -1, 53, 4, -1, -1, 154, 53, 4, -1,
1746 34, 22, -1, -1, 194, -1, -1, 154, 197, 196,
1747 -1, 194, -1, 53, 4, -1, 11, -1, 12, -1,
Dan Gohman54392c12008-04-19 00:24:39 +00001748 13, -1, 16, -1, 15, -1, 14, -1, 17, -1,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001749 49, -1, 198, -1, 199, 175, 155, -1, 233, -1,
1750 156, 4, -1, 199, 151, 203, 152, 190, -1, 10,
1751 151, 203, 152, 190, -1, 157, 4, 158, 199, 159,
1752 -1, 160, 4, 158, 199, 161, -1, 162, 204, 163,
1753 -1, 162, 163, -1, 160, 162, 204, 163, 161, -1,
1754 160, 162, 163, 161, -1, 199, 188, -1, 199, -1,
1755 10, -1, 200, -1, 202, 154, 200, -1, 202, -1,
1756 202, 154, 39, -1, 39, -1, -1, 199, -1, 204,
1757 154, 199, -1, 199, 157, 207, 159, -1, 199, 157,
1758 159, -1, 199, 164, 22, -1, 199, 160, 207, 161,
1759 -1, 199, 162, 207, 163, -1, 199, 162, 163, -1,
1760 199, 160, 162, 207, 163, 161, -1, 199, 160, 162,
1761 163, 161, -1, 199, 40, -1, 199, 41, -1, 199,
1762 233, -1, 199, 206, -1, 199, 25, -1, 171, 3,
1763 -1, 171, 5, -1, 171, 4, -1, 171, 6, -1,
1764 11, 26, -1, 11, 27, -1, 172, 9, -1, 168,
1765 151, 205, 38, 199, 152, -1, 116, 151, 205, 245,
1766 152, -1, 130, 151, 205, 154, 205, 154, 205, 152,
1767 -1, 166, 151, 205, 154, 205, 152, -1, 167, 151,
1768 205, 154, 205, 152, -1, 89, 169, 151, 205, 154,
1769 205, 152, -1, 90, 170, 151, 205, 154, 205, 152,
1770 -1, 132, 151, 205, 154, 205, 152, -1, 133, 151,
1771 205, 154, 205, 154, 205, 152, -1, 134, 151, 205,
1772 154, 205, 154, 205, 152, -1, 207, 154, 205, -1,
1773 205, -1, 32, -1, 33, -1, 37, -1, -1, 201,
1774 233, -1, 122, 151, 210, 38, 199, 152, -1, 212,
1775 -1, -1, 213, -1, 212, 213, -1, -1, 31, 214,
1776 229, -1, -1, 30, 215, 230, -1, 59, 58, 219,
1777 -1, 176, 18, 199, -1, 176, 18, 10, -1, -1,
1778 178, 182, 209, 208, 205, 175, 216, 196, -1, -1,
1779 178, 180, 182, 209, 208, 205, 175, 217, 196, -1,
1780 -1, 178, 181, 182, 209, 208, 199, 175, 218, 196,
1781 -1, 178, 182, 35, 185, 210, -1, 51, 220, -1,
1782 55, 153, 221, -1, 22, -1, 52, 153, 22, -1,
1783 67, 153, 22, -1, 157, 222, 159, -1, 222, 154,
1784 22, -1, 22, -1, -1, 223, 154, 199, 188, 174,
1785 -1, 199, 188, 174, -1, 223, -1, 223, 154, 39,
1786 -1, 39, -1, -1, 186, 201, 177, 151, 224, 152,
1787 190, 195, 192, 191, -1, 28, -1, 162, -1, 184,
1788 182, 225, 226, -1, 29, -1, 163, -1, 237, 228,
1789 -1, 183, 182, 225, -1, -1, 60, -1, 3, -1,
Dan Gohman54392c12008-04-19 00:24:39 +00001790 4, -1, 9, -1, 26, -1, 27, -1, 40, -1,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001791 41, -1, 25, -1, 160, 207, 161, -1, 206, -1,
1792 58, 231, 22, 154, 22, -1, 7, -1, 8, -1,
1793 173, -1, 177, -1, 233, -1, 232, -1, 199, 234,
1794 -1, 235, -1, 236, 154, 235, -1, 237, 238, -1,
1795 227, 238, -1, 239, 176, 240, -1, 239, 242, -1,
1796 -1, 21, -1, 68, 236, -1, 68, 10, -1, 69,
1797 17, 234, -1, 69, 11, 234, 154, 17, 234, 154,
1798 17, 234, -1, 70, 171, 234, 154, 17, 234, 157,
1799 241, 159, -1, 70, 171, 234, 154, 17, 234, 157,
1800 159, -1, 71, 186, 201, 234, 151, 244, 152, 190,
1801 38, 17, 234, 72, 17, 234, -1, 72, -1, 73,
1802 -1, 241, 171, 232, 154, 17, 234, -1, 171, 232,
1803 154, 17, 234, -1, 176, 247, -1, 199, 157, 234,
1804 154, 234, 159, -1, 243, 154, 157, 234, 154, 234,
1805 159, -1, 199, 188, 234, 188, -1, 17, 188, 234,
1806 188, -1, 244, 154, 199, 188, 234, 188, -1, 244,
1807 154, 17, 188, 234, 188, -1, -1, -1, 245, 154,
1808 235, -1, 57, 56, -1, 56, -1, 166, 199, 234,
1809 154, 234, -1, 167, 199, 234, 154, 234, -1, 89,
1810 169, 199, 234, 154, 234, -1, 90, 170, 199, 234,
1811 154, 234, -1, 168, 235, 38, 199, -1, 130, 235,
1812 154, 235, 154, 235, -1, 131, 235, 154, 199, -1,
1813 132, 235, 154, 235, -1, 133, 235, 154, 235, 154,
1814 235, -1, 134, 235, 154, 235, 154, 235, -1, 129,
1815 243, -1, 246, 186, 201, 234, 151, 244, 152, 190,
1816 -1, 249, -1, 36, -1, -1, 111, 199, 193, -1,
1817 111, 199, 154, 11, 234, 193, -1, 112, 199, 193,
1818 -1, 112, 199, 154, 11, 234, 193, -1, 113, 235,
1819 -1, 248, 114, 199, 234, 193, -1, 248, 115, 235,
1820 154, 199, 234, 193, -1, 135, 199, 234, 154, 4,
1821 -1, 116, 199, 234, 245, -1
Dan Gohman54392c12008-04-19 00:24:39 +00001822};
1823
1824/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1825static const yytype_uint16 yyrline[] =
1826{
Chris Lattnere7e9b602008-05-04 17:18:47 +00001827 0, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1828 1111, 1112, 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113,
1829 1113, 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1117,
1830 1117, 1118, 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125,
1831 1125, 1126, 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130,
1832 1130, 1131, 1131, 1132, 1133, 1138, 1139, 1139, 1139, 1139,
1833 1139, 1141, 1141, 1141, 1142, 1142, 1144, 1145, 1149, 1153,
1834 1158, 1158, 1160, 1161, 1166, 1172, 1173, 1174, 1175, 1176,
1835 1180, 1181, 1182, 1186, 1187, 1188, 1189, 1193, 1194, 1195,
1836 1199, 1200, 1201, 1202, 1203, 1207, 1208, 1209, 1212, 1213,
1837 1214, 1215, 1216, 1217, 1218, 1225, 1226, 1227, 1228, 1229,
1838 1230, 1231, 1232, 1233, 1234, 1238, 1239, 1244, 1245, 1246,
1839 1247, 1248, 1249, 1252, 1253, 1258, 1259, 1266, 1267, 1273,
1840 1274, 1283, 1291, 1292, 1297, 1298, 1299, 1304, 1317, 1317,
1841 1317, 1317, 1317, 1317, 1317, 1320, 1324, 1328, 1335, 1340,
1842 1348, 1377, 1402, 1407, 1417, 1427, 1431, 1441, 1448, 1457,
1843 1464, 1469, 1474, 1481, 1482, 1489, 1496, 1504, 1510, 1522,
1844 1550, 1566, 1593, 1621, 1647, 1667, 1693, 1713, 1725, 1732,
1845 1798, 1808, 1818, 1824, 1834, 1840, 1850, 1855, 1860, 1873,
1846 1885, 1907, 1915, 1921, 1932, 1937, 1942, 1948, 1954, 1963,
1847 1967, 1975, 1975, 1978, 1978, 1981, 1993, 2014, 2019, 2027,
1848 2028, 2032, 2032, 2036, 2036, 2039, 2042, 2066, 2078, 2077,
1849 2089, 2088, 2098, 2097, 2108, 2148, 2151, 2157, 2167, 2171,
1850 2176, 2178, 2183, 2188, 2197, 2207, 2218, 2222, 2231, 2240,
1851 2245, 2374, 2374, 2376, 2385, 2385, 2387, 2392, 2404, 2408,
1852 2413, 2417, 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2470,
1853 2474, 2484, 2488, 2492, 2497, 2504, 2504, 2510, 2519, 2524,
1854 2529, 2533, 2542, 2551, 2560, 2564, 2572, 2579, 2583, 2588,
1855 2598, 2617, 2626, 2711, 2715, 2722, 2733, 2746, 2756, 2767,
1856 2777, 2788, 2796, 2806, 2813, 2816, 2817, 2824, 2828, 2833,
1857 2849, 2866, 2880, 2894, 2906, 2914, 2921, 2927, 2933, 2939,
1858 2954, 3044, 3049, 3053, 3060, 3067, 3075, 3082, 3090, 3098,
1859 3112, 3129, 3137
Dan Gohman54392c12008-04-19 00:24:39 +00001860};
1861#endif
1862
1863#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1864/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1865 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1866static const char *const yytname[] =
1867{
1868 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1869 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1870 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1871 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1872 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1873 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1874 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1875 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1876 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1877 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1878 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1879 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Chris Lattnere7e9b602008-05-04 17:18:47 +00001880 "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE",
1881 "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM",
1882 "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE",
1883 "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE",
1884 "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC",
1885 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT",
1886 "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI",
1887 "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "VAARG",
1888 "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "GETRESULT",
1889 "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS",
1890 "BYVAL", "NEST", "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN",
1891 "PROTECTED", "'('", "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'",
1892 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1893 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1894 "FPType", "LocalName", "OptLocalName", "OptAddrSpace", "OptLocalAssign",
1895 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1896 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1897 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1898 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign",
1899 "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes",
Dan Gohman54392c12008-04-19 00:24:39 +00001900 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1901 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1902 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1903 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1904 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1905 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1906 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1907 "SymbolicValueRef", "ValueRef", "ResolvedVal", "ReturnedVal",
1908 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1909 "JumpTable", "Inst", "PHIList", "ParamList", "IndexList", "OptTailCall",
1910 "InstVal", "OptVolatile", "MemoryInst", 0
1911};
1912#endif
1913
1914# ifdef YYPRINT
1915/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1916 token YYLEX-NUM. */
1917static const yytype_uint16 yytoknum[] =
1918{
1919 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1920 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1921 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1922 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1923 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1924 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1925 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1926 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1927 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1928 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1929 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1930 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1931 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1932 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1933 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001934 405, 40, 41, 61, 44, 42, 92, 91, 120, 93,
1935 60, 62, 123, 125, 99
Dan Gohman54392c12008-04-19 00:24:39 +00001936};
1937# endif
1938
1939/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1940static const yytype_uint8 yyr1[] =
1941{
Chris Lattnere7e9b602008-05-04 17:18:47 +00001942 0, 165, 166, 166, 166, 166, 166, 166, 166, 166,
1943 166, 167, 167, 167, 167, 167, 167, 168, 168, 168,
1944 168, 168, 168, 168, 168, 168, 168, 168, 168, 169,
Dan Gohman54392c12008-04-19 00:24:39 +00001945 169, 169, 169, 169, 169, 169, 169, 169, 169, 170,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001946 170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
1947 170, 170, 170, 170, 170, 171, 172, 172, 172, 172,
1948 172, 173, 173, 173, 174, 174, 175, 175, 176, 176,
1949 177, 177, 178, 178, 179, 180, 180, 180, 180, 180,
1950 181, 181, 181, 182, 182, 182, 182, 183, 183, 183,
1951 184, 184, 184, 184, 184, 185, 185, 185, 186, 186,
1952 186, 186, 186, 186, 186, 187, 187, 187, 187, 187,
1953 187, 187, 187, 187, 187, 188, 188, 189, 189, 189,
1954 189, 189, 189, 190, 190, 191, 191, 192, 192, 193,
1955 193, 194, 195, 195, 196, 196, 197, 197, 198, 198,
1956 198, 198, 198, 198, 198, 199, 199, 199, 199, 199,
1957 199, 199, 199, 199, 199, 199, 199, 199, 200, 201,
1958 201, 202, 202, 203, 203, 203, 203, 204, 204, 205,
1959 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
1960 205, 205, 205, 205, 205, 205, 205, 205, 205, 206,
Dan Gohman54392c12008-04-19 00:24:39 +00001961 206, 206, 206, 206, 206, 206, 206, 206, 206, 207,
Chris Lattnere7e9b602008-05-04 17:18:47 +00001962 207, 208, 208, 209, 209, 210, 210, 211, 211, 212,
1963 212, 214, 213, 215, 213, 213, 213, 213, 216, 213,
1964 217, 213, 218, 213, 213, 213, 213, 219, 220, 220,
1965 221, 222, 222, 222, 223, 223, 224, 224, 224, 224,
1966 225, 226, 226, 227, 228, 228, 229, 230, 231, 231,
1967 232, 232, 232, 232, 232, 232, 232, 232, 232, 232,
1968 232, 233, 233, 233, 233, 234, 234, 235, 236, 236,
1969 237, 237, 238, 239, 239, 239, 240, 240, 240, 240,
1970 240, 240, 240, 240, 240, 241, 241, 242, 243, 243,
1971 244, 244, 244, 244, 244, 245, 245, 246, 246, 247,
1972 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
1973 247, 247, 248, 248, 249, 249, 249, 249, 249, 249,
1974 249, 249, 249
Dan Gohman54392c12008-04-19 00:24:39 +00001975};
1976
1977/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1978static const yytype_uint8 yyr2[] =
1979{
1980 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1981 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1982 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1983 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1984 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1985 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1986 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
1987 1, 1, 1, 0, 2, 1, 1, 1, 1, 1,
1988 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,
1989 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1990 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 2, 0, 2, 1, 1, 1,
1992 1, 1, 1, 0, 2, 0, 2, 0, 2, 0,
1993 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1994 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
1995 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
1996 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
1997 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
1998 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
1999 5, 8, 6, 6, 7, 7, 6, 8, 8, 3,
2000 1, 1, 1, 1, 0, 2, 6, 1, 0, 1,
2001 2, 0, 3, 0, 3, 3, 3, 3, 0, 8,
2002 0, 9, 0, 9, 5, 2, 3, 1, 3, 3,
2003 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
2004 10, 1, 1, 4, 1, 1, 2, 3, 0, 1,
2005 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
2006 5, 1, 1, 1, 1, 1, 1, 2, 1, 3,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002007 2, 2, 3, 2, 0, 1, 2, 2, 3, 9,
2008 9, 8, 14, 1, 1, 6, 5, 2, 6, 7,
2009 4, 4, 6, 6, 0, 0, 3, 2, 1, 5,
2010 5, 6, 6, 4, 6, 4, 4, 6, 6, 2,
2011 8, 1, 1, 0, 3, 6, 3, 6, 2, 5,
2012 7, 5, 4
Dan Gohman54392c12008-04-19 00:24:39 +00002013};
2014
2015/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2016 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2017 means the default is an error. */
2018static const yytype_uint16 yydefact[] =
2019{
2020 73, 61, 70, 62, 71, 63, 213, 211, 0, 0,
2021 0, 0, 0, 0, 83, 72, 0, 73, 209, 87,
2022 90, 0, 0, 225, 0, 0, 68, 0, 74, 75,
2023 77, 76, 78, 80, 79, 81, 82, 84, 85, 86,
2024 83, 83, 204, 1, 210, 88, 89, 83, 214, 91,
2025 92, 93, 94, 83, 274, 212, 274, 0, 0, 233,
2026 226, 227, 215, 261, 262, 217, 138, 139, 140, 143,
2027 142, 141, 144, 145, 0, 0, 0, 0, 263, 264,
2028 146, 216, 148, 204, 204, 95, 203, 0, 98, 98,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002029 275, 271, 69, 244, 245, 246, 270, 228, 229, 232,
2030 0, 166, 149, 0, 0, 0, 0, 155, 167, 0,
2031 0, 166, 0, 0, 0, 97, 96, 0, 201, 202,
2032 0, 0, 99, 100, 101, 102, 103, 0, 247, 0,
2033 313, 273, 0, 230, 165, 115, 161, 163, 0, 0,
2034 0, 0, 0, 0, 154, 0, 0, 147, 0, 0,
2035 160, 0, 159, 0, 224, 138, 139, 140, 143, 142,
2036 141, 0, 0, 67, 67, 104, 0, 241, 242, 243,
2037 312, 298, 0, 0, 0, 0, 98, 283, 284, 2,
2038 3, 4, 5, 6, 7, 8, 9, 10, 14, 15,
2039 16, 11, 12, 13, 0, 0, 0, 0, 0, 0,
2040 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
2041 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
2042 0, 0, 272, 98, 287, 0, 311, 231, 158, 0,
2043 123, 67, 67, 157, 0, 168, 0, 123, 67, 67,
2044 0, 205, 186, 187, 182, 184, 183, 185, 188, 181,
2045 177, 178, 0, 0, 0, 0, 0, 0, 0, 0,
2046 0, 0, 0, 0, 0, 0, 180, 179, 218, 0,
2047 297, 277, 67, 268, 276, 0, 0, 55, 0, 0,
2048 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
2049 0, 53, 54, 49, 50, 51, 52, 39, 40, 41,
2050 42, 43, 44, 45, 46, 47, 48, 0, 129, 129,
2051 318, 67, 67, 309, 0, 0, 0, 0, 0, 67,
2052 67, 67, 0, 0, 0, 0, 0, 106, 108, 107,
2053 105, 109, 110, 111, 112, 113, 116, 164, 162, 151,
2054 152, 153, 156, 66, 150, 220, 222, 0, 0, 0,
2055 0, 0, 0, 0, 0, 170, 200, 0, 0, 0,
2056 174, 0, 171, 0, 0, 0, 134, 239, 250, 251,
2057 252, 257, 253, 254, 255, 256, 248, 0, 259, 266,
2058 265, 267, 0, 0, 278, 0, 0, 67, 67, 0,
2059 314, 0, 316, 295, 0, 0, 0, 0, 0, 0,
2060 0, 0, 0, 0, 0, 0, 67, 0, 114, 120,
2061 119, 117, 118, 121, 122, 124, 134, 134, 0, 0,
2062 0, 295, 0, 0, 0, 0, 0, 169, 155, 167,
2063 0, 172, 173, 0, 0, 0, 0, 219, 238, 115,
2064 236, 0, 249, 0, 0, 269, 0, 0, 0, 0,
2065 0, 0, 0, 0, 322, 0, 0, 0, 305, 306,
2066 0, 0, 0, 0, 0, 303, 0, 129, 0, 221,
2067 223, 67, 0, 0, 0, 0, 0, 0, 0, 199,
2068 176, 0, 0, 0, 0, 0, 0, 136, 134, 65,
2069 0, 123, 0, 258, 0, 0, 294, 0, 0, 129,
2070 130, 129, 0, 0, 0, 0, 0, 0, 321, 299,
2071 300, 294, 0, 319, 67, 206, 0, 0, 190, 0,
2072 0, 0, 0, 175, 0, 0, 67, 131, 137, 135,
2073 64, 235, 237, 115, 132, 0, 0, 0, 115, 115,
2074 0, 301, 302, 315, 317, 296, 0, 0, 304, 307,
2075 308, 0, 129, 0, 0, 0, 196, 0, 0, 192,
2076 193, 189, 65, 133, 127, 260, 0, 0, 0, 0,
2077 123, 0, 288, 0, 123, 320, 194, 195, 0, 0,
2078 0, 234, 0, 125, 0, 281, 0, 0, 106, 108,
2079 115, 115, 0, 115, 115, 289, 310, 191, 197, 198,
2080 128, 0, 240, 279, 0, 280, 0, 291, 290, 0,
2081 0, 0, 126, 0, 0, 0, 115, 115, 0, 0,
2082 0, 293, 292, 286, 0, 0, 285, 0, 282
Dan Gohman54392c12008-04-19 00:24:39 +00002083};
2084
2085/* YYDEFGOTO[NTERM-NUM]. */
2086static const yytype_int16 yydefgoto[] =
2087{
Chris Lattnere7e9b602008-05-04 17:18:47 +00002088 -1, 263, 264, 265, 290, 307, 161, 162, 78, 531,
2089 112, 12, 79, 14, 15, 40, 41, 42, 47, 53,
2090 117, 127, 336, 228, 415, 339, 602, 583, 390, 487,
2091 564, 437, 488, 80, 163, 136, 153, 137, 138, 109,
2092 356, 378, 357, 120, 87, 154, 16, 17, 18, 20,
2093 19, 366, 416, 417, 62, 23, 60, 100, 440, 441,
2094 128, 169, 54, 95, 55, 48, 443, 379, 82, 381,
2095 273, 274, 56, 91, 92, 222, 587, 131, 313, 540,
2096 454, 223, 224, 225, 226
Dan Gohman54392c12008-04-19 00:24:39 +00002097};
2098
2099/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2100 STATE-NUM. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00002101#define YYPACT_NINF -561
Dan Gohman54392c12008-04-19 00:24:39 +00002102static const yytype_int16 yypact[] =
2103{
Chris Lattnere7e9b602008-05-04 17:18:47 +00002104 284, -561, -561, -561, -561, -561, -561, -561, -34, -121,
2105 14, -63, 101, -22, 17, -561, 127, 883, -561, 22,
2106 162, 10, 23, -561, 12, 158, -561, 1464, -561, -561,
2107 -561, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2108 -46, -46, 176, -561, -561, -561, -561, -46, -561, -561,
2109 -561, -561, -561, -46, 200, -561, -10, 209, 219, 234,
2110 -561, -561, -561, -561, -561, 124, -561, -561, -561, -561,
2111 -561, -561, -561, -561, 272, 275, 2, 126, -561, -561,
2112 -561, 28, -561, 243, 243, 196, -561, 165, 33, 33,
2113 -561, -561, 215, -561, -561, -561, -561, -561, -561, -561,
2114 -73, 1059, -561, 129, 132, 506, 124, -561, 28, -111,
2115 134, 1059, 137, 165, 165, -561, -561, 1014, -561, -561,
2116 1504, 292, -561, -561, -561, -561, -561, 1562, -561, -6,
2117 1843, -561, 278, -561, -561, 28, -561, 147, 153, 1620,
2118 1620, 148, -110, 1620, -561, 309, 164, -561, 1504, 1620,
2119 124, 166, 28, 388, -561, 342, 310, 311, 314, 316,
2120 317, 156, 322, 1115, 279, -561, 16, -561, -561, -561,
2121 -561, -561, 281, 1660, 20, 327, 33, -561, -561, -561,
2122 -561, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2123 -561, -561, -561, -561, 511, 787, 1620, 1620, 1620, 1620,
2124 -561, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2125 -561, -561, 1620, 1620, 1620, 1620, 1620, 1620, 1620, 1620,
2126 1620, 1620, -561, 33, -561, -60, -561, -561, 434, 1345,
2127 -561, -7, -33, -561, 181, 28, 192, -561, 279, -16,
2128 1014, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2129 -561, -561, 511, 787, 198, 199, 201, 203, 204, 1385,
2130 1678, 609, 329, 207, 208, 210, -561, -561, -561, 211,
2131 -561, 124, 702, -561, 206, 841, 841, -561, 841, 1562,
2132 -561, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2133 1620, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2134 -561, -561, -561, -561, -561, -561, -561, 1620, 100, 114,
2135 -561, 702, -31, 222, 225, 227, 228, 235, 239, 702,
2136 702, 702, 325, 1562, 1620, 1620, 360, -561, -561, -561,
2137 -561, -561, -561, -561, -561, -561, -561, -561, -561, -96,
2138 -561, -561, -561, -561, -96, -561, 137, 361, 247, 252,
2139 1504, 1504, 1504, 1504, 1504, -561, -561, -54, 788, -88,
2140 -561, -85, -561, 1504, 1504, 1504, 250, 1406, -561, -561,
2141 -561, -561, -561, -561, -561, -561, 345, 1504, -561, -561,
2142 -561, -561, 1620, 255, -561, 259, 841, 702, 702, 4,
2143 -561, 5, -561, -561, 841, 249, 1620, 1620, 1620, 1620,
2144 1620, 261, 262, 263, 1620, 841, 702, 266, -561, -561,
2145 -561, -561, -561, -561, -561, -561, 250, 250, 1620, 1504,
2146 1504, -561, 269, 274, 276, 277, 1504, -561, 265, 969,
2147 -83, -561, -561, 282, 283, 391, -5, -561, -561, 28,
2148 285, 289, -561, 413, -78, -561, 426, 427, 294, 293,
2149 295, 841, 442, 841, 296, 299, 841, 300, 28, -561,
2150 301, 302, 444, 841, 841, 28, 306, 305, 1620, -561,
2151 -561, -45, 307, 308, 94, 1504, 1504, 1504, 1504, -561,
2152 -561, 312, 1504, 1504, 1620, 438, 463, -561, 250, 1746,
2153 1446, -561, 315, -561, 841, 841, 1718, 841, 841, 305,
2154 -561, 305, 1620, 841, 318, 1620, 1620, 1620, -561, -561,
2155 -561, 1718, 415, -561, 702, -561, 1504, 1504, -561, 320,
2156 323, 324, 328, -561, 331, 332, -30, -561, -561, -561,
2157 -561, -561, -561, 28, 81, 455, 334, 333, 123, 28,
2158 95, -561, -561, -561, -561, -561, 335, 841, -561, -561,
2159 -561, 98, 305, 339, 343, 1504, -561, 1504, 1504, -561,
2160 -561, -561, 1746, -561, 433, -561, 479, -4, 560, 560,
2161 -561, 1736, -561, 341, -561, -561, -561, -561, 346, 349,
2162 351, -561, 500, 358, 841, -561, 1255, -1, 355, 356,
2163 -561, -561, 87, 123, 28, -561, -96, -561, -561, -561,
2164 -561, 489, -561, -561, 370, -561, 1255, 434, 434, 495,
2165 560, 560, -561, 498, 373, 841, -561, -561, 841, 514,
2166 460, 434, 434, -561, 841, 516, -561, 841, -561
Dan Gohman54392c12008-04-19 00:24:39 +00002167};
2168
2169/* YYPGOTO[NTERM-NUM]. */
2170static const yytype_int16 yypgoto[] =
2171{
Chris Lattnere7e9b602008-05-04 17:18:47 +00002172 -561, 406, 407, 408, 298, 303, -173, -561, 0, -15,
2173 -150, 454, 8, -561, -561, -561, -561, 189, -561, -561,
2174 -561, -149, -561, -409, -561, -234, -561, -561, -289, 24,
2175 -561, -404, -561, -561, -26, 330, -122, -561, 443, 452,
2176 -92, -159, -226, 102, 183, 321, -561, -561, 548, -561,
2177 -561, -561, -561, -561, -561, -561, -561, -561, -561, -561,
2178 477, -561, -561, -561, -561, -561, -561, -560, -76, 46,
2179 -105, -561, -561, 519, -561, -561, -561, -561, -561, 61,
2180 160, -561, -561, -561, -561
Dan Gohman54392c12008-04-19 00:24:39 +00002181};
2182
2183/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2184 positive, shift that token. If negative, reduce the rule which
2185 number is the opposite. If zero, do what YYDEFACT says.
2186 If YYTABLE_NINF, syntax error. */
2187#define YYTABLE_NINF -209
2188static const yytype_int16 yytable[] =
2189{
Chris Lattnere7e9b602008-05-04 17:18:47 +00002190 11, 81, 278, 344, 266, 166, 104, 277, 13, 110,
2191 277, 90, 469, 470, 268, 451, 453, 11, 21, 93,
2192 392, 110, 167, 110, 110, 13, 604, 279, 164, 485,
2193 489, 275, 24, 22, 359, 361, 2, 276, 110, 4,
2194 409, 410, 411, 143, 143, 412, 614, 110, 486, 413,
2195 414, 108, 144, 234, 324, 325, 238, 452, 452, 29,
2196 30, 31, 32, 33, 34, 35, 426, 36, 45, 426,
2197 46, 426, 25, 431, 323, 135, 426, 241, 432, 108,
2198 481, 132, 110, 493, 529, 135, 133, 267, 345, 346,
2199 26, 152, 11, 310, 121, 122, 123, 124, 125, 126,
2200 426, 152, 37, 38, 39, 427, 111, 515, 314, 315,
2201 316, 317, 318, 231, 232, 485, 322, 235, 111, 27,
2202 111, 111, 561, 239, 562, 609, 394, 43, 341, 568,
2203 569, 28, 430, 63, 64, 111, 106, 66, 67, 68,
2204 69, 70, 71, 72, 111, 1, 2, 272, 3, 4,
2205 5, 444, 340, 94, 110, 585, 168, 386, 605, 244,
2206 245, 246, 247, 57, 105, 37, 38, 39, 110, 59,
2207 308, 309, 272, 311, 269, 73, 58, -144, 513, 111,
2208 61, 607, 608, -67, 610, 611, 312, 272, 272, 272,
2209 272, 272, 319, 320, 321, 272, 380, 118, 119, 380,
2210 380, 405, 380, 135, 49, 50, 51, 621, 622, 52,
2211 543, 85, 544, 86, 152, 148, 149, 409, 410, 411,
2212 407, 90, 412, 409, 410, 411, 413, 414, 412, 83,
2213 84, 97, 413, 414, 1, 380, 88, 3, 115, 5,
2214 116, 98, 89, 380, 380, 380, 518, 570, 502, 571,
2215 574, 111, 571, 152, 389, -67, 99, 534, 421, 422,
2216 423, 424, 425, 575, 387, 111, 113, 114, 391, -67,
2217 266, 433, 434, 435, -144, 101, 102, 445, -144, 103,
2218 86, 388, 74, 75, -208, 145, 76, 139, 77, 107,
2219 140, 457, 147, 459, 460, 461, 165, 152, 406, 272,
2220 227, 229, -69, 1, 2, 230, 3, 4, 5, 233,
2221 380, 380, 380, 236, 6, 7, 237, 240, 380, -56,
2222 -57, 383, 384, -60, 385, -59, -58, 472, 473, 380,
2223 380, 248, 429, 110, 479, 8, 592, 270, 277, 9,
2224 596, 439, 342, 10, 343, -55, -55, -55, -55, 350,
2225 351, 362, 352, 267, 353, 354, 272, 393, 363, 364,
2226 382, 365, 367, 404, 408, 401, 402, 403, 242, 243,
2227 272, 458, 272, 272, 272, 380, 395, 380, 465, 396,
2228 380, 397, 398, 519, 520, 521, 522, 380, 380, 399,
2229 524, 525, 471, 400, 586, 63, 64, 545, 419, 418,
2230 548, 549, 550, 420, 436, 442, 456, 1, 2, 446,
2231 3, 4, 5, 447, 606, 462, 463, 464, 380, 380,
2232 468, 380, 380, 475, 553, 554, 480, 380, 476, 484,
2233 477, 478, 448, 449, 450, 492, 482, 483, 380, 490,
2234 455, 491, 514, 494, 495, 496, 500, 497, 508, 498,
2235 502, 466, 467, 503, 505, 506, 507, 511, 526, 512,
2236 527, 516, 517, 578, 533, 579, 580, 528, 452, 535,
2237 539, 380, 547, 523, 555, 556, 272, 565, 557, 272,
2238 272, 272, 558, 559, 560, 539, 582, 326, 566, 530,
2239 567, 576, 380, 380, 572, 577, 584, 499, 597, 501,
2240 595, 598, 504, 599, 600, 601, -18, -19, 380, 509,
2241 510, 612, 615, 63, 64, 618, 106, 66, 67, 68,
2242 69, 70, 71, 72, 613, 1, 2, 619, 3, 4,
2243 5, 624, 625, 627, 380, 380, 219, 220, 221, 380,
2244 536, 537, 380, 541, 542, 594, 130, 581, 380, 546,
2245 348, 380, 327, 328, 146, 73, 349, 142, 563, 338,
2246 552, 347, 530, 368, 369, 44, 129, 63, 64, 370,
2247 329, 330, 551, 331, 332, 96, 333, 334, 335, 1,
2248 2, 474, 3, 4, 5, 371, 372, 373, 0, 0,
2249 0, 0, 0, 573, 0, 0, 0, 0, 0, 0,
2250 374, 375, 280, 281, 282, 283, 284, 285, 286, 287,
2251 288, 289, 0, 326, 590, 591, 63, 64, 376, 106,
2252 155, 156, 157, 158, 159, 160, 72, 0, 1, 2,
2253 603, 3, 4, 5, 179, 180, 181, 182, 183, 184,
2254 185, 186, 187, 188, 189, 190, 191, 192, 193, 252,
2255 253, 0, 0, 0, 0, 0, 616, 617, 73, 0,
2256 0, 620, 74, 75, 623, 0, 76, 0, 77, 141,
2257 626, 0, 0, 628, 0, 0, 254, 200, 588, 589,
2258 203, 204, 205, 206, 207, 208, 209, 210, 211, 0,
2259 255, 0, 256, 257, 258, 0, 329, 330, 0, 331,
2260 332, 0, 333, 334, 335, 368, 369, 0, 0, 63,
2261 64, 370, 0, 0, 0, 0, 0, 0, 0, 0,
2262 377, 1, 2, 0, 3, 4, 5, 371, 372, 373,
Dan Gohman54392c12008-04-19 00:24:39 +00002263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002264 0, 0, 374, 375, 0, 0, 0, 0, 0, 0,
2265 0, 0, 0, 0, 0, 0, 110, 0, 0, 0,
2266 376, 0, 0, 0, 0, 74, 75, 0, 0, 76,
2267 0, 77, 360, 0, 0, 0, 179, 180, 181, 182,
Dan Gohman54392c12008-04-19 00:24:39 +00002268 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002269 193, 252, 253, 0, 0, 63, 64, 0, 106, 155,
2270 156, 157, 158, 159, 160, 72, 0, 1, 2, 0,
2271 3, 4, 5, 291, 292, 0, 0, 0, 254, 200,
Dan Gohman54392c12008-04-19 00:24:39 +00002272 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002273 211, 0, 255, 0, 256, 257, 258, 73, 0, 0,
2274 0, 0, 0, 0, 368, 369, 0, 0, 63, 64,
2275 370, 0, 0, 111, 0, 0, 0, 0, 0, 0,
2276 1, 2, 377, 3, 4, 5, 371, 372, 373, 0,
Dan Gohman54392c12008-04-19 00:24:39 +00002277 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002278 0, 374, 375, -207, 293, 294, 295, 296, 297, 298,
2279 299, 300, 301, 302, 303, 304, 305, 306, 0, 376,
2280 0, -69, 1, 2, 0, 3, 4, 5, 0, 0,
2281 0, 0, 0, 6, 7, 179, 180, 181, 182, 183,
2282 184, 185, 186, 187, 188, 189, 190, 191, 192, 193,
2283 252, 253, 0, 0, 8, 0, 0, 0, 9, 0,
2284 0, 0, 10, 0, 74, 75, 0, 0, 76, 0,
2285 77, 428, 0, 0, 0, 0, 0, 254, 200, 201,
2286 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
2287 0, 255, 0, 256, 257, 258, 63, 64, 0, 0,
2288 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
2289 0, 3, 4, 5, 249, 0, 0, 0, 0, 0,
2290 0, 377, 0, 0, 0, 0, 0, 0, 0, 250,
2291 251, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2292 0, 63, 64, 110, 150, 66, 67, 68, 69, 70,
2293 71, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2294 0, 0, 0, 179, 180, 181, 182, 183, 184, 185,
2295 186, 187, 188, 189, 190, 191, 192, 193, 252, 253,
2296 0, 0, 0, 73, 0, 0, 63, 64, 0, 106,
2297 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2298 0, 3, 4, 5, 0, 254, 200, 201, 202, 203,
2299 204, 205, 206, 207, 208, 209, 210, 211, 134, 255,
2300 0, 256, 257, 258, 0, 0, 0, 0, 73, 0,
2301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2302 111, 0, 63, 64, -67, 0, 259, 0, 0, 260,
2303 0, 261, 0, 262, 1, 2, 151, 3, 4, 5,
2304 249, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2305 0, 0, 0, 0, 0, 250, 251, 0, 0, 0,
2306 0, 0, 0, 0, 0, 0, 0, 0, 0, 110,
2307 74, 75, 0, 0, 76, 0, 77, 0, 0, 0,
2308 0, 0, 0, 0, 0, 0, 0, 0, 0, 179,
2309 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2310 190, 191, 192, 193, 252, 253, 0, 0, 0, 0,
2311 0, 0, 0, 0, 0, 74, 75, 0, 0, 76,
2312 0, 77, 0, 0, 0, 0, 0, 0, 0, 0,
2313 0, 254, 200, 201, 202, 203, 204, 205, 206, 207,
2314 208, 209, 210, 211, 0, 255, 0, 256, 257, 258,
2315 0, 0, 0, 0, 0, 0, 0, 0, 368, 369,
2316 0, 0, 0, 0, 370, 0, 111, 0, 0, 0,
2317 0, 0, 259, 0, 0, 260, 0, 261, 0, 262,
2318 371, 372, 373, 0, 0, 0, 0, 0, 0, 0,
2319 0, 0, 0, 0, 0, 374, 375, 0, 0, 0,
2320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2321 0, 0, 0, 376, 0, 0, 0, 0, 0, 0,
2322 0, 0, 0, 0, 0, 0, 0, 0, 0, 179,
2323 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2324 190, 191, 192, 193, 252, 253, 0, 0, 0, 0,
2325 0, 0, 63, 64, 0, 106, 66, 67, 68, 69,
2326 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2327 0, 254, 200, 201, 202, 203, 204, 205, 206, 207,
2328 208, 209, 210, 211, 337, 255, 0, 256, 257, 258,
2329 0, 0, 63, 64, 73, 106, 155, 156, 157, 158,
2330 159, 160, 72, 0, 1, 2, 0, 3, 4, 5,
2331 0, 0, 0, 63, 64, 377, 106, 66, 67, 68,
2332 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2333 5, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 438, 0, 0, 0, 0,
2335 0, 0, 0, 63, 64, 73, 106, 66, 67, 68,
2336 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2337 5, 63, 64, 0, 65, 66, 67, 68, 69, 70,
2338 71, 72, 0, 1, 2, 532, 3, 4, 5, 0,
2339 0, 0, 0, 0, 0, 73, 0, 0, 0, 0,
2340 0, 74, 75, 0, 0, 76, 0, 77, 0, 0,
2341 0, 63, 64, 73, 106, 155, 156, 157, 158, 159,
2342 160, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 74, 75, 0, 355, 76, 0, 77, 0, 0,
2345 0, 0, 0, 73, 0, 0, 0, 0, 0, 0,
2346 0, 0, 74, 75, 0, 0, 76, 0, 77, 63,
2347 64, 0, 150, 66, 67, 68, 69, 70, 71, 72,
2348 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2349 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2350 0, 0, 74, 75, 0, 0, 76, 0, 77, 0,
2351 0, 73, 0, 0, 0, 0, 0, 0, 0, 0,
2352 74, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2353 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2354 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2355 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2356 74, 75, 0, 0, 76, 0, 77, 63, 64, 73,
2357 271, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2358 2, 0, 3, 4, 5, 63, 64, 0, 106, 155,
2359 156, 157, 158, 159, 160, 72, 0, 1, 2, 0,
2360 3, 4, 5, 0, 0, 0, 0, 0, 0, 73,
2361 0, 0, 0, 0, 0, 0, 0, 0, 74, 75,
2362 0, 0, 76, 0, 77, 63, 64, 73, 106, 66,
2363 67, 68, 69, 70, 71, 538, 0, 1, 2, 0,
2364 3, 4, 5, 63, 64, 0, 106, 66, 67, 68,
2365 69, 70, 71, 593, 0, 1, 2, 0, 3, 4,
2366 5, 0, 0, 0, 0, 1, 0, 73, 3, 0,
2367 5, 0, 0, 0, 0, 0, 74, 75, 0, 0,
2368 76, 0, 77, 0, 0, 73, 0, 0, 0, 0,
2369 0, 0, 0, 0, 0, 0, 0, 0, 0, 326,
2370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2371 0, 0, 0, 0, 0, 0, 74, 75, 0, 0,
2372 76, 0, 77, 0, 0, 0, 0, 0, 0, 0,
2373 0, 0, 0, 0, 74, 75, 0, 0, 76, 0,
2374 358, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2376 0, 0, 0, 0, 327, 328, 0, 0, 0, 0,
2377 0, 0, 0, 0, 74, 75, 0, 0, 76, 170,
2378 77, 0, 329, 330, 0, 331, 332, 0, 333, 334,
2379 335, 0, 74, 75, 0, 0, 76, 0, 77, 171,
2380 172, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2381 0, 173, 174, 175, 176, 177, 178, 179, 180, 181,
2382 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2383 192, 193, 194, 195, 0, 0, 0, 0, 0, 0,
2384 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2385 0, 0, 0, 0, 196, 197, 198, 0, 0, 199,
2386 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
2387 210, 211, 212, 213, 214, 215, 216, 217, 218
Dan Gohman54392c12008-04-19 00:24:39 +00002388};
2389
2390static const yytype_int16 yycheck[] =
2391{
Chris Lattnere7e9b602008-05-04 17:18:47 +00002392 0, 27, 175, 237, 163, 127, 4, 11, 0, 54,
2393 11, 21, 416, 417, 164, 11, 11, 17, 52, 29,
2394 309, 54, 28, 54, 54, 17, 586, 176, 120, 34,
2395 439, 11, 153, 67, 260, 261, 20, 17, 54, 23,
2396 136, 137, 138, 154, 154, 141, 606, 54, 53, 145,
2397 146, 77, 163, 163, 114, 115, 148, 53, 53, 42,
2398 43, 44, 45, 46, 47, 48, 154, 50, 46, 154,
2399 48, 154, 58, 161, 223, 101, 154, 153, 163, 105,
2400 163, 154, 54, 161, 488, 111, 159, 163, 238, 239,
2401 153, 117, 92, 198, 61, 62, 63, 64, 65, 66,
2402 154, 127, 148, 149, 150, 159, 151, 152, 213, 214,
2403 215, 216, 217, 139, 140, 34, 221, 143, 151, 18,
2404 151, 151, 152, 149, 533, 38, 157, 0, 161, 538,
2405 539, 153, 358, 7, 8, 151, 10, 11, 12, 13,
2406 14, 15, 16, 17, 151, 19, 20, 173, 22, 23,
2407 24, 377, 159, 163, 54, 159, 162, 279, 159, 3,
2408 4, 5, 6, 153, 162, 148, 149, 150, 54, 157,
2409 196, 197, 198, 199, 166, 49, 153, 54, 467, 151,
2410 22, 590, 591, 155, 593, 594, 212, 213, 214, 215,
2411 216, 217, 218, 219, 220, 221, 272, 32, 33, 275,
2412 276, 323, 278, 229, 42, 43, 44, 616, 617, 47,
2413 499, 35, 501, 37, 240, 113, 114, 136, 137, 138,
2414 325, 21, 141, 136, 137, 138, 145, 146, 141, 40,
2415 41, 22, 145, 146, 19, 311, 47, 22, 42, 24,
2416 44, 22, 53, 319, 320, 321, 152, 152, 154, 154,
2417 152, 151, 154, 279, 154, 155, 22, 491, 350, 351,
2418 352, 353, 354, 552, 290, 151, 83, 84, 154, 155,
2419 429, 363, 364, 365, 151, 151, 4, 382, 155, 4,
2420 37, 307, 156, 157, 0, 151, 160, 158, 162, 163,
2421 158, 396, 155, 398, 399, 400, 4, 323, 324, 325,
2422 22, 154, 18, 19, 20, 152, 22, 23, 24, 161,
2423 386, 387, 388, 4, 30, 31, 152, 151, 394, 9,
2424 9, 275, 276, 9, 278, 9, 9, 419, 420, 405,
2425 406, 9, 358, 54, 426, 51, 570, 56, 11, 55,
2426 574, 367, 161, 59, 152, 3, 4, 5, 6, 151,
2427 151, 22, 151, 429, 151, 151, 382, 311, 151, 151,
2428 154, 151, 151, 38, 4, 319, 320, 321, 26, 27,
2429 396, 397, 398, 399, 400, 451, 154, 453, 404, 154,
2430 456, 154, 154, 475, 476, 477, 478, 463, 464, 154,
2431 482, 483, 418, 154, 567, 7, 8, 502, 151, 38,
2432 505, 506, 507, 151, 154, 60, 157, 19, 20, 154,
2433 22, 23, 24, 154, 587, 154, 154, 154, 494, 495,
2434 154, 497, 498, 154, 516, 517, 161, 503, 154, 38,
2435 154, 154, 386, 387, 388, 22, 154, 154, 514, 154,
2436 394, 152, 468, 17, 17, 151, 4, 154, 4, 154,
2437 154, 405, 406, 154, 154, 154, 154, 151, 484, 154,
2438 22, 154, 154, 555, 490, 557, 558, 4, 53, 154,
2439 496, 547, 154, 161, 154, 152, 502, 22, 154, 505,
2440 506, 507, 154, 152, 152, 511, 53, 53, 154, 489,
2441 157, 152, 568, 569, 159, 152, 17, 451, 152, 453,
2442 159, 152, 456, 152, 4, 147, 151, 151, 584, 463,
2443 464, 22, 17, 7, 8, 17, 10, 11, 12, 13,
2444 14, 15, 16, 17, 154, 19, 20, 154, 22, 23,
2445 24, 17, 72, 17, 610, 611, 130, 130, 130, 615,
2446 494, 495, 618, 497, 498, 571, 92, 562, 624, 503,
2447 252, 627, 118, 119, 111, 49, 253, 105, 534, 229,
2448 514, 240, 562, 3, 4, 17, 89, 7, 8, 9,
2449 136, 137, 511, 139, 140, 56, 142, 143, 144, 19,
2450 20, 421, 22, 23, 24, 25, 26, 27, -1, -1,
2451 -1, -1, -1, 547, -1, -1, -1, -1, -1, -1,
2452 40, 41, 91, 92, 93, 94, 95, 96, 97, 98,
2453 99, 100, -1, 53, 568, 569, 7, 8, 58, 10,
2454 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2455 584, 22, 23, 24, 74, 75, 76, 77, 78, 79,
2456 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2457 90, -1, -1, -1, -1, -1, 610, 611, 49, -1,
2458 -1, 615, 156, 157, 618, -1, 160, -1, 162, 163,
2459 624, -1, -1, 627, -1, -1, 116, 117, 118, 119,
2460 120, 121, 122, 123, 124, 125, 126, 127, 128, -1,
2461 130, -1, 132, 133, 134, -1, 136, 137, -1, 139,
2462 140, -1, 142, 143, 144, 3, 4, -1, -1, 7,
2463 8, 9, -1, -1, -1, -1, -1, -1, -1, -1,
2464 160, 19, 20, -1, 22, 23, 24, 25, 26, 27,
Dan Gohman54392c12008-04-19 00:24:39 +00002465 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2466 -1, -1, 40, 41, -1, -1, -1, -1, -1, -1,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002467 -1, -1, -1, -1, -1, -1, 54, -1, -1, -1,
2468 58, -1, -1, -1, -1, 156, 157, -1, -1, 160,
2469 -1, 162, 163, -1, -1, -1, 74, 75, 76, 77,
Dan Gohman54392c12008-04-19 00:24:39 +00002470 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002471 88, 89, 90, -1, -1, 7, 8, -1, 10, 11,
2472 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2473 22, 23, 24, 26, 27, -1, -1, -1, 116, 117,
Dan Gohman54392c12008-04-19 00:24:39 +00002474 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002475 128, -1, 130, -1, 132, 133, 134, 49, -1, -1,
2476 -1, -1, -1, -1, 3, 4, -1, -1, 7, 8,
2477 9, -1, -1, 151, -1, -1, -1, -1, -1, -1,
2478 19, 20, 160, 22, 23, 24, 25, 26, 27, -1,
Dan Gohman54392c12008-04-19 00:24:39 +00002479 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002480 -1, 40, 41, 0, 97, 98, 99, 100, 101, 102,
2481 103, 104, 105, 106, 107, 108, 109, 110, -1, 58,
2482 -1, 18, 19, 20, -1, 22, 23, 24, -1, -1,
2483 -1, -1, -1, 30, 31, 74, 75, 76, 77, 78,
2484 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2485 89, 90, -1, -1, 51, -1, -1, -1, 55, -1,
2486 -1, -1, 59, -1, 156, 157, -1, -1, 160, -1,
2487 162, 163, -1, -1, -1, -1, -1, 116, 117, 118,
2488 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2489 -1, 130, -1, 132, 133, 134, 7, 8, -1, -1,
2490 -1, -1, -1, -1, -1, -1, -1, -1, 19, 20,
2491 -1, 22, 23, 24, 25, -1, -1, -1, -1, -1,
2492 -1, 160, -1, -1, -1, -1, -1, -1, -1, 40,
2493 41, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2494 -1, 7, 8, 54, 10, 11, 12, 13, 14, 15,
2495 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2496 -1, -1, -1, 74, 75, 76, 77, 78, 79, 80,
2497 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2498 -1, -1, -1, 49, -1, -1, 7, 8, -1, 10,
2499 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2500 -1, 22, 23, 24, -1, 116, 117, 118, 119, 120,
2501 121, 122, 123, 124, 125, 126, 127, 128, 39, 130,
2502 -1, 132, 133, 134, -1, -1, -1, -1, 49, -1,
2503 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2504 151, -1, 7, 8, 155, -1, 157, -1, -1, 160,
2505 -1, 162, -1, 164, 19, 20, 122, 22, 23, 24,
2506 25, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2507 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2508 -1, -1, -1, -1, -1, -1, -1, -1, -1, 54,
2509 156, 157, -1, -1, 160, -1, 162, -1, -1, -1,
2510 -1, -1, -1, -1, -1, -1, -1, -1, -1, 74,
2511 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2512 85, 86, 87, 88, 89, 90, -1, -1, -1, -1,
2513 -1, -1, -1, -1, -1, 156, 157, -1, -1, 160,
2514 -1, 162, -1, -1, -1, -1, -1, -1, -1, -1,
2515 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2516 125, 126, 127, 128, -1, 130, -1, 132, 133, 134,
2517 -1, -1, -1, -1, -1, -1, -1, -1, 3, 4,
2518 -1, -1, -1, -1, 9, -1, 151, -1, -1, -1,
2519 -1, -1, 157, -1, -1, 160, -1, 162, -1, 164,
2520 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2521 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2522 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2523 -1, -1, -1, 58, -1, -1, -1, -1, -1, -1,
2524 -1, -1, -1, -1, -1, -1, -1, -1, -1, 74,
2525 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2526 85, 86, 87, 88, 89, 90, -1, -1, -1, -1,
2527 -1, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2528 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2529 -1, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2530 125, 126, 127, 128, 39, 130, -1, 132, 133, 134,
2531 -1, -1, 7, 8, 49, 10, 11, 12, 13, 14,
2532 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2533 -1, -1, -1, 7, 8, 160, 10, 11, 12, 13,
2534 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2535 24, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2536 -1, -1, -1, -1, -1, 39, -1, -1, -1, -1,
2537 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
2538 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2539 24, 7, 8, -1, 10, 11, 12, 13, 14, 15,
2540 16, 17, -1, 19, 20, 39, 22, 23, 24, -1,
2541 -1, -1, -1, -1, -1, 49, -1, -1, -1, -1,
2542 -1, 156, 157, -1, -1, 160, -1, 162, -1, -1,
2543 -1, 7, 8, 49, 10, 11, 12, 13, 14, 15,
2544 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2545 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2546 -1, 156, 157, -1, 159, 160, -1, 162, -1, -1,
2547 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
2548 -1, -1, 156, 157, -1, -1, 160, -1, 162, 7,
2549 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2550 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2551 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2552 -1, -1, 156, 157, -1, -1, 160, -1, 162, -1,
2553 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
2554 156, 157, -1, -1, 160, -1, 162, 7, 8, -1,
2555 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2556 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2557 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2558 156, 157, -1, -1, 160, -1, 162, 7, 8, 49,
2559 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2560 20, -1, 22, 23, 24, 7, 8, -1, 10, 11,
2561 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2562 22, 23, 24, -1, -1, -1, -1, -1, -1, 49,
2563 -1, -1, -1, -1, -1, -1, -1, -1, 156, 157,
2564 -1, -1, 160, -1, 162, 7, 8, 49, 10, 11,
2565 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2566 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
2567 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2568 24, -1, -1, -1, -1, 19, -1, 49, 22, -1,
2569 24, -1, -1, -1, -1, -1, 156, 157, -1, -1,
2570 160, -1, 162, -1, -1, 49, -1, -1, -1, -1,
2571 -1, -1, -1, -1, -1, -1, -1, -1, -1, 53,
2572 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2573 -1, -1, -1, -1, -1, -1, 156, 157, -1, -1,
2574 160, -1, 162, -1, -1, -1, -1, -1, -1, -1,
2575 -1, -1, -1, -1, 156, 157, -1, -1, 160, -1,
2576 162, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2578 -1, -1, -1, -1, 118, 119, -1, -1, -1, -1,
2579 -1, -1, -1, -1, 156, 157, -1, -1, 160, 36,
2580 162, -1, 136, 137, -1, 139, 140, -1, 142, 143,
2581 144, -1, 156, 157, -1, -1, 160, -1, 162, 56,
2582 57, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2583 -1, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2584 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2585 87, 88, 89, 90, -1, -1, -1, -1, -1, -1,
2586 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2587 -1, -1, -1, -1, 111, 112, 113, -1, -1, 116,
2588 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2589 127, 128, 129, 130, 131, 132, 133, 134, 135
Dan Gohman54392c12008-04-19 00:24:39 +00002590};
2591
2592/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2593 symbol of state STATE-NUM. */
2594static const yytype_uint8 yystos[] =
2595{
2596 0, 19, 20, 22, 23, 24, 30, 31, 51, 55,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002597 59, 173, 176, 177, 178, 179, 211, 212, 213, 215,
2598 214, 52, 67, 220, 153, 58, 153, 18, 153, 42,
2599 43, 44, 45, 46, 47, 48, 50, 148, 149, 150,
2600 180, 181, 182, 0, 213, 46, 48, 183, 230, 42,
2601 43, 44, 47, 184, 227, 229, 237, 153, 153, 157,
2602 221, 22, 219, 7, 8, 10, 11, 12, 13, 14,
2603 15, 16, 17, 49, 156, 157, 160, 162, 173, 177,
2604 198, 199, 233, 182, 182, 35, 37, 209, 182, 182,
2605 21, 238, 239, 29, 163, 228, 238, 22, 22, 22,
2606 222, 151, 4, 4, 4, 162, 10, 163, 199, 204,
2607 54, 151, 175, 209, 209, 42, 44, 185, 32, 33,
2608 208, 61, 62, 63, 64, 65, 66, 186, 225, 225,
2609 176, 242, 154, 159, 39, 199, 200, 202, 203, 158,
2610 158, 163, 204, 154, 163, 151, 203, 155, 208, 208,
2611 10, 122, 199, 201, 210, 11, 12, 13, 14, 15,
2612 16, 171, 172, 199, 205, 4, 201, 28, 162, 226,
2613 36, 56, 57, 68, 69, 70, 71, 72, 73, 74,
2614 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2615 85, 86, 87, 88, 89, 90, 111, 112, 113, 116,
Dan Gohman54392c12008-04-19 00:24:39 +00002616 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
Chris Lattnere7e9b602008-05-04 17:18:47 +00002617 127, 128, 129, 130, 131, 132, 133, 134, 135, 166,
2618 167, 168, 240, 246, 247, 248, 249, 22, 188, 154,
2619 152, 199, 199, 161, 163, 199, 4, 152, 205, 199,
2620 151, 233, 26, 27, 3, 4, 5, 6, 9, 25,
2621 40, 41, 89, 90, 116, 130, 132, 133, 134, 157,
2622 160, 162, 164, 166, 167, 168, 206, 233, 175, 177,
2623 56, 10, 199, 235, 236, 11, 17, 11, 171, 186,
2624 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2625 169, 26, 27, 97, 98, 99, 100, 101, 102, 103,
2626 104, 105, 106, 107, 108, 109, 110, 170, 199, 199,
2627 235, 199, 199, 243, 235, 235, 235, 235, 235, 199,
2628 199, 199, 235, 186, 114, 115, 53, 118, 119, 136,
2629 137, 139, 140, 142, 143, 144, 187, 39, 200, 190,
2630 159, 161, 161, 152, 190, 175, 175, 210, 169, 170,
2631 151, 151, 151, 151, 151, 159, 205, 207, 162, 207,
2632 163, 207, 22, 151, 151, 151, 216, 151, 3, 4,
2633 9, 25, 26, 27, 40, 41, 58, 160, 206, 232,
2634 233, 234, 154, 234, 234, 234, 201, 199, 199, 154,
2635 193, 154, 193, 234, 157, 154, 154, 154, 154, 154,
2636 154, 234, 234, 234, 38, 201, 199, 235, 4, 136,
2637 137, 138, 141, 145, 146, 189, 217, 218, 38, 151,
2638 151, 205, 205, 205, 205, 205, 154, 159, 163, 199,
2639 207, 161, 163, 205, 205, 205, 154, 196, 39, 199,
2640 223, 224, 60, 231, 207, 235, 154, 154, 234, 234,
2641 234, 11, 53, 11, 245, 234, 157, 235, 199, 235,
2642 235, 235, 154, 154, 154, 199, 234, 234, 154, 196,
2643 196, 199, 205, 205, 245, 154, 154, 154, 154, 205,
2644 161, 163, 154, 154, 38, 34, 53, 194, 197, 188,
2645 154, 152, 22, 161, 17, 17, 151, 154, 154, 234,
2646 4, 234, 154, 154, 234, 154, 154, 154, 4, 234,
2647 234, 151, 154, 193, 199, 152, 154, 154, 152, 205,
2648 205, 205, 205, 161, 205, 205, 199, 22, 4, 196,
2649 173, 174, 39, 199, 190, 154, 234, 234, 17, 199,
2650 244, 234, 234, 193, 193, 235, 234, 154, 235, 235,
2651 235, 244, 234, 205, 205, 154, 152, 154, 154, 152,
2652 152, 152, 188, 194, 195, 22, 154, 157, 188, 188,
2653 152, 154, 159, 234, 152, 193, 152, 152, 205, 205,
2654 205, 174, 53, 192, 17, 159, 171, 241, 118, 119,
2655 234, 234, 190, 17, 199, 159, 190, 152, 152, 152,
2656 4, 147, 191, 234, 232, 159, 171, 188, 188, 38,
2657 188, 188, 22, 154, 232, 17, 234, 234, 17, 154,
2658 234, 188, 188, 234, 17, 72, 234, 17, 234
Dan Gohman54392c12008-04-19 00:24:39 +00002659};
David Greene9145dd22007-08-01 03:59:32 +00002660
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002661#define yyerrok (yyerrstatus = 0)
2662#define yyclearin (yychar = YYEMPTY)
Dan Gohman54392c12008-04-19 00:24:39 +00002663#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002664#define YYEOF 0
Dan Gohman54392c12008-04-19 00:24:39 +00002665
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666#define YYACCEPT goto yyacceptlab
Dan Gohman54392c12008-04-19 00:24:39 +00002667#define YYABORT goto yyabortlab
2668#define YYERROR goto yyerrorlab
2669
2670
2671/* Like YYERROR except do call yyerror. This remains here temporarily
2672 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673 Once GCC version 2 has supplanted version 1, this can go. */
Dan Gohman54392c12008-04-19 00:24:39 +00002674
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002675#define YYFAIL goto yyerrlab
Dan Gohman54392c12008-04-19 00:24:39 +00002676
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677#define YYRECOVERING() (!!yyerrstatus)
Dan Gohman54392c12008-04-19 00:24:39 +00002678
2679#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002680do \
2681 if (yychar == YYEMPTY && yylen == 1) \
Dan Gohman54392c12008-04-19 00:24:39 +00002682 { \
2683 yychar = (Token); \
2684 yylval = (Value); \
2685 yytoken = YYTRANSLATE (yychar); \
2686 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002687 goto yybackup; \
2688 } \
2689 else \
Dan Gohman54392c12008-04-19 00:24:39 +00002690 { \
2691 yyerror (YY_("syntax error: cannot back up")); \
2692 YYERROR; \
2693 } \
2694while (YYID (0))
2695
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002696
2697#define YYTERROR 1
2698#define YYERRCODE 256
2699
Dan Gohman54392c12008-04-19 00:24:39 +00002700
2701/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2702 If N is 0, then set CURRENT to the empty location which ends
2703 the previous symbol: RHS[0] (always defined). */
2704
2705#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2706#ifndef YYLLOC_DEFAULT
2707# define YYLLOC_DEFAULT(Current, Rhs, N) \
2708 do \
2709 if (YYID (N)) \
2710 { \
2711 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2712 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2713 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2714 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2715 } \
2716 else \
2717 { \
2718 (Current).first_line = (Current).last_line = \
2719 YYRHSLOC (Rhs, 0).last_line; \
2720 (Current).first_column = (Current).last_column = \
2721 YYRHSLOC (Rhs, 0).last_column; \
2722 } \
2723 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724#endif
2725
Dan Gohman54392c12008-04-19 00:24:39 +00002726
2727/* YY_LOCATION_PRINT -- Print the location on the stream.
2728 This macro was not mandated originally: define only if we know
2729 we won't break user code: when these are the locations we know. */
2730
2731#ifndef YY_LOCATION_PRINT
2732# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2733# define YY_LOCATION_PRINT(File, Loc) \
2734 fprintf (File, "%d.%d-%d.%d", \
2735 (Loc).first_line, (Loc).first_column, \
2736 (Loc).last_line, (Loc).last_column)
2737# else
2738# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2739# endif
2740#endif
2741
2742
2743/* YYLEX -- calling `yylex' with the right arguments. */
2744
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002745#ifdef YYLEX_PARAM
Dan Gohman54392c12008-04-19 00:24:39 +00002746# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002747#else
Dan Gohman54392c12008-04-19 00:24:39 +00002748# define YYLEX yylex ()
Gabor Greif89f01162008-04-06 23:07:54 +00002749#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002750
2751/* Enable debugging if requested. */
2752#if YYDEBUG
2753
2754# ifndef YYFPRINTF
2755# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2756# define YYFPRINTF fprintf
2757# endif
2758
2759# define YYDPRINTF(Args) \
2760do { \
2761 if (yydebug) \
2762 YYFPRINTF Args; \
2763} while (YYID (0))
2764
2765# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2766do { \
2767 if (yydebug) \
2768 { \
2769 YYFPRINTF (stderr, "%s ", Title); \
2770 yy_symbol_print (stderr, \
2771 Type, Value); \
2772 YYFPRINTF (stderr, "\n"); \
2773 } \
2774} while (YYID (0))
2775
2776
2777/*--------------------------------.
2778| Print this symbol on YYOUTPUT. |
2779`--------------------------------*/
2780
2781/*ARGSUSED*/
2782#if (defined __STDC__ || defined __C99__FUNC__ \
2783 || defined __cplusplus || defined _MSC_VER)
2784static void
2785yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Gabor Greif89f01162008-04-06 23:07:54 +00002786#else
Dan Gohman54392c12008-04-19 00:24:39 +00002787static void
2788yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2789 FILE *yyoutput;
2790 int yytype;
2791 YYSTYPE const * const yyvaluep;
Gabor Greif89f01162008-04-06 23:07:54 +00002792#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002793{
2794 if (!yyvaluep)
2795 return;
2796# ifdef YYPRINT
2797 if (yytype < YYNTOKENS)
2798 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2799# else
2800 YYUSE (yyoutput);
2801# endif
2802 switch (yytype)
2803 {
2804 default:
2805 break;
2806 }
2807}
2808
2809
2810/*--------------------------------.
2811| Print this symbol on YYOUTPUT. |
2812`--------------------------------*/
2813
2814#if (defined __STDC__ || defined __C99__FUNC__ \
2815 || defined __cplusplus || defined _MSC_VER)
2816static void
2817yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2818#else
2819static void
2820yy_symbol_print (yyoutput, yytype, yyvaluep)
2821 FILE *yyoutput;
2822 int yytype;
2823 YYSTYPE const * const yyvaluep;
Scott Michel6d1aba82008-01-30 03:10:00 +00002824#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002825{
2826 if (yytype < YYNTOKENS)
2827 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2828 else
2829 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Chris Lattner59363a32008-02-19 04:36:25 +00002830
Dan Gohman54392c12008-04-19 00:24:39 +00002831 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2832 YYFPRINTF (yyoutput, ")");
2833}
Chris Lattner59363a32008-02-19 04:36:25 +00002834
Dan Gohman54392c12008-04-19 00:24:39 +00002835/*------------------------------------------------------------------.
2836| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2837| TOP (included). |
2838`------------------------------------------------------------------*/
Chris Lattner59363a32008-02-19 04:36:25 +00002839
Dan Gohman54392c12008-04-19 00:24:39 +00002840#if (defined __STDC__ || defined __C99__FUNC__ \
2841 || defined __cplusplus || defined _MSC_VER)
2842static void
2843yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2844#else
2845static void
2846yy_stack_print (bottom, top)
2847 yytype_int16 *bottom;
2848 yytype_int16 *top;
Scott Michel6d1aba82008-01-30 03:10:00 +00002849#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002850{
2851 YYFPRINTF (stderr, "Stack now");
2852 for (; bottom <= top; ++bottom)
2853 YYFPRINTF (stderr, " %d", *bottom);
2854 YYFPRINTF (stderr, "\n");
2855}
Chris Lattner59363a32008-02-19 04:36:25 +00002856
Dan Gohman54392c12008-04-19 00:24:39 +00002857# define YY_STACK_PRINT(Bottom, Top) \
2858do { \
2859 if (yydebug) \
2860 yy_stack_print ((Bottom), (Top)); \
2861} while (YYID (0))
Chris Lattner59363a32008-02-19 04:36:25 +00002862
Dan Gohman54392c12008-04-19 00:24:39 +00002863
2864/*------------------------------------------------.
2865| Report that the YYRULE is going to be reduced. |
2866`------------------------------------------------*/
2867
2868#if (defined __STDC__ || defined __C99__FUNC__ \
2869 || defined __cplusplus || defined _MSC_VER)
2870static void
2871yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2872#else
2873static void
2874yy_reduce_print (yyvsp, yyrule)
2875 YYSTYPE *yyvsp;
2876 int yyrule;
Christopher Lamb0a243582007-12-11 09:02:08 +00002877#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002878{
2879 int yynrhs = yyr2[yyrule];
2880 int yyi;
2881 unsigned long int yylno = yyrline[yyrule];
2882 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2883 yyrule - 1, yylno);
2884 /* The symbols being reduced. */
2885 for (yyi = 0; yyi < yynrhs; yyi++)
2886 {
2887 fprintf (stderr, " $%d = ", yyi + 1);
2888 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2889 &(yyvsp[(yyi + 1) - (yynrhs)])
2890 );
2891 fprintf (stderr, "\n");
2892 }
2893}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002894
Dan Gohman54392c12008-04-19 00:24:39 +00002895# define YY_REDUCE_PRINT(Rule) \
2896do { \
2897 if (yydebug) \
2898 yy_reduce_print (yyvsp, Rule); \
2899} while (YYID (0))
Scott Michel5a6f17b2008-01-30 02:55:46 +00002900
Dan Gohman54392c12008-04-19 00:24:39 +00002901/* Nonzero means print parse trace. It is left uninitialized so that
2902 multiple parsers can coexist. */
2903int yydebug;
2904#else /* !YYDEBUG */
2905# define YYDPRINTF(Args)
2906# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2907# define YY_STACK_PRINT(Bottom, Top)
2908# define YY_REDUCE_PRINT(Rule)
2909#endif /* !YYDEBUG */
2910
2911
2912/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913#ifndef YYINITDEPTH
Dan Gohman54392c12008-04-19 00:24:39 +00002914# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915#endif
2916
Dan Gohman54392c12008-04-19 00:24:39 +00002917/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2918 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002919
Dan Gohman54392c12008-04-19 00:24:39 +00002920 Do not make this value too large; the results are undefined if
2921 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2922 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002923
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924#ifndef YYMAXDEPTH
Dan Gohman54392c12008-04-19 00:24:39 +00002925# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002926#endif
Dan Gohman54392c12008-04-19 00:24:39 +00002927
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002929
Dan Gohman54392c12008-04-19 00:24:39 +00002930#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931
Dan Gohman54392c12008-04-19 00:24:39 +00002932# ifndef yystrlen
2933# if defined __GLIBC__ && defined _STRING_H
2934# define yystrlen strlen
2935# else
2936/* Return the length of YYSTR. */
2937#if (defined __STDC__ || defined __C99__FUNC__ \
2938 || defined __cplusplus || defined _MSC_VER)
2939static YYSIZE_T
2940yystrlen (const char *yystr)
Chris Lattner59363a32008-02-19 04:36:25 +00002941#else
Dan Gohman54392c12008-04-19 00:24:39 +00002942static YYSIZE_T
2943yystrlen (yystr)
2944 const char *yystr;
2945#endif
2946{
2947 YYSIZE_T yylen;
2948 for (yylen = 0; yystr[yylen]; yylen++)
2949 continue;
2950 return yylen;
2951}
2952# endif
2953# endif
2954
2955# ifndef yystpcpy
2956# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2957# define yystpcpy stpcpy
2958# else
2959/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2960 YYDEST. */
2961#if (defined __STDC__ || defined __C99__FUNC__ \
2962 || defined __cplusplus || defined _MSC_VER)
2963static char *
2964yystpcpy (char *yydest, const char *yysrc)
2965#else
2966static char *
2967yystpcpy (yydest, yysrc)
2968 char *yydest;
2969 const char *yysrc;
2970#endif
2971{
2972 char *yyd = yydest;
2973 const char *yys = yysrc;
2974
2975 while ((*yyd++ = *yys++) != '\0')
2976 continue;
2977
2978 return yyd - 1;
2979}
2980# endif
2981# endif
2982
2983# ifndef yytnamerr
2984/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2985 quotes and backslashes, so that it's suitable for yyerror. The
2986 heuristic is that double-quoting is unnecessary unless the string
2987 contains an apostrophe, a comma, or backslash (other than
2988 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2989 null, do not copy; instead, return the length of what the result
2990 would have been. */
2991static YYSIZE_T
2992yytnamerr (char *yyres, const char *yystr)
2993{
2994 if (*yystr == '"')
2995 {
2996 YYSIZE_T yyn = 0;
2997 char const *yyp = yystr;
2998
2999 for (;;)
3000 switch (*++yyp)
3001 {
3002 case '\'':
3003 case ',':
3004 goto do_not_strip_quotes;
3005
3006 case '\\':
3007 if (*++yyp != '\\')
3008 goto do_not_strip_quotes;
3009 /* Fall through. */
3010 default:
3011 if (yyres)
3012 yyres[yyn] = *yyp;
3013 yyn++;
3014 break;
3015
3016 case '"':
3017 if (yyres)
3018 yyres[yyn] = '\0';
3019 return yyn;
3020 }
3021 do_not_strip_quotes: ;
3022 }
3023
3024 if (! yyres)
3025 return yystrlen (yystr);
3026
3027 return yystpcpy (yyres, yystr) - yyres;
3028}
3029# endif
3030
3031/* Copy into YYRESULT an error message about the unexpected token
3032 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3033 including the terminating null byte. If YYRESULT is null, do not
3034 copy anything; just return the number of bytes that would be
3035 copied. As a special case, return 0 if an ordinary "syntax error"
3036 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3037 size calculation. */
3038static YYSIZE_T
3039yysyntax_error (char *yyresult, int yystate, int yychar)
3040{
3041 int yyn = yypact[yystate];
3042
3043 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3044 return 0;
3045 else
3046 {
3047 int yytype = YYTRANSLATE (yychar);
3048 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3049 YYSIZE_T yysize = yysize0;
3050 YYSIZE_T yysize1;
3051 int yysize_overflow = 0;
3052 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3053 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3054 int yyx;
3055
3056# if 0
3057 /* This is so xgettext sees the translatable formats that are
3058 constructed on the fly. */
3059 YY_("syntax error, unexpected %s");
3060 YY_("syntax error, unexpected %s, expecting %s");
3061 YY_("syntax error, unexpected %s, expecting %s or %s");
3062 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3063 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3064# endif
3065 char *yyfmt;
3066 char const *yyf;
3067 static char const yyunexpected[] = "syntax error, unexpected %s";
3068 static char const yyexpecting[] = ", expecting %s";
3069 static char const yyor[] = " or %s";
3070 char yyformat[sizeof yyunexpected
3071 + sizeof yyexpecting - 1
3072 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3073 * (sizeof yyor - 1))];
3074 char const *yyprefix = yyexpecting;
3075
3076 /* Start YYX at -YYN if negative to avoid negative indexes in
3077 YYCHECK. */
3078 int yyxbegin = yyn < 0 ? -yyn : 0;
3079
3080 /* Stay within bounds of both yycheck and yytname. */
3081 int yychecklim = YYLAST - yyn + 1;
3082 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3083 int yycount = 1;
3084
3085 yyarg[0] = yytname[yytype];
3086 yyfmt = yystpcpy (yyformat, yyunexpected);
3087
3088 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3089 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3090 {
3091 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3092 {
3093 yycount = 1;
3094 yysize = yysize0;
3095 yyformat[sizeof yyunexpected - 1] = '\0';
3096 break;
3097 }
3098 yyarg[yycount++] = yytname[yyx];
3099 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3100 yysize_overflow |= (yysize1 < yysize);
3101 yysize = yysize1;
3102 yyfmt = yystpcpy (yyfmt, yyprefix);
3103 yyprefix = yyor;
3104 }
3105
3106 yyf = YY_(yyformat);
3107 yysize1 = yysize + yystrlen (yyf);
3108 yysize_overflow |= (yysize1 < yysize);
3109 yysize = yysize1;
3110
3111 if (yysize_overflow)
3112 return YYSIZE_MAXIMUM;
3113
3114 if (yyresult)
3115 {
3116 /* Avoid sprintf, as that infringes on the user's name space.
3117 Don't have undefined behavior even if the translation
3118 produced a string with the wrong number of "%s"s. */
3119 char *yyp = yyresult;
3120 int yyi = 0;
3121 while ((*yyp = *yyf) != '\0')
3122 {
3123 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3124 {
3125 yyp += yytnamerr (yyp, yyarg[yyi++]);
3126 yyf += 2;
3127 }
3128 else
3129 {
3130 yyp++;
3131 yyf++;
3132 }
3133 }
3134 }
3135 return yysize;
3136 }
3137}
3138#endif /* YYERROR_VERBOSE */
3139
3140
3141/*-----------------------------------------------.
3142| Release the memory associated to this symbol. |
3143`-----------------------------------------------*/
3144
3145/*ARGSUSED*/
3146#if (defined __STDC__ || defined __C99__FUNC__ \
3147 || defined __cplusplus || defined _MSC_VER)
3148static void
3149yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3150#else
3151static void
3152yydestruct (yymsg, yytype, yyvaluep)
3153 const char *yymsg;
3154 int yytype;
3155 YYSTYPE *yyvaluep;
3156#endif
3157{
3158 YYUSE (yyvaluep);
3159
3160 if (!yymsg)
3161 yymsg = "Deleting";
3162 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3163
3164 switch (yytype)
3165 {
3166
3167 default:
3168 break;
3169 }
3170}
3171
3172
3173/* Prevent warnings from -Wmissing-prototypes. */
3174
3175#ifdef YYPARSE_PARAM
3176#if defined __STDC__ || defined __cplusplus
3177int yyparse (void *YYPARSE_PARAM);
3178#else
3179int yyparse ();
3180#endif
3181#else /* ! YYPARSE_PARAM */
3182#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003183int yyparse (void);
Gabor Greif89f01162008-04-06 23:07:54 +00003184#else
Dan Gohman54392c12008-04-19 00:24:39 +00003185int yyparse ();
Scott Michel6d1aba82008-01-30 03:10:00 +00003186#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003187#endif /* ! YYPARSE_PARAM */
Scott Michel5a6f17b2008-01-30 02:55:46 +00003188
Chris Lattner59363a32008-02-19 04:36:25 +00003189
Dan Gohman54392c12008-04-19 00:24:39 +00003190
3191/* The look-ahead symbol. */
3192int yychar;
3193
3194/* The semantic value of the look-ahead symbol. */
3195YYSTYPE yylval;
3196
3197/* Number of syntax errors so far. */
3198int yynerrs;
3199
3200
3201
3202/*----------.
3203| yyparse. |
3204`----------*/
3205
3206#ifdef YYPARSE_PARAM
3207#if (defined __STDC__ || defined __C99__FUNC__ \
3208 || defined __cplusplus || defined _MSC_VER)
3209int
3210yyparse (void *YYPARSE_PARAM)
3211#else
3212int
3213yyparse (YYPARSE_PARAM)
3214 void *YYPARSE_PARAM;
3215#endif
3216#else /* ! YYPARSE_PARAM */
3217#if (defined __STDC__ || defined __C99__FUNC__ \
3218 || defined __cplusplus || defined _MSC_VER)
3219int
3220yyparse (void)
3221#else
3222int
3223yyparse ()
3224
Gabor Greif89f01162008-04-06 23:07:54 +00003225#endif
3226#endif
Dan Gohman54392c12008-04-19 00:24:39 +00003227{
3228
3229 int yystate;
3230 int yyn;
3231 int yyresult;
3232 /* Number of tokens to shift before error messages enabled. */
3233 int yyerrstatus;
3234 /* Look-ahead token as an internal (translated) token number. */
3235 int yytoken = 0;
3236#if YYERROR_VERBOSE
3237 /* Buffer for error messages, and its allocated size. */
3238 char yymsgbuf[128];
3239 char *yymsg = yymsgbuf;
3240 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Gabor Greif89f01162008-04-06 23:07:54 +00003241#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003242
Dan Gohman54392c12008-04-19 00:24:39 +00003243 /* Three stacks and their tools:
3244 `yyss': related to states,
3245 `yyvs': related to semantic values,
3246 `yyls': related to locations.
3247
3248 Refer to the stacks thru separate pointers, to allow yyoverflow
3249 to reallocate them elsewhere. */
3250
3251 /* The state stack. */
3252 yytype_int16 yyssa[YYINITDEPTH];
3253 yytype_int16 *yyss = yyssa;
3254 yytype_int16 *yyssp;
3255
3256 /* The semantic value stack. */
3257 YYSTYPE yyvsa[YYINITDEPTH];
3258 YYSTYPE *yyvs = yyvsa;
3259 YYSTYPE *yyvsp;
3260
3261
3262
3263#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3264
3265 YYSIZE_T yystacksize = YYINITDEPTH;
3266
3267 /* The variables used to return semantic value and location from the
3268 action routines. */
3269 YYSTYPE yyval;
3270
3271
3272 /* The number of symbols on the RHS of the reduced rule.
3273 Keep to zero when no symbol should be popped. */
3274 int yylen = 0;
3275
3276 YYDPRINTF ((stderr, "Starting parse\n"));
3277
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003278 yystate = 0;
3279 yyerrstatus = 0;
3280 yynerrs = 0;
3281 yychar = YYEMPTY; /* Cause a token to be read. */
3282
3283 /* Initialize stack pointers.
3284 Waste one element of value and location stack
3285 so that they stay on the same level as the state stack.
3286 The wasted elements are never initialized. */
3287
Dan Gohman54392c12008-04-19 00:24:39 +00003288 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003289 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290
Dan Gohman54392c12008-04-19 00:24:39 +00003291 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003292
Dan Gohman54392c12008-04-19 00:24:39 +00003293/*------------------------------------------------------------.
3294| yynewstate -- Push a new state, which is found in yystate. |
3295`------------------------------------------------------------*/
3296 yynewstate:
3297 /* In all cases, when you get here, the value and location stacks
3298 have just been pushed. So pushing a state here evens the stacks. */
3299 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300
Dan Gohman54392c12008-04-19 00:24:39 +00003301 yysetstate:
3302 *yyssp = yystate;
3303
3304 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003305 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 /* Get the current used size of the three stacks, in elements. */
Dan Gohman54392c12008-04-19 00:24:39 +00003307 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308
3309#ifdef yyoverflow
Dan Gohman54392c12008-04-19 00:24:39 +00003310 {
3311 /* Give user a chance to reallocate the stack. Use copies of
3312 these so that the &'s don't force the real ones into
3313 memory. */
3314 YYSTYPE *yyvs1 = yyvs;
3315 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003316
Dan Gohman54392c12008-04-19 00:24:39 +00003317
3318 /* Each stack pointer address is followed by the size of the
3319 data in use in that stack, in bytes. This used to be a
3320 conditional around just the two extra args, but that might
3321 be undefined if yyoverflow is a macro. */
3322 yyoverflow (YY_("memory exhausted"),
3323 &yyss1, yysize * sizeof (*yyssp),
3324 &yyvs1, yysize * sizeof (*yyvsp),
3325
3326 &yystacksize);
3327
3328 yyss = yyss1;
3329 yyvs = yyvs1;
3330 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331#else /* no yyoverflow */
Dan Gohman54392c12008-04-19 00:24:39 +00003332# ifndef YYSTACK_RELOCATE
3333 goto yyexhaustedlab;
3334# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003335 /* Extend the stack our own way. */
Dan Gohman54392c12008-04-19 00:24:39 +00003336 if (YYMAXDEPTH <= yystacksize)
3337 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003338 yystacksize *= 2;
Dan Gohman54392c12008-04-19 00:24:39 +00003339 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003340 yystacksize = YYMAXDEPTH;
Dan Gohman54392c12008-04-19 00:24:39 +00003341
3342 {
3343 yytype_int16 *yyss1 = yyss;
3344 union yyalloc *yyptr =
3345 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3346 if (! yyptr)
3347 goto yyexhaustedlab;
3348 YYSTACK_RELOCATE (yyss);
3349 YYSTACK_RELOCATE (yyvs);
3350
3351# undef YYSTACK_RELOCATE
3352 if (yyss1 != yyssa)
3353 YYSTACK_FREE (yyss1);
3354 }
3355# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356#endif /* no yyoverflow */
3357
Dan Gohman54392c12008-04-19 00:24:39 +00003358 yyssp = yyss + yysize - 1;
3359 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003361
Dan Gohman54392c12008-04-19 00:24:39 +00003362 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3363 (unsigned long int) yystacksize));
3364
3365 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 YYABORT;
3367 }
3368
Dan Gohman54392c12008-04-19 00:24:39 +00003369 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370
3371 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003372
Dan Gohman54392c12008-04-19 00:24:39 +00003373/*-----------.
3374| yybackup. |
3375`-----------*/
3376yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377
Dan Gohman54392c12008-04-19 00:24:39 +00003378 /* Do appropriate processing given the current state. Read a
3379 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003380
Dan Gohman54392c12008-04-19 00:24:39 +00003381 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003382 yyn = yypact[yystate];
Dan Gohman54392c12008-04-19 00:24:39 +00003383 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003384 goto yydefault;
3385
Dan Gohman54392c12008-04-19 00:24:39 +00003386 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387
Dan Gohman54392c12008-04-19 00:24:39 +00003388 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389 if (yychar == YYEMPTY)
3390 {
Dan Gohman54392c12008-04-19 00:24:39 +00003391 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003392 yychar = YYLEX;
3393 }
3394
Dan Gohman54392c12008-04-19 00:24:39 +00003395 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003396 {
Dan Gohman54392c12008-04-19 00:24:39 +00003397 yychar = yytoken = YYEOF;
3398 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003399 }
3400 else
3401 {
Dan Gohman54392c12008-04-19 00:24:39 +00003402 yytoken = YYTRANSLATE (yychar);
3403 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404 }
3405
Dan Gohman54392c12008-04-19 00:24:39 +00003406 /* If the proper action on seeing token YYTOKEN is to reduce or to
3407 detect an error, take that action. */
3408 yyn += yytoken;
3409 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003410 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003411 yyn = yytable[yyn];
Dan Gohman54392c12008-04-19 00:24:39 +00003412 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003413 {
Dan Gohman54392c12008-04-19 00:24:39 +00003414 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003415 goto yyerrlab;
3416 yyn = -yyn;
3417 goto yyreduce;
3418 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003419
3420 if (yyn == YYFINAL)
3421 YYACCEPT;
3422
Dan Gohman54392c12008-04-19 00:24:39 +00003423 /* Count tokens shifted since error; after three, turn off error
3424 status. */
3425 if (yyerrstatus)
3426 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003427
Dan Gohman54392c12008-04-19 00:24:39 +00003428 /* Shift the look-ahead token. */
3429 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003430
Dan Gohman54392c12008-04-19 00:24:39 +00003431 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432 if (yychar != YYEOF)
3433 yychar = YYEMPTY;
3434
Gabor Greif89f01162008-04-06 23:07:54 +00003435 yystate = yyn;
Dan Gohman54392c12008-04-19 00:24:39 +00003436 *++yyvsp = yylval;
3437
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003438 goto yynewstate;
3439
Gabor Greif89f01162008-04-06 23:07:54 +00003440
Dan Gohman54392c12008-04-19 00:24:39 +00003441/*-----------------------------------------------------------.
3442| yydefault -- do the default action for the current state. |
3443`-----------------------------------------------------------*/
3444yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003445 yyn = yydefact[yystate];
3446 if (yyn == 0)
3447 goto yyerrlab;
Dan Gohman54392c12008-04-19 00:24:39 +00003448 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003449
Dan Gohman54392c12008-04-19 00:24:39 +00003450
3451/*-----------------------------.
3452| yyreduce -- Do a reduction. |
3453`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003454yyreduce:
Dan Gohman54392c12008-04-19 00:24:39 +00003455 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003456 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457
Dan Gohman54392c12008-04-19 00:24:39 +00003458 /* If YYLEN is nonzero, implement the default value of the action:
3459 `$$ = $1'.
3460
3461 Otherwise, the following line sets YYVAL to garbage.
3462 This behavior is undocumented and Bison
3463 users should not rely upon it. Assigning to YYVAL
3464 unconditionally makes the parser a bit smaller, and it avoids a
3465 GCC warning that YYVAL may be used uninitialized. */
3466 yyval = yyvsp[1-yylen];
3467
3468
3469 YY_REDUCE_PRINT (yyn);
3470 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003471 {
Dan Gohman54392c12008-04-19 00:24:39 +00003472 case 29:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003473#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003474 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3475 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003476
Dan Gohman54392c12008-04-19 00:24:39 +00003477 case 30:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003478#line 1117 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003479 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3480 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003481
Dan Gohman54392c12008-04-19 00:24:39 +00003482 case 31:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003483#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003484 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3485 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003486
Dan Gohman54392c12008-04-19 00:24:39 +00003487 case 32:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003488#line 1118 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003489 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3490 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003491
Dan Gohman54392c12008-04-19 00:24:39 +00003492 case 33:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003493#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003494 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3495 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496
Dan Gohman54392c12008-04-19 00:24:39 +00003497 case 34:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003498#line 1119 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003499 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3500 break;
3501
3502 case 35:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003503#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003504 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3505 break;
3506
3507 case 36:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003508#line 1120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003509 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3510 break;
3511
3512 case 37:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003513#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003514 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3515 break;
3516
3517 case 38:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003518#line 1121 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003519 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3520 break;
3521
3522 case 39:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003523#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003524 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3525 break;
3526
3527 case 40:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003528#line 1125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003529 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3530 break;
3531
3532 case 41:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003533#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003534 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3535 break;
3536
3537 case 42:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003538#line 1126 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003539 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3540 break;
3541
3542 case 43:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003543#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003544 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3545 break;
3546
3547 case 44:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003548#line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003549 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3550 break;
3551
3552 case 45:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003553#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003554 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3555 break;
3556
3557 case 46:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003558#line 1128 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003559 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3560 break;
3561
3562 case 47:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003563#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003564 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3565 break;
3566
3567 case 48:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003568#line 1129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003569 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3570 break;
3571
3572 case 49:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003573#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003574 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3575 break;
3576
3577 case 50:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003578#line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003579 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3580 break;
3581
3582 case 51:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003583#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003584 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3585 break;
3586
3587 case 52:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003588#line 1131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003589 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3590 break;
3591
3592 case 53:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003593#line 1132 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003594 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3595 break;
3596
3597 case 54:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003598#line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003599 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3600 break;
3601
3602 case 65:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003603#line 1142 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003604 { (yyval.StrVal) = 0; ;}
3605 break;
3606
3607 case 66:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003608#line 1144 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003609 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3610 break;
3611
3612 case 67:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003613#line 1145 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003614 { (yyval.UIntVal)=0; ;}
3615 break;
3616
3617 case 68:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003618#line 1149 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003619 {
3620 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003621 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003622 ;}
3623 break;
3624
3625 case 69:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003626#line 1153 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003627 {
3628 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003629 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003630 ;}
3631 break;
3632
3633 case 73:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003634#line 1161 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003635 {
3636 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003637 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003638 ;}
3639 break;
3640
3641 case 74:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003642#line 1166 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003643 {
3644 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00003645 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003646 ;}
3647 break;
3648
3649 case 75:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003650#line 1172 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003651 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3652 break;
3653
3654 case 76:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003655#line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003656 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3657 break;
3658
3659 case 77:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003660#line 1174 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003661 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3662 break;
3663
3664 case 78:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003665#line 1175 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003666 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3667 break;
3668
3669 case 79:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003670#line 1176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003671 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3672 break;
3673
3674 case 80:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003675#line 1180 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003676 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3677 break;
3678
3679 case 81:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003680#line 1181 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003681 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3682 break;
3683
3684 case 82:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003685#line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003686 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3687 break;
3688
3689 case 83:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003690#line 1186 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003691 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3692 break;
3693
3694 case 84:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003695#line 1187 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003696 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3697 break;
3698
3699 case 85:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003700#line 1188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003701 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3702 break;
3703
3704 case 86:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003705#line 1189 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003706 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3707 break;
3708
3709 case 87:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003710#line 1193 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003711 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3712 break;
3713
3714 case 88:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003715#line 1194 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003716 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3717 break;
3718
3719 case 89:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003720#line 1195 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003721 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3722 break;
3723
3724 case 90:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003725#line 1199 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003726 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3727 break;
3728
3729 case 91:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003730#line 1200 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003731 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3732 break;
3733
3734 case 92:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003735#line 1201 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003736 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3737 break;
3738
3739 case 93:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003740#line 1202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003741 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3742 break;
3743
3744 case 94:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003745#line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003746 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3747 break;
3748
3749 case 95:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003750#line 1207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003751 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3752 break;
3753
3754 case 96:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003755#line 1208 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003756 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3757 break;
3758
3759 case 97:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003760#line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003761 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3762 break;
3763
3764 case 98:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003765#line 1212 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003766 { (yyval.UIntVal) = CallingConv::C; ;}
3767 break;
3768
3769 case 99:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003770#line 1213 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003771 { (yyval.UIntVal) = CallingConv::C; ;}
3772 break;
3773
3774 case 100:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003775#line 1214 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003776 { (yyval.UIntVal) = CallingConv::Fast; ;}
3777 break;
3778
3779 case 101:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003780#line 1215 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003781 { (yyval.UIntVal) = CallingConv::Cold; ;}
3782 break;
3783
3784 case 102:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003785#line 1216 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003786 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3787 break;
3788
3789 case 103:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003790#line 1217 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003791 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3792 break;
3793
3794 case 104:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003795#line 1218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003796 {
3797 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003798 GEN_ERROR("Calling conv too large");
Dan Gohman54392c12008-04-19 00:24:39 +00003799 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003800 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003801 ;}
3802 break;
3803
3804 case 105:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003805#line 1225 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003806 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3807 break;
3808
3809 case 106:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003810#line 1226 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003811 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3812 break;
3813
3814 case 107:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003815#line 1227 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003816 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3817 break;
3818
3819 case 108:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003820#line 1228 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003821 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3822 break;
3823
3824 case 109:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003825#line 1229 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003826 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3827 break;
3828
3829 case 110:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003830#line 1230 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003831 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3832 break;
3833
3834 case 111:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003835#line 1231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003836 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3837 break;
3838
3839 case 112:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003840#line 1232 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003841 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3842 break;
3843
3844 case 113:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003845#line 1233 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003846 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3847 break;
3848
3849 case 114:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003850#line 1234 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003851 { (yyval.ParamAttrs) =
3852 ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
3853 break;
3854
3855 case 115:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003856#line 1238 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003857 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3858 break;
3859
3860 case 116:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003861#line 1239 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003862 {
3863 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3864 ;}
3865 break;
3866
3867 case 117:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003868#line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003869 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3870 break;
3871
3872 case 118:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003873#line 1245 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003874 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3875 break;
3876
3877 case 119:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003878#line 1246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003879 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3880 break;
3881
3882 case 120:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003883#line 1247 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003884 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3885 break;
3886
3887 case 121:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003888#line 1248 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003889 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
3890 break;
3891
3892 case 122:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003893#line 1249 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003894 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
3895 break;
3896
3897 case 123:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003898#line 1252 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003899 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3900 break;
3901
3902 case 124:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003903#line 1253 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003904 {
3905 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3906 ;}
3907 break;
3908
3909 case 125:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003910#line 1258 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003911 { (yyval.StrVal) = 0; ;}
3912 break;
3913
3914 case 126:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003915#line 1259 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003916 {
3917 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3918 ;}
3919 break;
3920
3921 case 127:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003922#line 1266 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003923 { (yyval.UIntVal) = 0; ;}
3924 break;
3925
3926 case 128:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003927#line 1267 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003928 {
3929 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3930 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003931 GEN_ERROR("Alignment must be a power of two");
3932 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003933;}
3934 break;
3935
3936 case 129:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003937#line 1273 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003938 { (yyval.UIntVal) = 0; ;}
3939 break;
3940
3941 case 130:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003942#line 1274 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003943 {
3944 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3945 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lamb668d9a02007-12-12 08:45:45 +00003946 GEN_ERROR("Alignment must be a power of two");
3947 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003948;}
3949 break;
3950
3951 case 131:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003952#line 1283 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003953 {
3954 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3955 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003956 GEN_ERROR("Invalid character in section name");
Dan Gohman54392c12008-04-19 00:24:39 +00003957 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003958 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003959;}
3960 break;
3961
3962 case 132:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003963#line 1291 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003964 { (yyval.StrVal) = 0; ;}
3965 break;
3966
3967 case 133:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003968#line 1292 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003969 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3970 break;
3971
3972 case 134:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003973#line 1297 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003974 {;}
3975 break;
3976
3977 case 135:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003978#line 1298 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003979 {;}
3980 break;
3981
3982 case 136:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003983#line 1299 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003984 {
3985 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
3986 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003987 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003988 ;}
3989 break;
3990
3991 case 137:
Chris Lattnere7e9b602008-05-04 17:18:47 +00003992#line 1304 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00003993 {
3994 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003995 GEN_ERROR("Alignment must be a power of two");
Dan Gohman54392c12008-04-19 00:24:39 +00003996 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003997 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00003998 ;}
3999 break;
4000
4001 case 145:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004002#line 1320 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004003 {
4004 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004005 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004006 ;}
4007 break;
4008
4009 case 146:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004010#line 1324 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004011 {
4012 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004013 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004014 ;}
4015 break;
4016
4017 case 147:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004018#line 1328 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004019 { // Pointer type?
4020 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00004021 GEN_ERROR("Cannot form a pointer to a basic block");
Dan Gohman54392c12008-04-19 00:24:39 +00004022 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4023 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00004024 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004025 ;}
4026 break;
4027
4028 case 148:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004029#line 1335 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004030 { // Named types are also simple types...
4031 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamb0a243582007-12-11 09:02:08 +00004032 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004033 (yyval.TypeVal) = new PATypeHolder(tmp);
4034 ;}
4035 break;
4036
4037 case 149:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004038#line 1340 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004039 { // Type UpReference
4040 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004041 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Dan Gohman54392c12008-04-19 00:24:39 +00004042 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4043 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004044 UR_OUT("New Upreference!\n");
4045 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004046 ;}
4047 break;
4048
4049 case 150:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004050#line 1348 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004051 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004052 // Allow but ignore attributes on function types; this permits auto-upgrade.
4053 // FIXME: remove in LLVM 3.0.
Chris Lattner73de3c02008-04-23 05:37:08 +00004054 const Type *RetTy = *(yyvsp[(1) - (5)].TypeVal);
4055 if (!FunctionType::isValidReturnType(RetTy))
4056 GEN_ERROR("Invalid result type for LLVM function");
4057
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004058 std::vector<const Type*> Params;
Dan Gohman54392c12008-04-19 00:24:39 +00004059 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004060 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004061 const Type *Ty = I->Ty->get();
4062 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004063 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004064
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004065 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4066 if (isVarArg) Params.pop_back();
4067
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004068 for (unsigned i = 0; i != Params.size(); ++i)
4069 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4070 GEN_ERROR("Function arguments must be value types!");
4071
4072 CHECK_FOR_ERROR
4073
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004074 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Dan Gohman54392c12008-04-19 00:24:39 +00004075 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4076 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4077 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004078 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004079 ;}
4080 break;
4081
4082 case 151:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004083#line 1377 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004084 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004085 // Allow but ignore attributes on function types; this permits auto-upgrade.
4086 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004087 std::vector<const Type*> Params;
Dan Gohman54392c12008-04-19 00:24:39 +00004088 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004089 for ( ; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004090 const Type* Ty = I->Ty->get();
4091 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004092 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004093
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004094 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4095 if (isVarArg) Params.pop_back();
4096
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004097 for (unsigned i = 0; i != Params.size(); ++i)
4098 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4099 GEN_ERROR("Function arguments must be value types!");
4100
4101 CHECK_FOR_ERROR
4102
Dan Gohman54392c12008-04-19 00:24:39 +00004103 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4104 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4105 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004106 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004107 ;}
4108 break;
4109
4110 case 152:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004111#line 1402 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004112 { // Sized array type?
4113 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4114 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004115 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004116 ;}
4117 break;
4118
4119 case 153:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004120#line 1407 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004121 { // Vector type?
4122 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4123 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004124 GEN_ERROR("Unsigned result not equal to signed result");
4125 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4126 GEN_ERROR("Element type of a VectorType must be primitive");
Dan Gohman54392c12008-04-19 00:24:39 +00004127 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4128 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004129 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004130 ;}
4131 break;
4132
4133 case 154:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004134#line 1417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004135 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004136 std::vector<const Type*> Elements;
Dan Gohman54392c12008-04-19 00:24:39 +00004137 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4138 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004139 Elements.push_back(*I);
4140
Dan Gohman54392c12008-04-19 00:24:39 +00004141 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4142 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004143 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004144 ;}
4145 break;
4146
4147 case 155:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004148#line 1427 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004149 { // Empty structure type?
4150 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004151 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004152 ;}
4153 break;
4154
4155 case 156:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004156#line 1431 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004157 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004158 std::vector<const Type*> Elements;
Dan Gohman54392c12008-04-19 00:24:39 +00004159 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4160 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004161 Elements.push_back(*I);
4162
Dan Gohman54392c12008-04-19 00:24:39 +00004163 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4164 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004165 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004166 ;}
4167 break;
4168
4169 case 157:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004170#line 1441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004171 { // Empty structure type?
4172 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004173 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004174 ;}
4175 break;
4176
4177 case 158:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004178#line 1448 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004179 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004180 // Allow but ignore attributes on function types; this permits auto-upgrade.
4181 // FIXME: remove in LLVM 3.0.
Dan Gohman54392c12008-04-19 00:24:39 +00004182 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4183 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4184 ;}
4185 break;
4186
4187 case 159:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004188#line 1457 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004189 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004190 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004191 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
4192 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004193 GEN_ERROR("LLVM functions cannot return aggregate types");
Dan Gohman54392c12008-04-19 00:24:39 +00004194 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4195 ;}
4196 break;
4197
4198 case 160:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004199#line 1464 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004200 {
4201 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4202 ;}
4203 break;
4204
4205 case 161:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004206#line 1469 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004207 {
4208 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4209 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004210 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004211 ;}
4212 break;
4213
4214 case 162:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004215#line 1474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004216 {
4217 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004218 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004219 ;}
4220 break;
4221
4222 case 164:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004223#line 1482 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004224 {
4225 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004226 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4227 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohman54392c12008-04-19 00:24:39 +00004228 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004229 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004230 ;}
4231 break;
4232
4233 case 165:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004234#line 1489 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004235 {
4236 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004237 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4238 TWA.Ty = new PATypeHolder(Type::VoidTy);
Dan Gohman54392c12008-04-19 00:24:39 +00004239 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004240 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004241 ;}
4242 break;
4243
4244 case 166:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004245#line 1496 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004246 {
4247 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004248 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004249 ;}
4250 break;
4251
4252 case 167:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004253#line 1504 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004254 {
4255 (yyval.TypeList) = new std::list<PATypeHolder>();
4256 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4257 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004258 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004259 ;}
4260 break;
4261
4262 case 168:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004263#line 1510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004264 {
4265 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4266 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004267 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004268 ;}
4269 break;
4270
4271 case 169:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004272#line 1522 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004273 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004274 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004275 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4276 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277 if (ATy == 0)
4278 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004279 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004280 const Type *ETy = ATy->getElementType();
4281 int NumElements = ATy->getNumElements();
4282
4283 // Verify that we have the correct size...
Dan Gohman54392c12008-04-19 00:24:39 +00004284 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004285 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Dan Gohman54392c12008-04-19 00:24:39 +00004286 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004287 itostr(NumElements) + "");
4288
4289 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00004290 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4291 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4293 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohman54392c12008-04-19 00:24:39 +00004294 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 }
4296
Dan Gohman54392c12008-04-19 00:24:39 +00004297 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4298 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004299 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004300 ;}
4301 break;
4302
4303 case 170:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004304#line 1550 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004305 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004306 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004307 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4308 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004309 if (ATy == 0)
4310 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004311 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004312
4313 int NumElements = ATy->getNumElements();
4314 if (NumElements != -1 && NumElements != 0)
4315 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4316 " arguments, but has size of " + itostr(NumElements) +"");
Dan Gohman54392c12008-04-19 00:24:39 +00004317 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4318 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004319 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004320 ;}
4321 break;
4322
4323 case 171:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004324#line 1566 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004325 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004326 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004327 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4328 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004329 if (ATy == 0)
4330 GEN_ERROR("Cannot make array constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004331 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004332
4333 int NumElements = ATy->getNumElements();
4334 const Type *ETy = ATy->getElementType();
Dan Gohman54392c12008-04-19 00:24:39 +00004335 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004336 GEN_ERROR("Can't build string constant of size " +
Dan Gohman54392c12008-04-19 00:24:39 +00004337 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004338 " when array has size " + itostr(NumElements) + "");
4339 std::vector<Constant*> Vals;
4340 if (ETy == Type::Int8Ty) {
Dan Gohman54392c12008-04-19 00:24:39 +00004341 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4342 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004343 } else {
Dan Gohman54392c12008-04-19 00:24:39 +00004344 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004345 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4346 }
Dan Gohman54392c12008-04-19 00:24:39 +00004347 delete (yyvsp[(3) - (3)].StrVal);
4348 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4349 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004350 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004351 ;}
4352 break;
4353
4354 case 172:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004355#line 1593 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004356 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004357 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004358 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4359 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004360 if (PTy == 0)
4361 GEN_ERROR("Cannot make packed constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004362 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004363 const Type *ETy = PTy->getElementType();
4364 int NumElements = PTy->getNumElements();
4365
4366 // Verify that we have the correct size...
Dan Gohman54392c12008-04-19 00:24:39 +00004367 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Dan Gohman54392c12008-04-19 00:24:39 +00004369 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004370 itostr(NumElements) + "");
4371
4372 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00004373 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4374 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004375 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4376 ETy->getDescription() +"' as required!\nIt is of type '"+
Dan Gohman54392c12008-04-19 00:24:39 +00004377 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004378 }
4379
Dan Gohman54392c12008-04-19 00:24:39 +00004380 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4381 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004382 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004383 ;}
4384 break;
4385
4386 case 173:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004387#line 1621 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004388 {
4389 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004390 if (STy == 0)
4391 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004392 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004393
Dan Gohman54392c12008-04-19 00:24:39 +00004394 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004395 GEN_ERROR("Illegal number of initializers for structure type");
4396
4397 // Check to ensure that constants are compatible with the type initializer!
Dan Gohman54392c12008-04-19 00:24:39 +00004398 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4399 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004400 GEN_ERROR("Expected type '" +
4401 STy->getElementType(i)->getDescription() +
4402 "' for element #" + utostr(i) +
4403 " of structure initializer");
4404
4405 // Check to ensure that Type is not packed
4406 if (STy->isPacked())
4407 GEN_ERROR("Unpacked Initializer to vector type '" +
4408 STy->getDescription() + "'");
4409
Dan Gohman54392c12008-04-19 00:24:39 +00004410 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4411 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004412 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004413 ;}
4414 break;
4415
4416 case 174:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004417#line 1647 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004418 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004419 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004420 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4421 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004422 if (STy == 0)
4423 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004424 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004425
4426 if (STy->getNumContainedTypes() != 0)
4427 GEN_ERROR("Illegal number of initializers for structure type");
4428
4429 // Check to ensure that Type is not packed
4430 if (STy->isPacked())
4431 GEN_ERROR("Unpacked Initializer to vector type '" +
4432 STy->getDescription() + "'");
4433
Dan Gohman54392c12008-04-19 00:24:39 +00004434 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4435 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004436 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004437 ;}
4438 break;
4439
4440 case 175:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004441#line 1667 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004442 {
4443 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004444 if (STy == 0)
4445 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004446 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004447
Dan Gohman54392c12008-04-19 00:24:39 +00004448 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004449 GEN_ERROR("Illegal number of initializers for structure type");
4450
4451 // Check to ensure that constants are compatible with the type initializer!
Dan Gohman54392c12008-04-19 00:24:39 +00004452 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4453 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004454 GEN_ERROR("Expected type '" +
4455 STy->getElementType(i)->getDescription() +
4456 "' for element #" + utostr(i) +
4457 " of structure initializer");
4458
4459 // Check to ensure that Type is packed
4460 if (!STy->isPacked())
4461 GEN_ERROR("Vector initializer to non-vector type '" +
4462 STy->getDescription() + "'");
4463
Dan Gohman54392c12008-04-19 00:24:39 +00004464 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4465 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004466 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004467 ;}
4468 break;
4469
4470 case 176:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004471#line 1693 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004472 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004473 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004474 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4475 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004476 if (STy == 0)
4477 GEN_ERROR("Cannot make struct constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004478 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004479
4480 if (STy->getNumContainedTypes() != 0)
4481 GEN_ERROR("Illegal number of initializers for structure type");
4482
4483 // Check to ensure that Type is packed
4484 if (!STy->isPacked())
4485 GEN_ERROR("Vector initializer to non-vector type '" +
4486 STy->getDescription() + "'");
4487
Dan Gohman54392c12008-04-19 00:24:39 +00004488 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4489 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004490 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004491 ;}
4492 break;
4493
4494 case 177:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004495#line 1713 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004496 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004497 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004498 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4499 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004500 if (PTy == 0)
4501 GEN_ERROR("Cannot make null pointer constant with type: '" +
Dan Gohman54392c12008-04-19 00:24:39 +00004502 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004503
Dan Gohman54392c12008-04-19 00:24:39 +00004504 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4505 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004506 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004507 ;}
4508 break;
4509
4510 case 178:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004511#line 1725 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004512 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004513 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004514 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4515 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4516 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004517 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004518 ;}
4519 break;
4520
4521 case 179:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004522#line 1732 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004523 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004524 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004525 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4526 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004527 if (Ty == 0)
Dan Gohman54392c12008-04-19 00:24:39 +00004528 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004529
4530 // ConstExprs can exist in the body of a function, thus creating
4531 // GlobalValues whenever they refer to a variable. Because we are in
4532 // the context of a function, getExistingVal will search the functions
4533 // symbol table instead of the module symbol table for the global symbol,
4534 // which throws things all off. To get around this, we just tell
4535 // getExistingVal that we are at global scope here.
4536 //
4537 Function *SavedCurFn = CurFun.CurrentFunction;
4538 CurFun.CurrentFunction = 0;
4539
Dan Gohman54392c12008-04-19 00:24:39 +00004540 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004541 CHECK_FOR_ERROR
4542
4543 CurFun.CurrentFunction = SavedCurFn;
4544
4545 // If this is an initializer for a constant pointer, which is referencing a
4546 // (currently) undefined variable, create a stub now that shall be replaced
4547 // in the future with the right type of variable.
4548 //
4549 if (V == 0) {
4550 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4551 const PointerType *PT = cast<PointerType>(Ty);
4552
4553 // First check to see if the forward references value is already created!
4554 PerModuleInfo::GlobalRefsType::iterator I =
Dan Gohman54392c12008-04-19 00:24:39 +00004555 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004556
4557 if (I != CurModule.GlobalRefs.end()) {
4558 V = I->second; // Placeholder already exists, use it...
Dan Gohman54392c12008-04-19 00:24:39 +00004559 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004560 } else {
4561 std::string Name;
Dan Gohman54392c12008-04-19 00:24:39 +00004562 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4563 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4564 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004565 GEN_ERROR("Invalid reference to global");
4566
4567 // Create the forward referenced global.
4568 GlobalValue *GV;
4569 if (const FunctionType *FTy =
4570 dyn_cast<FunctionType>(PT->getElementType())) {
Gabor Greif89f01162008-04-06 23:07:54 +00004571 GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name,
4572 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004573 } else {
4574 GV = new GlobalVariable(PT->getElementType(), false,
4575 GlobalValue::ExternalWeakLinkage, 0,
4576 Name, CurModule.CurrentModule);
4577 }
4578
4579 // Keep track of the fact that we have a forward ref to recycle it
Dan Gohman54392c12008-04-19 00:24:39 +00004580 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004581 V = GV;
4582 }
4583 }
4584
Dan Gohman54392c12008-04-19 00:24:39 +00004585 (yyval.ConstVal) = cast<GlobalValue>(V);
4586 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004587 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004588 ;}
4589 break;
4590
4591 case 180:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004592#line 1798 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004593 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004594 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004595 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4596 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004597 GEN_ERROR("Mismatched types for constant expression: " +
Dan Gohman54392c12008-04-19 00:24:39 +00004598 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4599 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4600 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004601 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004602 ;}
4603 break;
4604
4605 case 181:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004606#line 1808 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004607 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004608 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004609 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4610 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004611 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4612 GEN_ERROR("Cannot create a null initialized value of this type");
Dan Gohman54392c12008-04-19 00:24:39 +00004613 (yyval.ConstVal) = Constant::getNullValue(Ty);
4614 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004615 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004616 ;}
4617 break;
4618
4619 case 182:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004620#line 1818 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004621 { // integral constants
4622 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004623 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohman54392c12008-04-19 00:24:39 +00004624 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004625 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004626 ;}
4627 break;
4628
4629 case 183:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004630#line 1824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004631 { // arbitrary precision integer constants
4632 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4633 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004634 GEN_ERROR("Constant value does not fit in type");
4635 }
Dan Gohman54392c12008-04-19 00:24:39 +00004636 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4637 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4638 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004639 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004640 ;}
4641 break;
4642
4643 case 184:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004644#line 1834 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004645 { // integral constants
4646 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004647 GEN_ERROR("Constant value doesn't fit in type");
Dan Gohman54392c12008-04-19 00:24:39 +00004648 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004649 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004650 ;}
4651 break;
4652
4653 case 185:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004654#line 1840 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004655 { // arbitrary precision integer constants
4656 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4657 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004658 GEN_ERROR("Constant value does not fit in type");
4659 }
Dan Gohman54392c12008-04-19 00:24:39 +00004660 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4661 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4662 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004663 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004664 ;}
4665 break;
4666
4667 case 186:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004668#line 1850 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004669 { // Boolean constants
4670 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4671 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004672 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004673 ;}
4674 break;
4675
4676 case 187:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004677#line 1855 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004678 { // Boolean constants
4679 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4680 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004681 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004682 ;}
4683 break;
4684
4685 case 188:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004686#line 1860 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004687 { // Floating point constants
4688 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004689 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004690 // Lexer has no type info, so builds all float and double FP constants
4691 // as double. Fix this here. Long double is done right.
Dan Gohman54392c12008-04-19 00:24:39 +00004692 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4693 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
Chris Lattner05ba86e2008-04-20 00:41:19 +00004694 (yyval.ConstVal) = ConstantFP::get(*(yyvsp[(2) - (2)].FPVal));
Dan Gohman54392c12008-04-19 00:24:39 +00004695 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004696 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004697 ;}
4698 break;
4699
4700 case 189:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004701#line 1873 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004702 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004703 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004704 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4705 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4706 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4707 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004708 GEN_ERROR("invalid cast opcode for cast from '" +
4709 Val->getType()->getDescription() + "' to '" +
4710 DestTy->getDescription() + "'");
Dan Gohman54392c12008-04-19 00:24:39 +00004711 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4712 delete (yyvsp[(5) - (6)].TypeVal);
4713 ;}
4714 break;
4715
4716 case 190:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004717#line 1885 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004718 {
4719 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004720 GEN_ERROR("GetElementPtr requires a pointer operand");
4721
4722 const Type *IdxTy =
Dan Gohman54392c12008-04-19 00:24:39 +00004723 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004724 true);
4725 if (!IdxTy)
4726 GEN_ERROR("Index list invalid for constant getelementptr");
4727
4728 SmallVector<Constant*, 8> IdxVec;
Dan Gohman54392c12008-04-19 00:24:39 +00004729 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4730 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004731 IdxVec.push_back(C);
4732 else
4733 GEN_ERROR("Indices to constant getelementptr must be constants");
4734
Dan Gohman54392c12008-04-19 00:24:39 +00004735 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004736
Dan Gohman54392c12008-04-19 00:24:39 +00004737 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004738 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004739 ;}
4740 break;
4741
4742 case 191:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004743#line 1907 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004744 {
4745 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004746 GEN_ERROR("Select condition must be of boolean type");
Dan Gohman54392c12008-04-19 00:24:39 +00004747 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004748 GEN_ERROR("Select operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00004749 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004750 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004751 ;}
4752 break;
4753
4754 case 192:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004755#line 1915 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004756 {
4757 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004758 GEN_ERROR("Binary operator types must match");
4759 CHECK_FOR_ERROR;
Dan Gohman54392c12008-04-19 00:24:39 +00004760 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4761 ;}
4762 break;
4763
4764 case 193:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004765#line 1921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004766 {
4767 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004768 GEN_ERROR("Logical operator types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00004769 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4770 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4771 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004772 GEN_ERROR("Logical operator requires integral operands");
4773 }
Dan Gohman54392c12008-04-19 00:24:39 +00004774 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004775 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004776 ;}
4777 break;
4778
4779 case 194:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004780#line 1932 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004781 {
4782 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004783 GEN_ERROR("icmp operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00004784 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4785 ;}
4786 break;
4787
4788 case 195:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004789#line 1937 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004790 {
4791 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004792 GEN_ERROR("fcmp operand types must match");
Dan Gohman54392c12008-04-19 00:24:39 +00004793 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4794 ;}
4795 break;
4796
4797 case 196:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004798#line 1942 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004799 {
4800 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004801 GEN_ERROR("Invalid extractelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00004802 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004803 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004804 ;}
4805 break;
4806
4807 case 197:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004808#line 1948 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004809 {
4810 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004811 GEN_ERROR("Invalid insertelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00004812 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004813 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004814 ;}
4815 break;
4816
4817 case 198:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004818#line 1954 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004819 {
4820 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004821 GEN_ERROR("Invalid shufflevector operands");
Dan Gohman54392c12008-04-19 00:24:39 +00004822 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004823 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004824 ;}
4825 break;
4826
4827 case 199:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004828#line 1963 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004829 {
4830 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004831 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004832 ;}
4833 break;
4834
4835 case 200:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004836#line 1967 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004837 {
4838 (yyval.ConstVector) = new std::vector<Constant*>();
4839 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004840 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004841 ;}
4842 break;
4843
4844 case 201:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004845#line 1975 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004846 { (yyval.BoolVal) = false; ;}
4847 break;
4848
4849 case 202:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004850#line 1975 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004851 { (yyval.BoolVal) = true; ;}
4852 break;
4853
4854 case 203:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004855#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004856 { (yyval.BoolVal) = true; ;}
4857 break;
4858
4859 case 204:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004860#line 1978 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004861 { (yyval.BoolVal) = false; ;}
4862 break;
4863
4864 case 205:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004865#line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004866 {
4867 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4868 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00004869 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004870 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4871 if (!Aliasee)
4872 GEN_ERROR("Aliases can be created only to global values");
4873
Dan Gohman54392c12008-04-19 00:24:39 +00004874 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004875 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004876 delete (yyvsp[(1) - (2)].TypeVal);
4877 ;}
4878 break;
4879
4880 case 206:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004881#line 1993 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004882 {
4883 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4884 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4885 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004886 GEN_ERROR("invalid cast opcode for cast from '" +
4887 Val->getType()->getDescription() + "' to '" +
4888 DestTy->getDescription() + "'");
4889
Dan Gohman54392c12008-04-19 00:24:39 +00004890 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004891 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004892 delete (yyvsp[(5) - (6)].TypeVal);
4893 ;}
4894 break;
4895
4896 case 207:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004897#line 2014 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004898 {
4899 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lamb668d9a02007-12-12 08:45:45 +00004900 CurModule.ModuleDone();
4901 CHECK_FOR_ERROR;
Dan Gohman54392c12008-04-19 00:24:39 +00004902 ;}
4903 break;
4904
4905 case 208:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004906#line 2019 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004907 {
4908 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Dale Johannesena79ecf32008-02-20 21:15:43 +00004909 CurModule.ModuleDone();
4910 CHECK_FOR_ERROR;
Dan Gohman54392c12008-04-19 00:24:39 +00004911 ;}
4912 break;
4913
4914 case 211:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004915#line 2032 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004916 { CurFun.isDeclare = false; ;}
4917 break;
4918
4919 case 212:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004920#line 2032 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004921 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004922 CurFun.FunctionDone();
4923 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004924 ;}
4925 break;
4926
4927 case 213:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004928#line 2036 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004929 { CurFun.isDeclare = true; ;}
4930 break;
4931
4932 case 214:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004933#line 2036 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004934 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00004935 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004936 ;}
4937 break;
4938
4939 case 215:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004940#line 2039 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004941 {
Dale Johannesena79ecf32008-02-20 21:15:43 +00004942 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004943 ;}
4944 break;
4945
4946 case 216:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004947#line 2042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004948 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004949 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00004950 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004951 // Eagerly resolve types. This is not an optimization, this is a
4952 // requirement that is due to the fact that we could have this:
4953 //
4954 // %list = type { %list * }
4955 // %list = type { %list * } ; repeated type decl
4956 //
4957 // If types are not resolved eagerly, then the two types will not be
4958 // determined to be the same type!
4959 //
Dan Gohman54392c12008-04-19 00:24:39 +00004960 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004961
Dan Gohman54392c12008-04-19 00:24:39 +00004962 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004963 CHECK_FOR_ERROR
4964 // If this is a named type that is not a redefinition, add it to the slot
4965 // table.
Dan Gohman54392c12008-04-19 00:24:39 +00004966 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004967 }
4968
Dan Gohman54392c12008-04-19 00:24:39 +00004969 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004970 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004971 ;}
4972 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004973
Dan Gohman54392c12008-04-19 00:24:39 +00004974 case 217:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004975#line 2066 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004976 {
4977 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4978
4979 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004980 CHECK_FOR_ERROR
4981 // If this is a named type that is not a redefinition, add it to the slot
4982 // table.
Dan Gohman54392c12008-04-19 00:24:39 +00004983 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004984 }
4985 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004986 ;}
4987 break;
4988
4989 case 218:
Chris Lattnere7e9b602008-05-04 17:18:47 +00004990#line 2078 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00004991 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004992 /* "Externally Visible" Linkage */
Dan Gohman54392c12008-04-19 00:24:39 +00004993 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004994 GEN_ERROR("Global value initializer is not a constant");
Dan Gohman54392c12008-04-19 00:24:39 +00004995 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
4996 (yyvsp[(2) - (6)].Visibility), (yyvsp[(4) - (6)].BoolVal), (yyvsp[(5) - (6)].ConstVal)->getType(), (yyvsp[(5) - (6)].ConstVal), (yyvsp[(3) - (6)].BoolVal), (yyvsp[(6) - (6)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004997 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00004998 ;}
4999 break;
5000
5001 case 219:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005002#line 2085 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005003 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005004 CurGV = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00005005 ;}
5006 break;
5007
5008 case 220:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005009#line 2089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005010 {
5011 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00005012 GEN_ERROR("Global value initializer is not a constant");
Dan Gohman54392c12008-04-19 00:24:39 +00005013 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), (yyvsp[(6) - (7)].ConstVal)->getType(), (yyvsp[(6) - (7)].ConstVal), (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lamb668d9a02007-12-12 08:45:45 +00005014 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005015 ;}
5016 break;
5017
5018 case 221:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005019#line 2094 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005020 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005021 CurGV = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00005022 ;}
5023 break;
5024
5025 case 222:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005026#line 2098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005027 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005028 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005029 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5030 CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), *(yyvsp[(6) - (7)].TypeVal), 0, (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
Christopher Lamb668d9a02007-12-12 08:45:45 +00005031 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005032 delete (yyvsp[(6) - (7)].TypeVal);
5033 ;}
5034 break;
5035
5036 case 223:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005037#line 2104 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005038 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005039 CurGV = 0;
5040 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005041 ;}
5042 break;
5043
5044 case 224:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005045#line 2108 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005046 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005047 std::string Name;
Dan Gohman54392c12008-04-19 00:24:39 +00005048 if ((yyvsp[(1) - (5)].StrVal)) {
5049 Name = *(yyvsp[(1) - (5)].StrVal);
5050 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005051 }
5052 if (Name.empty())
5053 GEN_ERROR("Alias name cannot be empty");
5054
Dan Gohman54392c12008-04-19 00:24:39 +00005055 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005056 if (Aliasee == 0)
5057 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
5058
Dan Gohman54392c12008-04-19 00:24:39 +00005059 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005060 CurModule.CurrentModule);
Dan Gohman54392c12008-04-19 00:24:39 +00005061 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005062 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00005063
5064
5065 // If there was a forward reference of this alias, resolve it now.
5066
5067 ValID ID;
5068 if (!Name.empty())
5069 ID = ValID::createGlobalName(Name);
5070 else
5071 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5072
5073 if (GlobalValue *FWGV =
5074 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5075 // Replace uses of the fwdref with the actual alias.
5076 FWGV->replaceAllUsesWith(GA);
5077 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5078 GV->eraseFromParent();
5079 else
5080 cast<Function>(FWGV)->eraseFromParent();
5081 }
5082 ID.destroy();
5083
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005084 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005085 ;}
5086 break;
5087
5088 case 225:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005089#line 2148 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005090 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005091 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005092 ;}
5093 break;
5094
5095 case 226:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005096#line 2151 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005097 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005098 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005099 ;}
5100 break;
5101
5102 case 227:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005103#line 2157 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005104 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005105 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5106 if (AsmSoFar.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005107 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005108 else
Dan Gohman54392c12008-04-19 00:24:39 +00005109 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5110 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005111 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005112;}
5113 break;
5114
5115 case 228:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005116#line 2167 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005117 {
5118 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5119 delete (yyvsp[(3) - (3)].StrVal);
5120 ;}
5121 break;
5122
5123 case 229:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005124#line 2171 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005125 {
5126 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5127 delete (yyvsp[(3) - (3)].StrVal);
5128 ;}
5129 break;
5130
5131 case 231:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005132#line 2178 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005133 {
5134 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5135 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00005136 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005137 ;}
5138 break;
5139
5140 case 232:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005141#line 2183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005142 {
5143 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5144 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005145 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005146 ;}
5147 break;
5148
5149 case 233:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005150#line 2188 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005151 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005152 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005153 ;}
5154 break;
5155
5156 case 234:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005157#line 2197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005158 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005159 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005160 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5161 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005162 GEN_ERROR("void typed arguments are invalid");
Dan Gohman54392c12008-04-19 00:24:39 +00005163 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5164 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5165 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005166 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005167 ;}
5168 break;
5169
5170 case 235:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005171#line 2207 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005172 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005173 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005174 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5175 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005176 GEN_ERROR("void typed arguments are invalid");
Dan Gohman54392c12008-04-19 00:24:39 +00005177 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5178 (yyval.ArgList) = new ArgListType;
5179 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005180 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005181 ;}
5182 break;
5183
5184 case 236:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005185#line 2218 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005186 {
5187 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005188 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005189 ;}
5190 break;
5191
5192 case 237:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005193#line 2222 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005194 {
5195 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005196 struct ArgListEntry E;
5197 E.Ty = new PATypeHolder(Type::VoidTy);
5198 E.Name = 0;
5199 E.Attrs = ParamAttr::None;
Dan Gohman54392c12008-04-19 00:24:39 +00005200 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005201 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005202 ;}
5203 break;
5204
5205 case 238:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005206#line 2231 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005207 {
5208 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005209 struct ArgListEntry E;
5210 E.Ty = new PATypeHolder(Type::VoidTy);
5211 E.Name = 0;
5212 E.Attrs = ParamAttr::None;
Dan Gohman54392c12008-04-19 00:24:39 +00005213 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005214 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005215 ;}
5216 break;
5217
5218 case 239:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005219#line 2240 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005220 {
5221 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005222 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005223 ;}
5224 break;
5225
5226 case 240:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005227#line 2246 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005228 {
5229 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5230 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005231
5232 // Check the function result for abstractness if this is a define. We should
5233 // have no abstract types at this point
Dan Gohman54392c12008-04-19 00:24:39 +00005234 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5235 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005236
Chris Lattner73de3c02008-04-23 05:37:08 +00005237 if (!FunctionType::isValidReturnType(*(yyvsp[(2) - (10)].TypeVal)))
5238 GEN_ERROR("Invalid result type for LLVM function");
5239
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005240 std::vector<const Type*> ParamTypeList;
Chris Lattner1c8733e2008-03-12 17:45:29 +00005241 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohman54392c12008-04-19 00:24:39 +00005242 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None)
5243 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(7) - (10)].ParamAttrs)));
5244 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005245 unsigned index = 1;
Dan Gohman54392c12008-04-19 00:24:39 +00005246 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005247 const Type* Ty = I->Ty->get();
5248 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5249 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5250 ParamTypeList.push_back(Ty);
Chris Lattner1c8733e2008-03-12 17:45:29 +00005251 if (Ty != Type::VoidTy && I->Attrs != ParamAttr::None)
5252 Attrs.push_back(ParamAttrsWithIndex::get(index, I->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005253 }
5254 }
5255
5256 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5257 if (isVarArg) ParamTypeList.pop_back();
5258
Chris Lattner1c8733e2008-03-12 17:45:29 +00005259 PAListPtr PAL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005260 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00005261 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005262
Dan Gohman54392c12008-04-19 00:24:39 +00005263 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00005264 const PointerType *PFT = PointerType::getUnqual(FT);
Dan Gohman54392c12008-04-19 00:24:39 +00005265 delete (yyvsp[(2) - (10)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005266
5267 ValID ID;
5268 if (!FunctionName.empty()) {
5269 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5270 } else {
5271 ID = ValID::createGlobalID(CurModule.Values.size());
5272 }
5273
5274 Function *Fn = 0;
5275 // See if this function was forward referenced. If so, recycle the object.
5276 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5277 // Move the function to the end of the list, from whereever it was
5278 // previously inserted.
5279 Fn = cast<Function>(FWRef);
Chris Lattner1c8733e2008-03-12 17:45:29 +00005280 assert(Fn->getParamAttrs().isEmpty() &&
5281 "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005282 CurModule.CurrentModule->getFunctionList().remove(Fn);
5283 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5284 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5285 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005286 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005287 // The existing function doesn't have the same type. This is an overload
5288 // error.
5289 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005290 } else if (Fn->getParamAttrs() != PAL) {
5291 // The existing function doesn't have the same parameter attributes.
5292 // This is an overload error.
5293 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005294 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5295 // Neither the existing or the current function is a declaration and they
5296 // have the same name and same type. Clearly this is a redefinition.
5297 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005298 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005299 // Make sure to strip off any argument names so we can't get conflicts.
5300 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5301 AI != AE; ++AI)
5302 AI->setName("");
5303 }
5304 } else { // Not already defined?
Gabor Greif89f01162008-04-06 23:07:54 +00005305 Fn = Function::Create(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5306 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005307 InsertValue(Fn, CurModule.Values);
5308 }
5309
5310 CurFun.FunctionStart(Fn);
5311
5312 if (CurFun.isDeclare) {
5313 // If we have declaration, always overwrite linkage. This will allow us to
5314 // correctly handle cases, when pointer to function is passed as argument to
5315 // another function.
5316 Fn->setLinkage(CurFun.Linkage);
5317 Fn->setVisibility(CurFun.Visibility);
5318 }
Dan Gohman54392c12008-04-19 00:24:39 +00005319 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005320 Fn->setParamAttrs(PAL);
Dan Gohman54392c12008-04-19 00:24:39 +00005321 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5322 if ((yyvsp[(8) - (10)].StrVal)) {
5323 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5324 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00005325 }
Dan Gohman54392c12008-04-19 00:24:39 +00005326 if ((yyvsp[(10) - (10)].StrVal)) {
5327 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5328 delete (yyvsp[(10) - (10)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005329 }
5330
5331 // Add all of the arguments we parsed to the function...
Dan Gohman54392c12008-04-19 00:24:39 +00005332 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005333 if (isVarArg) { // Nuke the last entry
Dan Gohman54392c12008-04-19 00:24:39 +00005334 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005335 "Not a varargs marker!");
Dan Gohman54392c12008-04-19 00:24:39 +00005336 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5337 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005338 }
5339 Function::arg_iterator ArgIt = Fn->arg_begin();
5340 Function::arg_iterator ArgEnd = Fn->arg_end();
5341 unsigned Idx = 1;
Dan Gohman54392c12008-04-19 00:24:39 +00005342 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5343 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005344 delete I->Ty; // Delete the typeholder...
5345 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5346 CHECK_FOR_ERROR
5347 InsertValue(ArgIt);
5348 Idx++;
5349 }
5350
Dan Gohman54392c12008-04-19 00:24:39 +00005351 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005352 }
5353 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005354;}
5355 break;
5356
5357 case 243:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005358#line 2376 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005359 {
5360 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005361
5362 // Make sure that we keep track of the linkage type even if there was a
5363 // previous "declare".
Dan Gohman54392c12008-04-19 00:24:39 +00005364 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5365 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5366;}
5367 break;
5368
5369 case 246:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005370#line 2387 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005371 {
5372 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005373 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005374;}
5375 break;
5376
5377 case 247:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005378#line 2392 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005379 {
5380 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5381 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5382 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005383 CurFun.FunctionDone();
5384 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005385 ;}
5386 break;
5387
5388 case 248:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005389#line 2404 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005390 {
5391 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005392 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005393 ;}
5394 break;
5395
5396 case 249:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005397#line 2408 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005398 {
5399 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005400 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005401 ;}
5402 break;
5403
5404 case 250:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005405#line 2413 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005406 { // A reference to a direct constant
5407 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005408 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005409 ;}
5410 break;
5411
5412 case 251:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005413#line 2417 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005414 {
5415 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005416 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005417 ;}
5418 break;
5419
5420 case 252:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005421#line 2421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005422 { // Perhaps it's an FP constant?
5423 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005424 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005425 ;}
5426 break;
5427
5428 case 253:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005429#line 2425 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005430 {
5431 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005432 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005433 ;}
5434 break;
5435
5436 case 254:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005437#line 2429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005438 {
5439 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005440 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005441 ;}
5442 break;
5443
5444 case 255:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005445#line 2433 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005446 {
5447 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005448 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005449 ;}
5450 break;
5451
5452 case 256:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005453#line 2437 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005454 {
5455 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005456 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005457 ;}
5458 break;
5459
5460 case 257:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005461#line 2441 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005462 { // A vector zero constant.
5463 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005464 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005465 ;}
5466 break;
5467
5468 case 258:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005469#line 2445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005470 { // Nonempty unsized packed vector
5471 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5472 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005473
5474 VectorType* pt = VectorType::get(ETy, NumElements);
5475 PATypeHolder* PTy = new PATypeHolder(
5476 HandleUpRefs(
5477 VectorType::get(
5478 ETy,
5479 NumElements)
5480 )
5481 );
5482
5483 // Verify all elements are correct type!
Dan Gohman54392c12008-04-19 00:24:39 +00005484 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5485 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005486 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5487 ETy->getDescription() +"' as required!\nIt is of type '" +
Dan Gohman54392c12008-04-19 00:24:39 +00005488 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005489 }
5490
Dan Gohman54392c12008-04-19 00:24:39 +00005491 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5492 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005493 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005494 ;}
5495 break;
5496
5497 case 259:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005498#line 2470 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005499 {
5500 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005501 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005502 ;}
5503 break;
5504
5505 case 260:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005506#line 2474 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005507 {
5508 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5509 delete (yyvsp[(3) - (5)].StrVal);
5510 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005511 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005512 ;}
5513 break;
5514
5515 case 261:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005516#line 2484 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005517 { // Is it an integer reference...?
5518 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005519 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005520 ;}
5521 break;
5522
5523 case 262:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005524#line 2488 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005525 {
5526 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005527 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005528 ;}
5529 break;
5530
5531 case 263:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005532#line 2492 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005533 { // Is it a named reference...?
5534 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5535 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005536 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005537 ;}
5538 break;
5539
5540 case 264:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005541#line 2497 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005542 { // Is it a named reference...?
5543 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5544 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005545 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005546 ;}
5547 break;
5548
5549 case 267:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005550#line 2510 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005551 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005552 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005553 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5554 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5555 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005556 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005557 ;}
5558 break;
5559
5560 case 268:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005561#line 2519 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005562 {
5563 (yyval.ValueList) = new std::vector<Value *>();
5564 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
Devang Patelbf507402008-02-20 22:40:23 +00005565 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005566 ;}
5567 break;
5568
5569 case 269:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005570#line 2524 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005571 {
5572 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patelbf507402008-02-20 22:40:23 +00005573 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005574 ;}
5575 break;
5576
5577 case 270:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005578#line 2529 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005579 {
5580 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005581 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005582 ;}
5583 break;
5584
5585 case 271:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005586#line 2533 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005587 { // Do not allow functions with 0 basic blocks
5588 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005589 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005590 ;}
5591 break;
5592
5593 case 272:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005594#line 2542 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005595 {
5596 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005597 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005598 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5599 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5600 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005601 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005602 ;}
5603 break;
5604
5605 case 273:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005606#line 2551 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005607 {
5608 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005609 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5610 if (CI2->getParent() == 0)
Dan Gohman54392c12008-04-19 00:24:39 +00005611 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5612 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5613 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005614 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005615 ;}
5616 break;
Chris Lattner59363a32008-02-19 04:36:25 +00005617
Dan Gohman54392c12008-04-19 00:24:39 +00005618 case 274:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005619#line 2560 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005620 { // Empty space between instruction lists
Chris Lattnere7e9b602008-05-04 17:18:47 +00005621 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Dan Gohman54392c12008-04-19 00:24:39 +00005622 CHECK_FOR_ERROR
5623 ;}
5624 break;
5625
5626 case 275:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005627#line 2564 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
5628 { // Labelled (named) basic block
5629 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)));
5630 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohman54392c12008-04-19 00:24:39 +00005631 CHECK_FOR_ERROR
Chris Lattnere7e9b602008-05-04 17:18:47 +00005632
Dan Gohman54392c12008-04-19 00:24:39 +00005633 ;}
5634 break;
5635
5636 case 276:
Chris Lattnere7e9b602008-05-04 17:18:47 +00005637#line 2572 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005638 { // Return with a result...
5639 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
5640 assert(!VL.empty() && "Invalid ret operands!");
5641 (yyval.TermInstVal) = ReturnInst::Create(&VL[0], VL.size());
5642 delete (yyvsp[(2) - (2)].ValueList);
5643 CHECK_FOR_ERROR
5644 ;}
5645 break;
5646
Chris Lattnere7e9b602008-05-04 17:18:47 +00005647 case 277:
5648#line 2579 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005649 { // Return with no result...
5650 (yyval.TermInstVal) = ReturnInst::Create();
5651 CHECK_FOR_ERROR
5652 ;}
5653 break;
5654
Chris Lattnere7e9b602008-05-04 17:18:47 +00005655 case 278:
5656#line 2583 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005657 { // Unconditional Branch...
5658 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5659 CHECK_FOR_ERROR
5660 (yyval.TermInstVal) = BranchInst::Create(tmpBB);
5661 ;}
5662 break;
5663
Chris Lattnere7e9b602008-05-04 17:18:47 +00005664 case 279:
5665#line 2588 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005666 {
5667 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5668 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5669 CHECK_FOR_ERROR
5670 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5671 CHECK_FOR_ERROR
5672 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5673 CHECK_FOR_ERROR
5674 (yyval.TermInstVal) = BranchInst::Create(tmpBBA, tmpBBB, tmpVal);
5675 ;}
5676 break;
5677
Chris Lattnere7e9b602008-05-04 17:18:47 +00005678 case 280:
5679#line 2598 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005680 {
5681 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5682 CHECK_FOR_ERROR
5683 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5684 CHECK_FOR_ERROR
5685 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5686 (yyval.TermInstVal) = S;
5687
5688 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5689 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005690 for (; I != E; ++I) {
5691 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5692 S->addCase(CI, I->second);
5693 else
5694 GEN_ERROR("Switch case is constant, but not a simple integer");
5695 }
Dan Gohman54392c12008-04-19 00:24:39 +00005696 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005697 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005698 ;}
5699 break;
5700
Chris Lattnere7e9b602008-05-04 17:18:47 +00005701 case 281:
5702#line 2617 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005703 {
5704 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005705 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005706 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005707 CHECK_FOR_ERROR
Gabor Greif89f01162008-04-06 23:07:54 +00005708 SwitchInst *S = SwitchInst::Create(tmpVal, tmpBB, 0);
Dan Gohman54392c12008-04-19 00:24:39 +00005709 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005710 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005711 ;}
5712 break;
5713
Chris Lattnere7e9b602008-05-04 17:18:47 +00005714 case 282:
5715#line 2627 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005716 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005717
5718 // Handle the short syntax
5719 const PointerType *PFTy = 0;
5720 const FunctionType *Ty = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00005721 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005722 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5723 // Pull out the types of all of the arguments...
5724 std::vector<const Type*> ParamTypes;
Dan Gohman54392c12008-04-19 00:24:39 +00005725 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005726 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005727 const Type *Ty = I->Val->getType();
5728 if (Ty == Type::VoidTy)
5729 GEN_ERROR("Short call syntax cannot be used with varargs");
5730 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005731 }
Chris Lattner73de3c02008-04-23 05:37:08 +00005732
5733 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (14)].TypeVal)))
5734 GEN_ERROR("Invalid result type for LLVM function");
5735
Dan Gohman54392c12008-04-19 00:24:39 +00005736 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00005737 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005738 }
5739
Dan Gohman54392c12008-04-19 00:24:39 +00005740 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005741
Dan Gohman54392c12008-04-19 00:24:39 +00005742 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005743 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005744 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005745 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005746 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005747 CHECK_FOR_ERROR
5748
Chris Lattner1c8733e2008-03-12 17:45:29 +00005749 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohman54392c12008-04-19 00:24:39 +00005750 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None)
5751 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (14)].ParamAttrs)));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005752
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005753 // Check the arguments
5754 ValueList Args;
Dan Gohman54392c12008-04-19 00:24:39 +00005755 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005756 // Make sure no arguments is a good thing!
5757 if (Ty->getNumParams() != 0)
5758 GEN_ERROR("No arguments passed to a function that "
5759 "expects arguments");
5760 } else { // Has arguments?
5761 // Loop through FunctionType's arguments and ensure they are specified
5762 // correctly!
5763 FunctionType::param_iterator I = Ty->param_begin();
5764 FunctionType::param_iterator E = Ty->param_end();
Dan Gohman54392c12008-04-19 00:24:39 +00005765 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005766 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005767
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005768 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005769 if (ArgI->Val->getType() != *I)
5770 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5771 (*I)->getDescription() + "'");
5772 Args.push_back(ArgI->Val);
Chris Lattner1c8733e2008-03-12 17:45:29 +00005773 if (ArgI->Attrs != ParamAttr::None)
5774 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005775 }
5776
5777 if (Ty->isVarArg()) {
5778 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00005779 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005780 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner1c8733e2008-03-12 17:45:29 +00005781 if (ArgI->Attrs != ParamAttr::None)
5782 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00005783 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005784 } else if (I != E || ArgI != ArgE)
5785 GEN_ERROR("Invalid number of parameters detected");
5786 }
5787
Chris Lattner1c8733e2008-03-12 17:45:29 +00005788 PAListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005789 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00005790 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005791
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005792 // Create the InvokeInst
Gabor Greif89f01162008-04-06 23:07:54 +00005793 InvokeInst *II = InvokeInst::Create(V, Normal, Except, Args.begin(),Args.end());
Dan Gohman54392c12008-04-19 00:24:39 +00005794 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005795 II->setParamAttrs(PAL);
Dan Gohman54392c12008-04-19 00:24:39 +00005796 (yyval.TermInstVal) = II;
5797 delete (yyvsp[(6) - (14)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005798 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005799 ;}
5800 break;
5801
Chris Lattnere7e9b602008-05-04 17:18:47 +00005802 case 283:
5803#line 2711 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005804 {
5805 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005806 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005807 ;}
5808 break;
5809
Chris Lattnere7e9b602008-05-04 17:18:47 +00005810 case 284:
5811#line 2715 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005812 {
5813 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005814 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005815 ;}
5816 break;
5817
Chris Lattnere7e9b602008-05-04 17:18:47 +00005818 case 285:
5819#line 2722 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005820 {
5821 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5822 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005823 CHECK_FOR_ERROR
5824 if (V == 0)
5825 GEN_ERROR("May only switch on a constant pool value");
5826
Dan Gohman54392c12008-04-19 00:24:39 +00005827 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005828 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005829 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5830 ;}
5831 break;
5832
Chris Lattnere7e9b602008-05-04 17:18:47 +00005833 case 286:
5834#line 2733 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005835 {
5836 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5837 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005838 CHECK_FOR_ERROR
5839
5840 if (V == 0)
5841 GEN_ERROR("May only switch on a constant pool value");
5842
Dan Gohman54392c12008-04-19 00:24:39 +00005843 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005844 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005845 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5846 ;}
5847 break;
5848
Chris Lattnere7e9b602008-05-04 17:18:47 +00005849 case 287:
5850#line 2746 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005851 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005852 // Is this definition named?? if so, assign the name...
Dan Gohman54392c12008-04-19 00:24:39 +00005853 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005854 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005855 InsertValue((yyvsp[(2) - (2)].InstVal));
5856 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005857 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005858 ;}
5859 break;
5860
Chris Lattnere7e9b602008-05-04 17:18:47 +00005861 case 288:
5862#line 2756 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005863 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005864 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005865 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5866 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5867 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005868 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005869 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005870 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005871 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5872 delete (yyvsp[(1) - (6)].TypeVal);
5873 ;}
5874 break;
5875
Chris Lattnere7e9b602008-05-04 17:18:47 +00005876 case 289:
5877#line 2767 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005878 {
5879 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5880 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005881 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005882 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005883 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005884 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5885 ;}
5886 break;
5887
Chris Lattnere7e9b602008-05-04 17:18:47 +00005888 case 290:
5889#line 2777 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005890 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005891 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005892 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005893 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005894 // Used for call and invoke instructions
Dan Gohman54392c12008-04-19 00:24:39 +00005895 (yyval.ParamList) = new ParamList();
5896 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5897 (yyval.ParamList)->push_back(E);
5898 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005899 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005900 ;}
5901 break;
5902
Chris Lattnere7e9b602008-05-04 17:18:47 +00005903 case 291:
5904#line 2788 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005905 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005906 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00005907 // Labels are only valid in ASMs
Dan Gohman54392c12008-04-19 00:24:39 +00005908 (yyval.ParamList) = new ParamList();
5909 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5910 (yyval.ParamList)->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005911 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005912 ;}
5913 break;
5914
Chris Lattnere7e9b602008-05-04 17:18:47 +00005915 case 292:
5916#line 2796 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005917 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005918 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005919 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005920 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5921 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5922 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5923 (yyval.ParamList)->push_back(E);
5924 delete (yyvsp[(3) - (6)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005925 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005926 ;}
5927 break;
5928
Chris Lattnere7e9b602008-05-04 17:18:47 +00005929 case 293:
5930#line 2806 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005931 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005932 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohman54392c12008-04-19 00:24:39 +00005933 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5934 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5935 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00005936 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005937 ;}
5938 break;
5939
Chris Lattnere7e9b602008-05-04 17:18:47 +00005940 case 294:
5941#line 2813 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005942 { (yyval.ParamList) = new ParamList(); ;}
5943 break;
5944
Chris Lattnere7e9b602008-05-04 17:18:47 +00005945 case 295:
5946#line 2816 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005947 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5948 break;
5949
Chris Lattnere7e9b602008-05-04 17:18:47 +00005950 case 296:
5951#line 2817 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005952 {
5953 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5954 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005955 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005956 ;}
5957 break;
5958
Chris Lattnere7e9b602008-05-04 17:18:47 +00005959 case 297:
5960#line 2824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005961 {
5962 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005963 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005964 ;}
5965 break;
5966
Chris Lattnere7e9b602008-05-04 17:18:47 +00005967 case 298:
5968#line 2828 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005969 {
5970 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005971 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005972 ;}
5973 break;
5974
Chris Lattnere7e9b602008-05-04 17:18:47 +00005975 case 299:
5976#line 2833 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005977 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005978 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005979 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
5980 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
5981 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005982 GEN_ERROR(
5983 "Arithmetic operator requires integer, FP, or packed operands");
Dan Gohman54392c12008-04-19 00:24:39 +00005984 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005985 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005986 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005987 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00005988 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
5989 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005990 GEN_ERROR("binary operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00005991 delete (yyvsp[(2) - (5)].TypeVal);
5992 ;}
5993 break;
5994
Chris Lattnere7e9b602008-05-04 17:18:47 +00005995 case 300:
5996#line 2849 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00005997 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005998 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00005999 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6000 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
6001 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
6002 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006003 GEN_ERROR("Logical operator requires integral operands");
6004 }
Dan Gohman54392c12008-04-19 00:24:39 +00006005 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006006 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006007 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006008 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006009 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
6010 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006011 GEN_ERROR("binary operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006012 delete (yyvsp[(2) - (5)].TypeVal);
6013 ;}
6014 break;
6015
Chris Lattnere7e9b602008-05-04 17:18:47 +00006016 case 301:
6017#line 2866 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006018 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006019 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006020 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6021 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006022 GEN_ERROR("Vector types not supported by icmp instruction");
Dan Gohman54392c12008-04-19 00:24:39 +00006023 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006024 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006025 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006026 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006027 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6028 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006029 GEN_ERROR("icmp operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006030 delete (yyvsp[(3) - (6)].TypeVal);
6031 ;}
6032 break;
6033
Chris Lattnere7e9b602008-05-04 17:18:47 +00006034 case 302:
6035#line 2880 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006036 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006037 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006038 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6039 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006040 GEN_ERROR("Vector types not supported by fcmp instruction");
Dan Gohman54392c12008-04-19 00:24:39 +00006041 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006042 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006043 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006044 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006045 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6046 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006047 GEN_ERROR("fcmp operator returned null");
Dan Gohman54392c12008-04-19 00:24:39 +00006048 delete (yyvsp[(3) - (6)].TypeVal);
6049 ;}
6050 break;
6051
Chris Lattnere7e9b602008-05-04 17:18:47 +00006052 case 303:
6053#line 2894 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006054 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006055 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006056 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6057 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6058 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6059 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006060 GEN_ERROR("invalid cast opcode for cast from '" +
6061 Val->getType()->getDescription() + "' to '" +
6062 DestTy->getDescription() + "'");
Dan Gohman54392c12008-04-19 00:24:39 +00006063 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6064 delete (yyvsp[(4) - (4)].TypeVal);
6065 ;}
6066 break;
6067
Chris Lattnere7e9b602008-05-04 17:18:47 +00006068 case 304:
6069#line 2906 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006070 {
6071 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006072 GEN_ERROR("select condition must be boolean");
Dan Gohman54392c12008-04-19 00:24:39 +00006073 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006074 GEN_ERROR("select value types should match");
Dan Gohman54392c12008-04-19 00:24:39 +00006075 (yyval.InstVal) = SelectInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006076 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006077 ;}
6078 break;
6079
Chris Lattnere7e9b602008-05-04 17:18:47 +00006080 case 305:
6081#line 2914 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006082 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006083 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006084 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6085 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6086 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006087 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006088 ;}
6089 break;
6090
Chris Lattnere7e9b602008-05-04 17:18:47 +00006091 case 306:
6092#line 2921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006093 {
6094 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006095 GEN_ERROR("Invalid extractelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006096 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006097 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006098 ;}
6099 break;
6100
Chris Lattnere7e9b602008-05-04 17:18:47 +00006101 case 307:
6102#line 2927 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006103 {
6104 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006105 GEN_ERROR("Invalid insertelement operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006106 (yyval.InstVal) = InsertElementInst::Create((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006107 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006108 ;}
6109 break;
6110
Chris Lattnere7e9b602008-05-04 17:18:47 +00006111 case 308:
6112#line 2933 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006113 {
6114 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006115 GEN_ERROR("Invalid shufflevector operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006116 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006117 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006118 ;}
6119 break;
6120
Chris Lattnere7e9b602008-05-04 17:18:47 +00006121 case 309:
6122#line 2939 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006123 {
6124 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006125 if (!Ty->isFirstClassType())
6126 GEN_ERROR("PHI node operands must be of first class type");
Dan Gohman54392c12008-04-19 00:24:39 +00006127 (yyval.InstVal) = PHINode::Create(Ty);
6128 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6129 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6130 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006131 GEN_ERROR("All elements of a PHI node must be of the same type");
Dan Gohman54392c12008-04-19 00:24:39 +00006132 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6133 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006134 }
Dan Gohman54392c12008-04-19 00:24:39 +00006135 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006136 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006137 ;}
6138 break;
6139
Chris Lattnere7e9b602008-05-04 17:18:47 +00006140 case 310:
6141#line 2955 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006142 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006143
6144 // Handle the short syntax
6145 const PointerType *PFTy = 0;
6146 const FunctionType *Ty = 0;
Dan Gohman54392c12008-04-19 00:24:39 +00006147 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006148 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6149 // Pull out the types of all of the arguments...
6150 std::vector<const Type*> ParamTypes;
Dan Gohman54392c12008-04-19 00:24:39 +00006151 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006152 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006153 const Type *Ty = I->Val->getType();
6154 if (Ty == Type::VoidTy)
6155 GEN_ERROR("Short call syntax cannot be used with varargs");
6156 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006157 }
Chris Lattner73de3c02008-04-23 05:37:08 +00006158
6159 if (!FunctionType::isValidReturnType(*(yyvsp[(3) - (8)].TypeVal)))
6160 GEN_ERROR("Invalid result type for LLVM function");
6161
Dan Gohman54392c12008-04-19 00:24:39 +00006162 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00006163 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006164 }
6165
Dan Gohman54392c12008-04-19 00:24:39 +00006166 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006167 CHECK_FOR_ERROR
6168
6169 // Check for call to invalid intrinsic to avoid crashing later.
6170 if (Function *theF = dyn_cast<Function>(V)) {
6171 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6172 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6173 !theF->getIntrinsicID(true))
6174 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6175 theF->getName() + "'");
6176 }
6177
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006178 // Set up the ParamAttrs for the function
Chris Lattner1c8733e2008-03-12 17:45:29 +00006179 SmallVector<ParamAttrsWithIndex, 8> Attrs;
Dan Gohman54392c12008-04-19 00:24:39 +00006180 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None)
6181 Attrs.push_back(ParamAttrsWithIndex::get(0, (yyvsp[(8) - (8)].ParamAttrs)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006182 // Check the arguments
6183 ValueList Args;
Dan Gohman54392c12008-04-19 00:24:39 +00006184 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006185 // Make sure no arguments is a good thing!
6186 if (Ty->getNumParams() != 0)
6187 GEN_ERROR("No arguments passed to a function that "
6188 "expects arguments");
6189 } else { // Has arguments?
6190 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006191 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006192 FunctionType::param_iterator I = Ty->param_begin();
6193 FunctionType::param_iterator E = Ty->param_end();
Dan Gohman54392c12008-04-19 00:24:39 +00006194 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006195 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006196
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006197 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006198 if (ArgI->Val->getType() != *I)
6199 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6200 (*I)->getDescription() + "'");
6201 Args.push_back(ArgI->Val);
Chris Lattner1c8733e2008-03-12 17:45:29 +00006202 if (ArgI->Attrs != ParamAttr::None)
6203 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006204 }
6205 if (Ty->isVarArg()) {
6206 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00006207 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006208 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner1c8733e2008-03-12 17:45:29 +00006209 if (ArgI->Attrs != ParamAttr::None)
6210 Attrs.push_back(ParamAttrsWithIndex::get(index, ArgI->Attrs));
Chris Lattner59363a32008-02-19 04:36:25 +00006211 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006212 } else if (I != E || ArgI != ArgE)
6213 GEN_ERROR("Invalid number of parameters detected");
6214 }
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006215
6216 // Finish off the ParamAttrs and check them
Chris Lattner1c8733e2008-03-12 17:45:29 +00006217 PAListPtr PAL;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006218 if (!Attrs.empty())
Chris Lattner1c8733e2008-03-12 17:45:29 +00006219 PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006220
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006221 // Create the call node
Gabor Greif89f01162008-04-06 23:07:54 +00006222 CallInst *CI = CallInst::Create(V, Args.begin(), Args.end());
Dan Gohman54392c12008-04-19 00:24:39 +00006223 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6224 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006225 CI->setParamAttrs(PAL);
Dan Gohman54392c12008-04-19 00:24:39 +00006226 (yyval.InstVal) = CI;
6227 delete (yyvsp[(6) - (8)].ParamList);
6228 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006229 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006230 ;}
6231 break;
6232
Chris Lattnere7e9b602008-05-04 17:18:47 +00006233 case 311:
6234#line 3044 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006235 {
6236 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006237 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006238 ;}
6239 break;
6240
Chris Lattnere7e9b602008-05-04 17:18:47 +00006241 case 312:
6242#line 3049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006243 {
6244 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006245 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006246 ;}
6247 break;
6248
Chris Lattnere7e9b602008-05-04 17:18:47 +00006249 case 313:
6250#line 3053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006251 {
6252 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006253 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006254 ;}
6255 break;
6256
Chris Lattnere7e9b602008-05-04 17:18:47 +00006257 case 314:
6258#line 3060 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006259 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006260 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006261 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6262 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6263 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006264 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006265 ;}
6266 break;
6267
Chris Lattnere7e9b602008-05-04 17:18:47 +00006268 case 315:
6269#line 3067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006270 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006271 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006272 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6273 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006274 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006275 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6276 delete (yyvsp[(2) - (6)].TypeVal);
6277 ;}
6278 break;
6279
Chris Lattnere7e9b602008-05-04 17:18:47 +00006280 case 316:
6281#line 3075 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006282 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006283 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006284 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6285 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6286 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006287 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006288 ;}
6289 break;
6290
Chris Lattnere7e9b602008-05-04 17:18:47 +00006291 case 317:
6292#line 3082 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006293 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006294 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006295 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6296 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006297 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006298 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6299 delete (yyvsp[(2) - (6)].TypeVal);
6300 ;}
6301 break;
6302
Chris Lattnere7e9b602008-05-04 17:18:47 +00006303 case 318:
6304#line 3090 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006305 {
6306 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006307 GEN_ERROR("Trying to free nonpointer type " +
Dan Gohman54392c12008-04-19 00:24:39 +00006308 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6309 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006310 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006311 ;}
6312 break;
6313
Chris Lattnere7e9b602008-05-04 17:18:47 +00006314 case 319:
6315#line 3098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006316 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006317 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006318 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6319 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006320 GEN_ERROR("Can't load from nonpointer type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006321 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6322 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006323 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006324 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6325 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006326 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006327 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6328 delete (yyvsp[(3) - (5)].TypeVal);
6329 ;}
6330 break;
6331
Chris Lattnere7e9b602008-05-04 17:18:47 +00006332 case 320:
6333#line 3112 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006334 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006335 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006336 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6337 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006338 if (!PT)
6339 GEN_ERROR("Can't store to a nonpointer type: " +
Dan Gohman54392c12008-04-19 00:24:39 +00006340 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006341 const Type *ElTy = PT->getElementType();
Dan Gohman54392c12008-04-19 00:24:39 +00006342 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6343 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006344 "' into space of type '" + ElTy->getDescription() + "'");
6345
Dan Gohman54392c12008-04-19 00:24:39 +00006346 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006347 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006348 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6349 delete (yyvsp[(5) - (7)].TypeVal);
6350 ;}
6351 break;
6352
Chris Lattnere7e9b602008-05-04 17:18:47 +00006353 case 321:
6354#line 3129 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006355 {
6356 Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
6357 if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
Devang Patel3b8849c2008-02-19 22:27:01 +00006358 GEN_ERROR("Invalid getresult operands");
Dan Gohman54392c12008-04-19 00:24:39 +00006359 (yyval.InstVal) = new GetResultInst(TmpVal, (yyvsp[(5) - (5)].UInt64Val));
6360 delete (yyvsp[(2) - (5)].TypeVal);
Devang Patel3b8849c2008-02-19 22:27:01 +00006361 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006362 ;}
6363 break;
6364
Chris Lattnere7e9b602008-05-04 17:18:47 +00006365 case 322:
6366#line 3137 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohman54392c12008-04-19 00:24:39 +00006367 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006368 if (!UpRefs.empty())
Dan Gohman54392c12008-04-19 00:24:39 +00006369 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6370 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006371 GEN_ERROR("getelementptr insn requires pointer operand");
6372
Dan Gohman54392c12008-04-19 00:24:39 +00006373 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 +00006374 GEN_ERROR("Invalid getelementptr indices for type '" +
Dan Gohman54392c12008-04-19 00:24:39 +00006375 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6376 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006377 CHECK_FOR_ERROR
Dan Gohman54392c12008-04-19 00:24:39 +00006378 (yyval.InstVal) = GetElementPtrInst::Create(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6379 delete (yyvsp[(2) - (4)].TypeVal);
6380 delete (yyvsp[(4) - (4)].ValueList);
6381 ;}
6382 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006383
Dan Gohman54392c12008-04-19 00:24:39 +00006384
6385/* Line 1267 of yacc.c. */
Chris Lattnere7e9b602008-05-04 17:18:47 +00006386#line 6387 "llvmAsmParser.tab.c"
Dan Gohman54392c12008-04-19 00:24:39 +00006387 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00006388 }
Dan Gohman54392c12008-04-19 00:24:39 +00006389 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6390
6391 YYPOPSTACK (yylen);
6392 yylen = 0;
6393 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006394
6395 *++yyvsp = yyval;
6396
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006397
Dan Gohman54392c12008-04-19 00:24:39 +00006398 /* Now `shift' the result of the reduction. Determine what state
6399 that goes to, based on the state we popped back to and the rule
6400 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006401
6402 yyn = yyr1[yyn];
6403
Dan Gohman54392c12008-04-19 00:24:39 +00006404 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6405 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006406 yystate = yytable[yystate];
6407 else
Dan Gohman54392c12008-04-19 00:24:39 +00006408 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006409
6410 goto yynewstate;
6411
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006412
Dan Gohman54392c12008-04-19 00:24:39 +00006413/*------------------------------------.
6414| yyerrlab -- here on detecting error |
6415`------------------------------------*/
6416yyerrlab:
6417 /* If not already recovering from an error, report this error. */
6418 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006419 {
6420 ++yynerrs;
Dan Gohman54392c12008-04-19 00:24:39 +00006421#if ! YYERROR_VERBOSE
6422 yyerror (YY_("syntax error"));
6423#else
6424 {
6425 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6426 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6427 {
6428 YYSIZE_T yyalloc = 2 * yysize;
6429 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6430 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6431 if (yymsg != yymsgbuf)
6432 YYSTACK_FREE (yymsg);
6433 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6434 if (yymsg)
6435 yymsg_alloc = yyalloc;
6436 else
6437 {
6438 yymsg = yymsgbuf;
6439 yymsg_alloc = sizeof yymsgbuf;
6440 }
6441 }
Dale Johannesen3afee192007-09-07 21:07:57 +00006442
Dan Gohman54392c12008-04-19 00:24:39 +00006443 if (0 < yysize && yysize <= yymsg_alloc)
6444 {
6445 (void) yysyntax_error (yymsg, yystate, yychar);
6446 yyerror (yymsg);
6447 }
6448 else
6449 {
6450 yyerror (YY_("syntax error"));
6451 if (yysize != 0)
6452 goto yyexhaustedlab;
6453 }
6454 }
6455#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006456 }
6457
Dan Gohman54392c12008-04-19 00:24:39 +00006458
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006459
6460 if (yyerrstatus == 3)
6461 {
Dan Gohman54392c12008-04-19 00:24:39 +00006462 /* If just tried and failed to reuse look-ahead token after an
6463 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006464
Dan Gohman54392c12008-04-19 00:24:39 +00006465 if (yychar <= YYEOF)
6466 {
6467 /* Return failure if at end of input. */
6468 if (yychar == YYEOF)
6469 YYABORT;
6470 }
6471 else
6472 {
6473 yydestruct ("Error: discarding",
6474 yytoken, &yylval);
6475 yychar = YYEMPTY;
6476 }
6477 }
6478
6479 /* Else will try to reuse look-ahead token after shifting the error
6480 token. */
6481 goto yyerrlab1;
6482
6483
6484/*---------------------------------------------------.
6485| yyerrorlab -- error raised explicitly by YYERROR. |
6486`---------------------------------------------------*/
6487yyerrorlab:
6488
6489 /* Pacify compilers like GCC when the user code never invokes
6490 YYERROR and the label yyerrorlab therefore never appears in user
6491 code. */
6492 if (/*CONSTCOND*/ 0)
6493 goto yyerrorlab;
6494
6495 /* Do not reclaim the symbols of the rule which action triggered
6496 this YYERROR. */
6497 YYPOPSTACK (yylen);
6498 yylen = 0;
6499 YY_STACK_PRINT (yyss, yyssp);
6500 yystate = *yyssp;
6501 goto yyerrlab1;
6502
6503
6504/*-------------------------------------------------------------.
6505| yyerrlab1 -- common code for both syntax error and YYERROR. |
6506`-------------------------------------------------------------*/
6507yyerrlab1:
6508 yyerrstatus = 3; /* Each real token shifted decrements this. */
6509
6510 for (;;)
6511 {
6512 yyn = yypact[yystate];
6513 if (yyn != YYPACT_NINF)
6514 {
6515 yyn += YYTERROR;
6516 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6517 {
6518 yyn = yytable[yyn];
6519 if (0 < yyn)
6520 break;
6521 }
6522 }
6523
6524 /* Pop the current state because it cannot handle the error token. */
6525 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006526 YYABORT;
6527
Dale Johannesen3afee192007-09-07 21:07:57 +00006528
Dan Gohman54392c12008-04-19 00:24:39 +00006529 yydestruct ("Error: popping",
6530 yystos[yystate], yyvsp);
6531 YYPOPSTACK (1);
6532 yystate = *yyssp;
6533 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006534 }
6535
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006536 if (yyn == YYFINAL)
6537 YYACCEPT;
6538
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006539 *++yyvsp = yylval;
Dan Gohman54392c12008-04-19 00:24:39 +00006540
6541
6542 /* Shift the error token. */
6543 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006544
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006545 yystate = yyn;
6546 goto yynewstate;
6547
Gabor Greif89f01162008-04-06 23:07:54 +00006548
Dan Gohman54392c12008-04-19 00:24:39 +00006549/*-------------------------------------.
6550| yyacceptlab -- YYACCEPT comes here. |
6551`-------------------------------------*/
6552yyacceptlab:
6553 yyresult = 0;
6554 goto yyreturn;
6555
6556/*-----------------------------------.
6557| yyabortlab -- YYABORT comes here. |
6558`-----------------------------------*/
6559yyabortlab:
6560 yyresult = 1;
6561 goto yyreturn;
6562
6563#ifndef yyoverflow
6564/*-------------------------------------------------.
6565| yyexhaustedlab -- memory exhaustion comes here. |
6566`-------------------------------------------------*/
6567yyexhaustedlab:
6568 yyerror (YY_("memory exhausted"));
6569 yyresult = 2;
6570 /* Fall through. */
Chris Lattner59363a32008-02-19 04:36:25 +00006571#endif
Dan Gohman54392c12008-04-19 00:24:39 +00006572
6573yyreturn:
6574 if (yychar != YYEOF && yychar != YYEMPTY)
6575 yydestruct ("Cleanup: discarding lookahead",
6576 yytoken, &yylval);
6577 /* Do not reclaim the symbols of the rule which action triggered
6578 this YYABORT or YYACCEPT. */
6579 YYPOPSTACK (yylen);
6580 YY_STACK_PRINT (yyss, yyssp);
6581 while (yyssp != yyss)
6582 {
6583 yydestruct ("Cleanup: popping",
6584 yystos[*yyssp], yyvsp);
6585 YYPOPSTACK (1);
Gabor Greif89f01162008-04-06 23:07:54 +00006586 }
Dan Gohman54392c12008-04-19 00:24:39 +00006587#ifndef yyoverflow
6588 if (yyss != yyssa)
6589 YYSTACK_FREE (yyss);
6590#endif
6591#if YYERROR_VERBOSE
6592 if (yymsg != yymsgbuf)
6593 YYSTACK_FREE (yymsg);
6594#endif
6595 /* Make sure YYID is used. */
6596 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006597}
Dan Gohman54392c12008-04-19 00:24:39 +00006598
6599
Chris Lattnere7e9b602008-05-04 17:18:47 +00006600#line 3154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006601
6602
6603// common code from the two 'RunVMAsmParser' functions
6604static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006605 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006606 // Check to make sure the parser succeeded
6607 if (yyparse()) {
6608 if (ParserResult)
6609 delete ParserResult;
6610 return 0;
6611 }
6612
6613 // Emit an error if there are any unresolved types left.
6614 if (!CurModule.LateResolveTypes.empty()) {
6615 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6616 if (DID.Type == ValID::LocalName) {
6617 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6618 } else {
6619 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6620 }
6621 if (ParserResult)
6622 delete ParserResult;
6623 return 0;
6624 }
6625
6626 // Emit an error if there are any unresolved values left.
6627 if (!CurModule.LateResolveValues.empty()) {
6628 Value *V = CurModule.LateResolveValues.back();
6629 std::map<Value*, std::pair<ValID, int> >::iterator I =
6630 CurModule.PlaceHolderInfo.find(V);
6631
6632 if (I != CurModule.PlaceHolderInfo.end()) {
6633 ValID &DID = I->second.first;
6634 if (DID.Type == ValID::LocalName) {
6635 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6636 } else {
6637 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6638 }
6639 if (ParserResult)
6640 delete ParserResult;
6641 return 0;
6642 }
6643 }
6644
6645 // Check to make sure that parsing produced a result
6646 if (!ParserResult)
6647 return 0;
6648
6649 // Reset ParserResult variable while saving its value for the result.
6650 Module *Result = ParserResult;
6651 ParserResult = 0;
6652
6653 return Result;
6654}
6655
6656void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006657 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006658 // TODO: column number in exception
6659 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006660 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006661 TriggerError = 1;
6662}
6663
6664int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006665 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006666 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006667 if (yychar != YYEMPTY && yychar != 0) {
6668 errMsg += " while reading token: '";
6669 errMsg += std::string(LLLgetTokenStart(),
6670 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6671 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006672 GenerateError(errMsg);
6673 return 0;
6674}
Dan Gohman54392c12008-04-19 00:24:39 +00006675