blob: c0de61723eb822487c20179e2052a6fb938418e2 [file] [log] [blame]
Chris Lattner59363a32008-02-19 04:36:25 +00001/* A Bison parser, made by GNU Bison 2.3. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Chris Lattner59363a32008-02-19 04:36:25 +00003/* Skeleton implementation for Bison's Yacc-like parsers in C
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Chris Lattner59363a32008-02-19 04:36:25 +00005 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007
Chris Lattner59363a32008-02-19 04:36:25 +00008 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23/* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36/* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39/* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46/* Identify Bison output. */
47#define YYBISON 1
48
49/* Bison version. */
50#define YYBISON_VERSION "2.3"
51
52/* Skeleton name. */
53#define YYSKELETON_NAME "yacc.c"
54
55/* Pure parsers. */
56#define YYPURE 0
57
58/* Using locations. */
59#define YYLSP_NEEDED 0
60
61/* Substitute the variable and function names. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062#define yyparse llvmAsmparse
Chris Lattner59363a32008-02-19 04:36:25 +000063#define yylex llvmAsmlex
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064#define yyerror llvmAsmerror
Chris Lattner59363a32008-02-19 04:36:25 +000065#define yylval llvmAsmlval
66#define yychar llvmAsmchar
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067#define yydebug llvmAsmdebug
68#define yynerrs llvmAsmnerrs
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
Chris Lattner59363a32008-02-19 04:36:25 +000070
71/* Tokens. */
72#ifndef YYTOKENTYPE
73# define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ESINT64VAL = 258,
78 EUINT64VAL = 259,
79 ESAPINTVAL = 260,
80 EUAPINTVAL = 261,
81 LOCALVAL_ID = 262,
82 GLOBALVAL_ID = 263,
83 FPVAL = 264,
84 VOID = 265,
85 INTTYPE = 266,
86 FLOAT = 267,
87 DOUBLE = 268,
88 X86_FP80 = 269,
89 FP128 = 270,
90 PPC_FP128 = 271,
91 LABEL = 272,
92 TYPE = 273,
93 LOCALVAR = 274,
94 GLOBALVAR = 275,
95 LABELSTR = 276,
96 STRINGCONSTANT = 277,
97 ATSTRINGCONSTANT = 278,
98 PCTSTRINGCONSTANT = 279,
99 ZEROINITIALIZER = 280,
100 TRUETOK = 281,
101 FALSETOK = 282,
102 BEGINTOK = 283,
103 ENDTOK = 284,
104 DECLARE = 285,
105 DEFINE = 286,
106 GLOBAL = 287,
107 CONSTANT = 288,
108 SECTION = 289,
109 ALIAS = 290,
110 VOLATILE = 291,
111 THREAD_LOCAL = 292,
112 TO = 293,
113 DOTDOTDOT = 294,
114 NULL_TOK = 295,
115 UNDEF = 296,
116 INTERNAL = 297,
117 LINKONCE = 298,
118 WEAK = 299,
119 APPENDING = 300,
120 DLLIMPORT = 301,
121 DLLEXPORT = 302,
122 EXTERN_WEAK = 303,
123 OPAQUE = 304,
124 EXTERNAL = 305,
125 TARGET = 306,
126 TRIPLE = 307,
127 ALIGN = 308,
128 ADDRSPACE = 309,
129 DEPLIBS = 310,
130 CALL = 311,
131 TAIL = 312,
132 ASM_TOK = 313,
133 MODULE = 314,
134 SIDEEFFECT = 315,
135 CC_TOK = 316,
136 CCC_TOK = 317,
137 FASTCC_TOK = 318,
138 COLDCC_TOK = 319,
139 X86_STDCALLCC_TOK = 320,
140 X86_FASTCALLCC_TOK = 321,
141 DATALAYOUT = 322,
Nick Lewycky92b80c72008-03-10 05:01:34 +0000142 UNWINDS = 323,
Devang Patel890cc572008-03-03 18:58:47 +0000143 RET = 324,
144 BR = 325,
145 SWITCH = 326,
146 INVOKE = 327,
147 UNWIND = 328,
148 UNREACHABLE = 329,
149 ADD = 330,
150 SUB = 331,
151 MUL = 332,
152 UDIV = 333,
153 SDIV = 334,
154 FDIV = 335,
155 UREM = 336,
156 SREM = 337,
157 FREM = 338,
158 AND = 339,
159 OR = 340,
160 XOR = 341,
161 SHL = 342,
162 LSHR = 343,
163 ASHR = 344,
164 ICMP = 345,
165 FCMP = 346,
166 EQ = 347,
167 NE = 348,
168 SLT = 349,
169 SGT = 350,
170 SLE = 351,
171 SGE = 352,
172 ULT = 353,
173 UGT = 354,
174 ULE = 355,
175 UGE = 356,
176 OEQ = 357,
177 ONE = 358,
178 OLT = 359,
179 OGT = 360,
180 OLE = 361,
181 OGE = 362,
182 ORD = 363,
183 UNO = 364,
184 UEQ = 365,
185 UNE = 366,
186 MALLOC = 367,
187 ALLOCA = 368,
188 FREE = 369,
189 LOAD = 370,
190 STORE = 371,
191 GETELEMENTPTR = 372,
192 TRUNC = 373,
193 ZEXT = 374,
194 SEXT = 375,
195 FPTRUNC = 376,
196 FPEXT = 377,
197 BITCAST = 378,
198 UITOFP = 379,
199 SITOFP = 380,
200 FPTOUI = 381,
201 FPTOSI = 382,
202 INTTOPTR = 383,
203 PTRTOINT = 384,
204 PHI_TOK = 385,
205 SELECT = 386,
206 VAARG = 387,
207 EXTRACTELEMENT = 388,
208 INSERTELEMENT = 389,
209 SHUFFLEVECTOR = 390,
210 GETRESULT = 391,
211 SIGNEXT = 392,
212 ZEROEXT = 393,
213 NORETURN = 394,
214 INREG = 395,
215 SRET = 396,
216 NOUNWIND = 397,
217 NOALIAS = 398,
218 BYVAL = 399,
219 NEST = 400,
220 READNONE = 401,
221 READONLY = 402,
222 GC = 403,
223 DEFAULT = 404,
224 HIDDEN = 405,
225 PROTECTED = 406
Chris Lattner59363a32008-02-19 04:36:25 +0000226 };
227#endif
228/* Tokens. */
229#define ESINT64VAL 258
230#define EUINT64VAL 259
231#define ESAPINTVAL 260
232#define EUAPINTVAL 261
233#define LOCALVAL_ID 262
234#define GLOBALVAL_ID 263
235#define FPVAL 264
236#define VOID 265
237#define INTTYPE 266
238#define FLOAT 267
239#define DOUBLE 268
240#define X86_FP80 269
241#define FP128 270
242#define PPC_FP128 271
243#define LABEL 272
244#define TYPE 273
245#define LOCALVAR 274
246#define GLOBALVAR 275
247#define LABELSTR 276
248#define STRINGCONSTANT 277
249#define ATSTRINGCONSTANT 278
250#define PCTSTRINGCONSTANT 279
251#define ZEROINITIALIZER 280
252#define TRUETOK 281
253#define FALSETOK 282
254#define BEGINTOK 283
255#define ENDTOK 284
256#define DECLARE 285
257#define DEFINE 286
258#define GLOBAL 287
259#define CONSTANT 288
260#define SECTION 289
261#define ALIAS 290
262#define VOLATILE 291
263#define THREAD_LOCAL 292
264#define TO 293
265#define DOTDOTDOT 294
266#define NULL_TOK 295
267#define UNDEF 296
268#define INTERNAL 297
269#define LINKONCE 298
270#define WEAK 299
271#define APPENDING 300
272#define DLLIMPORT 301
273#define DLLEXPORT 302
274#define EXTERN_WEAK 303
275#define OPAQUE 304
276#define EXTERNAL 305
277#define TARGET 306
278#define TRIPLE 307
279#define ALIGN 308
280#define ADDRSPACE 309
281#define DEPLIBS 310
282#define CALL 311
283#define TAIL 312
284#define ASM_TOK 313
285#define MODULE 314
286#define SIDEEFFECT 315
287#define CC_TOK 316
288#define CCC_TOK 317
289#define FASTCC_TOK 318
290#define COLDCC_TOK 319
291#define X86_STDCALLCC_TOK 320
292#define X86_FASTCALLCC_TOK 321
293#define DATALAYOUT 322
Nick Lewycky92b80c72008-03-10 05:01:34 +0000294#define UNWINDS 323
Devang Patel890cc572008-03-03 18:58:47 +0000295#define RET 324
296#define BR 325
297#define SWITCH 326
298#define INVOKE 327
299#define UNWIND 328
300#define UNREACHABLE 329
301#define ADD 330
302#define SUB 331
303#define MUL 332
304#define UDIV 333
305#define SDIV 334
306#define FDIV 335
307#define UREM 336
308#define SREM 337
309#define FREM 338
310#define AND 339
311#define OR 340
312#define XOR 341
313#define SHL 342
314#define LSHR 343
315#define ASHR 344
316#define ICMP 345
317#define FCMP 346
318#define EQ 347
319#define NE 348
320#define SLT 349
321#define SGT 350
322#define SLE 351
323#define SGE 352
324#define ULT 353
325#define UGT 354
326#define ULE 355
327#define UGE 356
328#define OEQ 357
329#define ONE 358
330#define OLT 359
331#define OGT 360
332#define OLE 361
333#define OGE 362
334#define ORD 363
335#define UNO 364
336#define UEQ 365
337#define UNE 366
338#define MALLOC 367
339#define ALLOCA 368
340#define FREE 369
341#define LOAD 370
342#define STORE 371
343#define GETELEMENTPTR 372
344#define TRUNC 373
345#define ZEXT 374
346#define SEXT 375
347#define FPTRUNC 376
348#define FPEXT 377
349#define BITCAST 378
350#define UITOFP 379
351#define SITOFP 380
352#define FPTOUI 381
353#define FPTOSI 382
354#define INTTOPTR 383
355#define PTRTOINT 384
356#define PHI_TOK 385
357#define SELECT 386
358#define VAARG 387
359#define EXTRACTELEMENT 388
360#define INSERTELEMENT 389
361#define SHUFFLEVECTOR 390
362#define GETRESULT 391
363#define SIGNEXT 392
364#define ZEROEXT 393
365#define NORETURN 394
366#define INREG 395
367#define SRET 396
368#define NOUNWIND 397
369#define NOALIAS 398
370#define BYVAL 399
371#define NEST 400
372#define READNONE 401
373#define READONLY 402
374#define GC 403
375#define DEFAULT 404
376#define HIDDEN 405
377#define PROTECTED 406
Chris Lattner59363a32008-02-19 04:36:25 +0000378
379
380
381
382/* Copy the first part of user declarations. */
Nick Lewycky92b80c72008-03-10 05:01:34 +0000383#line 14 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
385#include "ParserInternals.h"
386#include "llvm/CallingConv.h"
387#include "llvm/InlineAsm.h"
388#include "llvm/Instructions.h"
389#include "llvm/Module.h"
390#include "llvm/ValueSymbolTable.h"
Chandler Carruth563d4a42007-08-04 01:56:21 +0000391#include "llvm/AutoUpgrade.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392#include "llvm/Support/GetElementPtrTypeIterator.h"
393#include "llvm/Support/CommandLine.h"
394#include "llvm/ADT/SmallVector.h"
395#include "llvm/ADT/STLExtras.h"
396#include "llvm/Support/MathExtras.h"
397#include "llvm/Support/Streams.h"
Dale Johannesen98738822008-02-22 22:17:59 +0000398#include "llvm/ParamAttrsList.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399#include <algorithm>
400#include <list>
401#include <map>
402#include <utility>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403
404// The following is a gross hack. In order to rid the libAsmParser library of
405// exceptions, we have to have a way of getting the yyparse function to go into
406// an error situation. So, whenever we want an error to occur, the GenerateError
407// function (see bottom of file) sets TriggerError. Then, at the end of each
408// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
409// (a goto) to put YACC in error state. Furthermore, several calls to
410// GenerateError are made from inside productions and they must simulate the
411// previous exception behavior by exiting the production immediately. We have
412// replaced these with the GEN_ERROR macro which calls GeneratError and then
413// immediately invokes YYERROR. This would be so much cleaner if it was a
414// recursive descent parser.
415static bool TriggerError = false;
416#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
417#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
418
419int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
420int yylex(); // declaration" of xxx warnings.
421int yyparse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422using namespace llvm;
423
424static Module *ParserResult;
425
426// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
427// relating to upreferences in the input stream.
428//
429//#define DEBUG_UPREFS 1
430#ifdef DEBUG_UPREFS
431#define UR_OUT(X) cerr << X
432#else
433#define UR_OUT(X)
434#endif
435
436#define YYERROR_VERBOSE 1
437
438static GlobalVariable *CurGV;
439
440
441// This contains info used when building the body of a function. It is
442// destroyed when the function is completed.
443//
444typedef std::vector<Value *> ValueList; // Numbered defs
445
446static void
447ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
448
449static struct PerModuleInfo {
450 Module *CurrentModule;
451 ValueList Values; // Module level numbered definitions
452 ValueList LateResolveValues;
453 std::vector<PATypeHolder> Types;
454 std::map<ValID, PATypeHolder> LateResolveTypes;
455
456 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
457 /// how they were referenced and on which line of the input they came from so
458 /// that we can resolve them later and print error messages as appropriate.
459 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
460
461 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
462 // references to global values. Global values may be referenced before they
463 // are defined, and if so, the temporary object that they represent is held
464 // here. This is used for forward references of GlobalValues.
465 //
466 typedef std::map<std::pair<const PointerType *,
467 ValID>, GlobalValue*> GlobalRefsType;
468 GlobalRefsType GlobalRefs;
469
470 void ModuleDone() {
471 // If we could not resolve some functions at function compilation time
472 // (calls to functions before they are defined), resolve them now... Types
473 // are resolved when the constant pool has been completely parsed.
474 //
475 ResolveDefinitions(LateResolveValues);
476 if (TriggerError)
477 return;
478
479 // Check to make sure that all global value forward references have been
480 // resolved!
481 //
482 if (!GlobalRefs.empty()) {
483 std::string UndefinedReferences = "Unresolved global references exist:\n";
484
485 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
486 I != E; ++I) {
487 UndefinedReferences += " " + I->first.first->getDescription() + " " +
488 I->first.second.getName() + "\n";
489 }
490 GenerateError(UndefinedReferences);
491 return;
492 }
493
Chandler Carruth563d4a42007-08-04 01:56:21 +0000494 // Look for intrinsic functions and CallInst that need to be upgraded
495 for (Module::iterator FI = CurrentModule->begin(),
496 FE = CurrentModule->end(); FI != FE; )
497 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
498
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499 Values.clear(); // Clear out function local definitions
500 Types.clear();
501 CurrentModule = 0;
502 }
503
504 // GetForwardRefForGlobal - Check to see if there is a forward reference
505 // for this global. If so, remove it from the GlobalRefs map and return it.
506 // If not, just return null.
507 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
508 // Check to see if there is a forward reference to this global variable...
509 // if there is, eliminate it and patch the reference to use the new def'n.
510 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
511 GlobalValue *Ret = 0;
512 if (I != GlobalRefs.end()) {
513 Ret = I->second;
514 GlobalRefs.erase(I);
515 }
516 return Ret;
517 }
518
519 bool TypeIsUnresolved(PATypeHolder* PATy) {
520 // If it isn't abstract, its resolved
521 const Type* Ty = PATy->get();
522 if (!Ty->isAbstract())
523 return false;
524 // Traverse the type looking for abstract types. If it isn't abstract then
525 // we don't need to traverse that leg of the type.
526 std::vector<const Type*> WorkList, SeenList;
527 WorkList.push_back(Ty);
528 while (!WorkList.empty()) {
529 const Type* Ty = WorkList.back();
530 SeenList.push_back(Ty);
531 WorkList.pop_back();
532 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
533 // Check to see if this is an unresolved type
534 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
535 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
536 for ( ; I != E; ++I) {
537 if (I->second.get() == OpTy)
538 return true;
539 }
540 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
541 const Type* TheTy = SeqTy->getElementType();
542 if (TheTy->isAbstract() && TheTy != Ty) {
543 std::vector<const Type*>::iterator I = SeenList.begin(),
544 E = SeenList.end();
545 for ( ; I != E; ++I)
546 if (*I == TheTy)
547 break;
548 if (I == E)
549 WorkList.push_back(TheTy);
550 }
551 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
552 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
553 const Type* TheTy = StrTy->getElementType(i);
554 if (TheTy->isAbstract() && TheTy != Ty) {
555 std::vector<const Type*>::iterator I = SeenList.begin(),
556 E = SeenList.end();
557 for ( ; I != E; ++I)
558 if (*I == TheTy)
559 break;
560 if (I == E)
561 WorkList.push_back(TheTy);
562 }
563 }
564 }
565 }
566 return false;
567 }
568} CurModule;
569
570static struct PerFunctionInfo {
571 Function *CurrentFunction; // Pointer to current function being created
572
573 ValueList Values; // Keep track of #'d definitions
574 unsigned NextValNum;
575 ValueList LateResolveValues;
576 bool isDeclare; // Is this function a forward declararation?
577 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
578 GlobalValue::VisibilityTypes Visibility;
579
580 /// BBForwardRefs - When we see forward references to basic blocks, keep
581 /// track of them here.
582 std::map<ValID, BasicBlock*> BBForwardRefs;
583
584 inline PerFunctionInfo() {
585 CurrentFunction = 0;
586 isDeclare = false;
587 Linkage = GlobalValue::ExternalLinkage;
588 Visibility = GlobalValue::DefaultVisibility;
589 }
590
591 inline void FunctionStart(Function *M) {
592 CurrentFunction = M;
593 NextValNum = 0;
594 }
595
596 void FunctionDone() {
597 // Any forward referenced blocks left?
598 if (!BBForwardRefs.empty()) {
599 GenerateError("Undefined reference to label " +
600 BBForwardRefs.begin()->second->getName());
601 return;
602 }
603
604 // Resolve all forward references now.
605 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
606
607 Values.clear(); // Clear out function local definitions
608 BBForwardRefs.clear();
609 CurrentFunction = 0;
610 isDeclare = false;
611 Linkage = GlobalValue::ExternalLinkage;
612 Visibility = GlobalValue::DefaultVisibility;
613 }
614} CurFun; // Info for the current function...
615
616static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
617
618
619//===----------------------------------------------------------------------===//
620// Code to handle definitions of all the types
621//===----------------------------------------------------------------------===//
622
623static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
624 // Things that have names or are void typed don't get slot numbers
625 if (V->hasName() || (V->getType() == Type::VoidTy))
626 return;
627
628 // In the case of function values, we have to allow for the forward reference
629 // of basic blocks, which are included in the numbering. Consequently, we keep
630 // track of the next insertion location with NextValNum. When a BB gets
631 // inserted, it could change the size of the CurFun.Values vector.
632 if (&ValueTab == &CurFun.Values) {
633 if (ValueTab.size() <= CurFun.NextValNum)
634 ValueTab.resize(CurFun.NextValNum+1);
635 ValueTab[CurFun.NextValNum++] = V;
636 return;
637 }
638 // For all other lists, its okay to just tack it on the back of the vector.
639 ValueTab.push_back(V);
640}
641
642static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
643 switch (D.Type) {
644 case ValID::LocalID: // Is it a numbered definition?
645 // Module constants occupy the lowest numbered slots...
646 if (D.Num < CurModule.Types.size())
647 return CurModule.Types[D.Num];
648 break;
649 case ValID::LocalName: // Is it a named definition?
650 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
651 D.destroy(); // Free old strdup'd memory...
652 return N;
653 }
654 break;
655 default:
656 GenerateError("Internal parser error: Invalid symbol type reference");
657 return 0;
658 }
659
660 // If we reached here, we referenced either a symbol that we don't know about
661 // or an id number that hasn't been read yet. We may be referencing something
662 // forward, so just create an entry to be resolved later and get to it...
663 //
664 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
665
666
667 if (inFunctionScope()) {
668 if (D.Type == ValID::LocalName) {
669 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
670 return 0;
671 } else {
672 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
673 return 0;
674 }
675 }
676
677 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
678 if (I != CurModule.LateResolveTypes.end())
679 return I->second;
680
681 Type *Typ = OpaqueType::get();
682 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
683 return Typ;
684 }
685
686// getExistingVal - Look up the value specified by the provided type and
687// the provided ValID. If the value exists and has already been defined, return
688// it. Otherwise return null.
689//
690static Value *getExistingVal(const Type *Ty, const ValID &D) {
691 if (isa<FunctionType>(Ty)) {
692 GenerateError("Functions are not values and "
693 "must be referenced as pointers");
694 return 0;
695 }
696
697 switch (D.Type) {
698 case ValID::LocalID: { // Is it a numbered definition?
699 // Check that the number is within bounds.
700 if (D.Num >= CurFun.Values.size())
701 return 0;
702 Value *Result = CurFun.Values[D.Num];
703 if (Ty != Result->getType()) {
704 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
705 Result->getType()->getDescription() + "' does not match "
706 "expected type, '" + Ty->getDescription() + "'");
707 return 0;
708 }
709 return Result;
710 }
711 case ValID::GlobalID: { // Is it a numbered definition?
712 if (D.Num >= CurModule.Values.size())
713 return 0;
714 Value *Result = CurModule.Values[D.Num];
715 if (Ty != Result->getType()) {
716 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
717 Result->getType()->getDescription() + "' does not match "
718 "expected type, '" + Ty->getDescription() + "'");
719 return 0;
720 }
721 return Result;
722 }
723
724 case ValID::LocalName: { // Is it a named definition?
725 if (!inFunctionScope())
726 return 0;
727 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
728 Value *N = SymTab.lookup(D.getName());
729 if (N == 0)
730 return 0;
731 if (N->getType() != Ty)
732 return 0;
733
734 D.destroy(); // Free old strdup'd memory...
735 return N;
736 }
737 case ValID::GlobalName: { // Is it a named definition?
738 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
739 Value *N = SymTab.lookup(D.getName());
740 if (N == 0)
741 return 0;
742 if (N->getType() != Ty)
743 return 0;
744
745 D.destroy(); // Free old strdup'd memory...
746 return N;
747 }
748
749 // Check to make sure that "Ty" is an integral type, and that our
750 // value will fit into the specified type...
751 case ValID::ConstSIntVal: // Is it a constant pool reference??
Chris Lattner59363a32008-02-19 04:36:25 +0000752 if (!isa<IntegerType>(Ty) ||
753 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 GenerateError("Signed integral constant '" +
755 itostr(D.ConstPool64) + "' is invalid for type '" +
756 Ty->getDescription() + "'");
757 return 0;
758 }
759 return ConstantInt::get(Ty, D.ConstPool64, true);
760
761 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000762 if (isa<IntegerType>(Ty) &&
763 ConstantInt::isValueValidForType(Ty, D.UConstPool64))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 return ConstantInt::get(Ty, D.UConstPool64);
Chris Lattner59363a32008-02-19 04:36:25 +0000765
766 if (!isa<IntegerType>(Ty) ||
767 !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
768 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
769 "' is invalid or out of range for type '" +
770 Ty->getDescription() + "'");
771 return 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772 }
Chris Lattner59363a32008-02-19 04:36:25 +0000773 // This is really a signed reference. Transmogrify.
774 return ConstantInt::get(Ty, D.ConstPool64, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775
776 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Chris Lattner59363a32008-02-19 04:36:25 +0000777 if (!Ty->isFloatingPoint() ||
778 !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 GenerateError("FP constant invalid for type");
780 return 0;
781 }
Dale Johannesen255b8fe2007-09-11 18:33:39 +0000782 // Lexer has no type info, so builds all float and double FP constants
783 // as double. Fix this here. Long double does not need this.
784 if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble &&
785 Ty==Type::FloatTy)
Dale Johannesen3afee192007-09-07 21:07:57 +0000786 D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
787 return ConstantFP::get(Ty, *D.ConstPoolFP);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788
789 case ValID::ConstNullVal: // Is it a null value?
790 if (!isa<PointerType>(Ty)) {
791 GenerateError("Cannot create a a non pointer null");
792 return 0;
793 }
794 return ConstantPointerNull::get(cast<PointerType>(Ty));
795
796 case ValID::ConstUndefVal: // Is it an undef value?
797 return UndefValue::get(Ty);
798
799 case ValID::ConstZeroVal: // Is it a zero value?
800 return Constant::getNullValue(Ty);
801
802 case ValID::ConstantVal: // Fully resolved constant?
803 if (D.ConstantValue->getType() != Ty) {
804 GenerateError("Constant expression type different from required type");
805 return 0;
806 }
807 return D.ConstantValue;
808
809 case ValID::InlineAsmVal: { // Inline asm expression
810 const PointerType *PTy = dyn_cast<PointerType>(Ty);
811 const FunctionType *FTy =
812 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
813 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
814 GenerateError("Invalid type for asm constraint string");
815 return 0;
816 }
817 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
818 D.IAD->HasSideEffects);
819 D.destroy(); // Free InlineAsmDescriptor.
820 return IA;
821 }
822 default:
823 assert(0 && "Unhandled case!");
824 return 0;
825 } // End of switch
826
827 assert(0 && "Unhandled case!");
828 return 0;
829}
830
831// getVal - This function is identical to getExistingVal, except that if a
832// value is not already defined, it "improvises" by creating a placeholder var
833// that looks and acts just like the requested variable. When the value is
834// defined later, all uses of the placeholder variable are replaced with the
835// real thing.
836//
837static Value *getVal(const Type *Ty, const ValID &ID) {
838 if (Ty == Type::LabelTy) {
839 GenerateError("Cannot use a basic block here");
840 return 0;
841 }
842
843 // See if the value has already been defined.
844 Value *V = getExistingVal(Ty, ID);
845 if (V) return V;
846 if (TriggerError) return 0;
847
848 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
849 GenerateError("Invalid use of a composite type");
850 return 0;
851 }
852
853 // If we reached here, we referenced either a symbol that we don't know about
854 // or an id number that hasn't been read yet. We may be referencing something
855 // forward, so just create an entry to be resolved later and get to it...
856 //
857 switch (ID.Type) {
858 case ValID::GlobalName:
859 case ValID::GlobalID: {
860 const PointerType *PTy = dyn_cast<PointerType>(Ty);
861 if (!PTy) {
862 GenerateError("Invalid type for reference to global" );
863 return 0;
864 }
865 const Type* ElTy = PTy->getElementType();
866 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
867 V = new Function(FTy, GlobalValue::ExternalLinkage);
868 else
Christopher Lamb0a243582007-12-11 09:02:08 +0000869 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "",
870 (Module*)0, false, PTy->getAddressSpace());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 break;
872 }
873 default:
874 V = new Argument(Ty);
875 }
876
877 // Remember where this forward reference came from. FIXME, shouldn't we try
878 // to recycle these things??
879 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
Duncan Sandsf5588dc2007-11-27 13:23:08 +0000880 LLLgetLineNo())));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881
882 if (inFunctionScope())
883 InsertValue(V, CurFun.LateResolveValues);
884 else
885 InsertValue(V, CurModule.LateResolveValues);
886 return V;
887}
888
889/// defineBBVal - This is a definition of a new basic block with the specified
890/// identifier which must be the same as CurFun.NextValNum, if its numeric.
Devang Patel890cc572008-03-03 18:58:47 +0000891static BasicBlock *defineBBVal(const ValID &ID, BasicBlock *unwindDest) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 assert(inFunctionScope() && "Can't get basic block at global scope!");
893
894 BasicBlock *BB = 0;
895
896 // First, see if this was forward referenced
897
898 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
899 if (BBI != CurFun.BBForwardRefs.end()) {
900 BB = BBI->second;
901 // The forward declaration could have been inserted anywhere in the
902 // function: insert it into the correct place now.
903 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
904 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
905
906 // We're about to erase the entry, save the key so we can clean it up.
907 ValID Tmp = BBI->first;
908
909 // Erase the forward ref from the map as its no longer "forward"
910 CurFun.BBForwardRefs.erase(ID);
911
912 // The key has been removed from the map but so we don't want to leave
913 // strdup'd memory around so destroy it too.
914 Tmp.destroy();
915
916 // If its a numbered definition, bump the number and set the BB value.
917 if (ID.Type == ValID::LocalID) {
918 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
919 InsertValue(BB);
920 }
Devang Patel890cc572008-03-03 18:58:47 +0000921 } else {
922 // We haven't seen this BB before and its first mention is a definition.
923 // Just create it and return it.
924 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
925 BB = new BasicBlock(Name, CurFun.CurrentFunction);
926 if (ID.Type == ValID::LocalID) {
927 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
928 InsertValue(BB);
929 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 }
931
Devang Patel890cc572008-03-03 18:58:47 +0000932 ID.destroy();
933 BB->setUnwindDest(unwindDest);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 return BB;
935}
936
937/// getBBVal - get an existing BB value or create a forward reference for it.
938///
939static BasicBlock *getBBVal(const ValID &ID) {
940 assert(inFunctionScope() && "Can't get basic block at global scope!");
941
942 BasicBlock *BB = 0;
943
944 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
945 if (BBI != CurFun.BBForwardRefs.end()) {
946 BB = BBI->second;
947 } if (ID.Type == ValID::LocalName) {
948 std::string Name = ID.getName();
949 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000950 if (N) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 if (N->getType()->getTypeID() == Type::LabelTyID)
952 BB = cast<BasicBlock>(N);
953 else
954 GenerateError("Reference to label '" + Name + "' is actually of type '"+
955 N->getType()->getDescription() + "'");
Anton Korobeynikov21c1eeb2008-02-20 12:10:37 +0000956 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 } else if (ID.Type == ValID::LocalID) {
958 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
959 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
960 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
961 else
962 GenerateError("Reference to label '%" + utostr(ID.Num) +
963 "' is actually of type '"+
964 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
965 }
966 } else {
967 GenerateError("Illegal label reference " + ID.getName());
968 return 0;
969 }
970
971 // If its already been defined, return it now.
972 if (BB) {
973 ID.destroy(); // Free strdup'd memory.
974 return BB;
975 }
976
977 // Otherwise, this block has not been seen before, create it.
978 std::string Name;
979 if (ID.Type == ValID::LocalName)
980 Name = ID.getName();
981 BB = new BasicBlock(Name, CurFun.CurrentFunction);
982
983 // Insert it in the forward refs map.
984 CurFun.BBForwardRefs[ID] = BB;
985
986 return BB;
987}
988
989
990//===----------------------------------------------------------------------===//
991// Code to handle forward references in instructions
992//===----------------------------------------------------------------------===//
993//
994// This code handles the late binding needed with statements that reference
995// values not defined yet... for example, a forward branch, or the PHI node for
996// a loop body.
997//
998// This keeps a table (CurFun.LateResolveValues) of all such forward references
999// and back patchs after we are done.
1000//
1001
1002// ResolveDefinitions - If we could not resolve some defs at parsing
1003// time (forward branches, phi functions for loops, etc...) resolve the
1004// defs now...
1005//
1006static void
1007ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
1008 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
1009 while (!LateResolvers.empty()) {
1010 Value *V = LateResolvers.back();
1011 LateResolvers.pop_back();
1012
1013 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
1014 CurModule.PlaceHolderInfo.find(V);
1015 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
1016
1017 ValID &DID = PHI->second.first;
1018
1019 Value *TheRealValue = getExistingVal(V->getType(), DID);
1020 if (TriggerError)
1021 return;
1022 if (TheRealValue) {
1023 V->replaceAllUsesWith(TheRealValue);
1024 delete V;
1025 CurModule.PlaceHolderInfo.erase(PHI);
1026 } else if (FutureLateResolvers) {
1027 // Functions have their unresolved items forwarded to the module late
1028 // resolver table
1029 InsertValue(V, *FutureLateResolvers);
1030 } else {
1031 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1032 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1033 "' of type '" + V->getType()->getDescription() + "'",
1034 PHI->second.second);
1035 return;
1036 } else {
1037 GenerateError("Reference to an invalid definition: #" +
1038 itostr(DID.Num) + " of type '" +
1039 V->getType()->getDescription() + "'",
1040 PHI->second.second);
1041 return;
1042 }
1043 }
1044 }
1045 LateResolvers.clear();
1046}
1047
1048// ResolveTypeTo - A brand new type was just declared. This means that (if
1049// name is not null) things referencing Name can be resolved. Otherwise, things
1050// refering to the number can be resolved. Do this now.
1051//
1052static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
1053 ValID D;
1054 if (Name)
1055 D = ValID::createLocalName(*Name);
1056 else
1057 D = ValID::createLocalID(CurModule.Types.size());
1058
1059 std::map<ValID, PATypeHolder>::iterator I =
1060 CurModule.LateResolveTypes.find(D);
1061 if (I != CurModule.LateResolveTypes.end()) {
1062 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
1063 CurModule.LateResolveTypes.erase(I);
1064 }
1065}
1066
1067// setValueName - Set the specified value to the name given. The name may be
1068// null potentially, in which case this is a noop. The string passed in is
1069// assumed to be a malloc'd string buffer, and is free'd by this function.
1070//
1071static void setValueName(Value *V, std::string *NameStr) {
1072 if (!NameStr) return;
1073 std::string Name(*NameStr); // Copy string
1074 delete NameStr; // Free old string
1075
1076 if (V->getType() == Type::VoidTy) {
1077 GenerateError("Can't assign name '" + Name+"' to value with void type");
1078 return;
1079 }
1080
1081 assert(inFunctionScope() && "Must be in function scope!");
1082 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1083 if (ST.lookup(Name)) {
1084 GenerateError("Redefinition of value '" + Name + "' of type '" +
1085 V->getType()->getDescription() + "'");
1086 return;
1087 }
1088
1089 // Set the name.
1090 V->setName(Name);
1091}
1092
1093/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1094/// this is a declaration, otherwise it is a definition.
1095static GlobalVariable *
1096ParseGlobalVariable(std::string *NameStr,
1097 GlobalValue::LinkageTypes Linkage,
1098 GlobalValue::VisibilityTypes Visibility,
1099 bool isConstantGlobal, const Type *Ty,
Christopher Lamb0a243582007-12-11 09:02:08 +00001100 Constant *Initializer, bool IsThreadLocal,
1101 unsigned AddressSpace = 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 if (isa<FunctionType>(Ty)) {
1103 GenerateError("Cannot declare global vars of function type");
1104 return 0;
1105 }
1106
Christopher Lamb0a243582007-12-11 09:02:08 +00001107 const PointerType *PTy = PointerType::get(Ty, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108
1109 std::string Name;
1110 if (NameStr) {
1111 Name = *NameStr; // Copy string
1112 delete NameStr; // Free old string
1113 }
1114
1115 // See if this global value was forward referenced. If so, recycle the
1116 // object.
1117 ValID ID;
1118 if (!Name.empty()) {
1119 ID = ValID::createGlobalName(Name);
1120 } else {
1121 ID = ValID::createGlobalID(CurModule.Values.size());
1122 }
1123
1124 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1125 // Move the global to the end of the list, from whereever it was
1126 // previously inserted.
1127 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1128 CurModule.CurrentModule->getGlobalList().remove(GV);
1129 CurModule.CurrentModule->getGlobalList().push_back(GV);
1130 GV->setInitializer(Initializer);
1131 GV->setLinkage(Linkage);
1132 GV->setVisibility(Visibility);
1133 GV->setConstant(isConstantGlobal);
1134 GV->setThreadLocal(IsThreadLocal);
1135 InsertValue(GV, CurModule.Values);
1136 return GV;
1137 }
1138
1139 // If this global has a name
1140 if (!Name.empty()) {
1141 // if the global we're parsing has an initializer (is a definition) and
1142 // has external linkage.
1143 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1144 // If there is already a global with external linkage with this name
1145 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1146 // If we allow this GVar to get created, it will be renamed in the
1147 // symbol table because it conflicts with an existing GVar. We can't
1148 // allow redefinition of GVars whose linking indicates that their name
1149 // must stay the same. Issue the error.
1150 GenerateError("Redefinition of global variable named '" + Name +
1151 "' of type '" + Ty->getDescription() + "'");
1152 return 0;
1153 }
1154 }
1155
1156 // Otherwise there is no existing GV to use, create one now.
1157 GlobalVariable *GV =
1158 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Christopher Lamb0a243582007-12-11 09:02:08 +00001159 CurModule.CurrentModule, IsThreadLocal, AddressSpace);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 GV->setVisibility(Visibility);
1161 InsertValue(GV, CurModule.Values);
1162 return GV;
1163}
1164
1165// setTypeName - Set the specified type to the name given. The name may be
1166// null potentially, in which case this is a noop. The string passed in is
1167// assumed to be a malloc'd string buffer, and is freed by this function.
1168//
1169// This function returns true if the type has already been defined, but is
1170// allowed to be redefined in the specified context. If the name is a new name
1171// for the type plane, it is inserted and false is returned.
1172static bool setTypeName(const Type *T, std::string *NameStr) {
1173 assert(!inFunctionScope() && "Can't give types function-local names!");
1174 if (NameStr == 0) return false;
1175
1176 std::string Name(*NameStr); // Copy string
1177 delete NameStr; // Free old string
1178
1179 // We don't allow assigning names to void type
1180 if (T == Type::VoidTy) {
1181 GenerateError("Can't assign name '" + Name + "' to the void type");
1182 return false;
1183 }
1184
1185 // Set the type name, checking for conflicts as we do so.
1186 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1187
1188 if (AlreadyExists) { // Inserting a name that is already defined???
1189 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1190 assert(Existing && "Conflict but no matching type?!");
1191
1192 // There is only one case where this is allowed: when we are refining an
1193 // opaque type. In this case, Existing will be an opaque type.
1194 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1195 // We ARE replacing an opaque type!
1196 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1197 return true;
1198 }
1199
1200 // Otherwise, this is an attempt to redefine a type. That's okay if
1201 // the redefinition is identical to the original. This will be so if
1202 // Existing and T point to the same Type object. In this one case we
1203 // allow the equivalent redefinition.
1204 if (Existing == T) return true; // Yes, it's equal.
1205
1206 // Any other kind of (non-equivalent) redefinition is an error.
1207 GenerateError("Redefinition of type named '" + Name + "' of type '" +
1208 T->getDescription() + "'");
1209 }
1210
1211 return false;
1212}
1213
1214//===----------------------------------------------------------------------===//
1215// Code for handling upreferences in type names...
1216//
1217
1218// TypeContains - Returns true if Ty directly contains E in it.
1219//
1220static bool TypeContains(const Type *Ty, const Type *E) {
1221 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1222 E) != Ty->subtype_end();
1223}
1224
1225namespace {
1226 struct UpRefRecord {
1227 // NestingLevel - The number of nesting levels that need to be popped before
1228 // this type is resolved.
1229 unsigned NestingLevel;
1230
1231 // LastContainedTy - This is the type at the current binding level for the
1232 // type. Every time we reduce the nesting level, this gets updated.
1233 const Type *LastContainedTy;
1234
1235 // UpRefTy - This is the actual opaque type that the upreference is
1236 // represented with.
1237 OpaqueType *UpRefTy;
1238
1239 UpRefRecord(unsigned NL, OpaqueType *URTy)
1240 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1241 };
1242}
1243
1244// UpRefs - A list of the outstanding upreferences that need to be resolved.
1245static std::vector<UpRefRecord> UpRefs;
1246
1247/// HandleUpRefs - Every time we finish a new layer of types, this function is
1248/// called. It loops through the UpRefs vector, which is a list of the
1249/// currently active types. For each type, if the up reference is contained in
1250/// the newly completed type, we decrement the level count. When the level
1251/// count reaches zero, the upreferenced type is the type that is passed in:
1252/// thus we can complete the cycle.
1253///
1254static PATypeHolder HandleUpRefs(const Type *ty) {
1255 // If Ty isn't abstract, or if there are no up-references in it, then there is
1256 // nothing to resolve here.
1257 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1258
1259 PATypeHolder Ty(ty);
1260 UR_OUT("Type '" << Ty->getDescription() <<
1261 "' newly formed. Resolving upreferences.\n" <<
1262 UpRefs.size() << " upreferences active!\n");
1263
1264 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1265 // to zero), we resolve them all together before we resolve them to Ty. At
1266 // the end of the loop, if there is anything to resolve to Ty, it will be in
1267 // this variable.
1268 OpaqueType *TypeToResolve = 0;
1269
1270 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1271 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1272 << UpRefs[i].second->getDescription() << ") = "
1273 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1274 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1275 // Decrement level of upreference
1276 unsigned Level = --UpRefs[i].NestingLevel;
1277 UpRefs[i].LastContainedTy = Ty;
1278 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1279 if (Level == 0) { // Upreference should be resolved!
1280 if (!TypeToResolve) {
1281 TypeToResolve = UpRefs[i].UpRefTy;
1282 } else {
1283 UR_OUT(" * Resolving upreference for "
1284 << UpRefs[i].second->getDescription() << "\n";
1285 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1286 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1287 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1288 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1289 }
1290 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1291 --i; // Do not skip the next element...
1292 }
1293 }
1294 }
1295
1296 if (TypeToResolve) {
1297 UR_OUT(" * Resolving upreference for "
1298 << UpRefs[i].second->getDescription() << "\n";
1299 std::string OldName = TypeToResolve->getDescription());
1300 TypeToResolve->refineAbstractTypeTo(Ty);
1301 }
1302
1303 return Ty;
1304}
1305
1306//===----------------------------------------------------------------------===//
1307// RunVMAsmParser - Define an interface to this parser
1308//===----------------------------------------------------------------------===//
1309//
1310static Module* RunParser(Module * M);
1311
Duncan Sandsf5588dc2007-11-27 13:23:08 +00001312Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
1313 InitLLLexer(MB);
1314 Module *M = RunParser(new Module(LLLgetFilename()));
1315 FreeLexer();
1316 return M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317}
1318
1319
Chris Lattner59363a32008-02-19 04:36:25 +00001320
1321/* Enabling traces. */
1322#ifndef YYDEBUG
1323# define YYDEBUG 0
1324#endif
1325
1326/* Enabling verbose error messages. */
1327#ifdef YYERROR_VERBOSE
1328# undef YYERROR_VERBOSE
1329# define YYERROR_VERBOSE 1
1330#else
1331# define YYERROR_VERBOSE 0
1332#endif
1333
1334/* Enabling the token table. */
1335#ifndef YYTOKEN_TABLE
1336# define YYTOKEN_TABLE 0
1337#endif
1338
1339#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1340typedef union YYSTYPE
Nick Lewycky92b80c72008-03-10 05:01:34 +00001341#line 951 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00001342{
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 llvm::Module *ModuleVal;
1344 llvm::Function *FunctionVal;
1345 llvm::BasicBlock *BasicBlockVal;
1346 llvm::TerminatorInst *TermInstVal;
1347 llvm::Instruction *InstVal;
1348 llvm::Constant *ConstVal;
1349
1350 const llvm::Type *PrimType;
1351 std::list<llvm::PATypeHolder> *TypeList;
1352 llvm::PATypeHolder *TypeVal;
1353 llvm::Value *ValueVal;
1354 std::vector<llvm::Value*> *ValueList;
1355 llvm::ArgListType *ArgList;
1356 llvm::TypeWithAttrs TypeWithAttrs;
1357 llvm::TypeWithAttrsList *TypeWithAttrsList;
Dale Johannesencfb19e62007-11-05 21:20:28 +00001358 llvm::ParamList *ParamList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359
1360 // Represent the RHS of PHI node
1361 std::list<std::pair<llvm::Value*,
1362 llvm::BasicBlock*> > *PHIList;
1363 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1364 std::vector<llvm::Constant*> *ConstVector;
1365
1366 llvm::GlobalValue::LinkageTypes Linkage;
1367 llvm::GlobalValue::VisibilityTypes Visibility;
Dale Johannesend915ee52008-02-19 21:40:51 +00001368 llvm::ParameterAttributes ParamAttrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 llvm::APInt *APIntVal;
1370 int64_t SInt64Val;
1371 uint64_t UInt64Val;
1372 int SIntVal;
1373 unsigned UIntVal;
Dale Johannesen3afee192007-09-07 21:07:57 +00001374 llvm::APFloat *FPVal;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375 bool BoolVal;
1376
1377 std::string *StrVal; // This memory must be deleted
1378 llvm::ValID ValIDVal;
1379
1380 llvm::Instruction::BinaryOps BinaryOpVal;
1381 llvm::Instruction::TermOps TermOpVal;
1382 llvm::Instruction::MemoryOps MemOpVal;
1383 llvm::Instruction::CastOps CastOpVal;
1384 llvm::Instruction::OtherOps OtherOpVal;
1385 llvm::ICmpInst::Predicate IPredicate;
1386 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner59363a32008-02-19 04:36:25 +00001387}
Nick Lewycky92b80c72008-03-10 05:01:34 +00001388/* Line 187 of yacc.c. */
Dale Johannesen98738822008-02-22 22:17:59 +00001389#line 1390 "llvmAsmParser.tab.c"
Chris Lattner59363a32008-02-19 04:36:25 +00001390 YYSTYPE;
1391# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1392# define YYSTYPE_IS_DECLARED 1
1393# define YYSTYPE_IS_TRIVIAL 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394#endif
1395
1396
1397
Chris Lattner59363a32008-02-19 04:36:25 +00001398/* Copy the second part of user declarations. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400
Chris Lattner59363a32008-02-19 04:36:25 +00001401/* Line 216 of yacc.c. */
Dale Johannesen98738822008-02-22 22:17:59 +00001402#line 1403 "llvmAsmParser.tab.c"
Reid Spenceraa8ae282007-07-31 03:50:36 +00001403
Chris Lattner59363a32008-02-19 04:36:25 +00001404#ifdef short
1405# undef short
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406#endif
1407
Chris Lattner59363a32008-02-19 04:36:25 +00001408#ifdef YYTYPE_UINT8
1409typedef YYTYPE_UINT8 yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410#else
Chris Lattner59363a32008-02-19 04:36:25 +00001411typedef unsigned char yytype_uint8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412#endif
1413
Chris Lattner59363a32008-02-19 04:36:25 +00001414#ifdef YYTYPE_INT8
1415typedef YYTYPE_INT8 yytype_int8;
1416#elif (defined __STDC__ || defined __C99__FUNC__ \
1417 || defined __cplusplus || defined _MSC_VER)
1418typedef signed char yytype_int8;
1419#else
1420typedef short int yytype_int8;
1421#endif
1422
1423#ifdef YYTYPE_UINT16
1424typedef YYTYPE_UINT16 yytype_uint16;
1425#else
1426typedef unsigned short int yytype_uint16;
1427#endif
1428
1429#ifdef YYTYPE_INT16
1430typedef YYTYPE_INT16 yytype_int16;
1431#else
1432typedef short int yytype_int16;
1433#endif
1434
1435#ifndef YYSIZE_T
1436# ifdef __SIZE_TYPE__
1437# define YYSIZE_T __SIZE_TYPE__
1438# elif defined size_t
1439# define YYSIZE_T size_t
1440# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1441 || defined __cplusplus || defined _MSC_VER)
1442# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1443# define YYSIZE_T size_t
1444# else
1445# define YYSIZE_T unsigned int
1446# endif
1447#endif
1448
1449#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1450
1451#ifndef YY_
Nick Lewycky92b80c72008-03-10 05:01:34 +00001452# if YYENABLE_NLS
Chris Lattner59363a32008-02-19 04:36:25 +00001453# if ENABLE_NLS
1454# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1455# define YY_(msgid) dgettext ("bison-runtime", msgid)
1456# endif
1457# endif
1458# ifndef YY_
1459# define YY_(msgid) msgid
1460# endif
1461#endif
1462
1463/* Suppress unused-variable warnings by "using" E. */
1464#if ! defined lint || defined __GNUC__
1465# define YYUSE(e) ((void) (e))
1466#else
1467# define YYUSE(e) /* empty */
1468#endif
1469
1470/* Identity function, used to suppress warnings about constant conditions. */
1471#ifndef lint
1472# define YYID(n) (n)
1473#else
1474#if (defined __STDC__ || defined __C99__FUNC__ \
1475 || defined __cplusplus || defined _MSC_VER)
1476static int
1477YYID (int i)
1478#else
1479static int
1480YYID (i)
1481 int i;
1482#endif
1483{
1484 return i;
1485}
1486#endif
1487
1488#if ! defined yyoverflow || YYERROR_VERBOSE
1489
1490/* The parser invokes alloca or malloc; define the necessary symbols. */
1491
1492# ifdef YYSTACK_USE_ALLOCA
1493# if YYSTACK_USE_ALLOCA
1494# ifdef __GNUC__
1495# define YYSTACK_ALLOC __builtin_alloca
1496# elif defined __BUILTIN_VA_ARG_INCR
1497# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1498# elif defined _AIX
1499# define YYSTACK_ALLOC __alloca
1500# elif defined _MSC_VER
1501# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1502# define alloca _alloca
1503# else
1504# define YYSTACK_ALLOC alloca
1505# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1506 || defined __cplusplus || defined _MSC_VER)
1507# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1508# ifndef _STDLIB_H
1509# define _STDLIB_H 1
1510# endif
1511# endif
1512# endif
1513# endif
1514# endif
1515
1516# ifdef YYSTACK_ALLOC
1517 /* Pacify GCC's `empty if-body' warning. */
1518# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1519# ifndef YYSTACK_ALLOC_MAXIMUM
1520 /* The OS might guarantee only one guard page at the bottom of the stack,
1521 and a page size can be as small as 4096 bytes. So we cannot safely
1522 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1523 to allow for a few compiler-allocated temporary stack slots. */
1524# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1525# endif
1526# else
1527# define YYSTACK_ALLOC YYMALLOC
1528# define YYSTACK_FREE YYFREE
1529# ifndef YYSTACK_ALLOC_MAXIMUM
1530# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1531# endif
1532# if (defined __cplusplus && ! defined _STDLIB_H \
1533 && ! ((defined YYMALLOC || defined malloc) \
1534 && (defined YYFREE || defined free)))
1535# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1536# ifndef _STDLIB_H
1537# define _STDLIB_H 1
1538# endif
1539# endif
1540# ifndef YYMALLOC
1541# define YYMALLOC malloc
1542# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1543 || defined __cplusplus || defined _MSC_VER)
1544void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1545# endif
1546# endif
1547# ifndef YYFREE
1548# define YYFREE free
1549# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1550 || defined __cplusplus || defined _MSC_VER)
1551void free (void *); /* INFRINGES ON USER NAME SPACE */
1552# endif
1553# endif
1554# endif
1555#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1556
1557
1558#if (! defined yyoverflow \
1559 && (! defined __cplusplus \
1560 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1561
1562/* A type that is properly aligned for any stack member. */
1563union yyalloc
1564{
1565 yytype_int16 yyss;
1566 YYSTYPE yyvs;
1567 };
1568
1569/* The size of the maximum gap between one aligned stack and the next. */
1570# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1571
1572/* The size of an array large to enough to hold all stacks, each with
1573 N elements. */
1574# define YYSTACK_BYTES(N) \
1575 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
1576 + YYSTACK_GAP_MAXIMUM)
1577
1578/* Copy COUNT objects from FROM to TO. The source and destination do
1579 not overlap. */
1580# ifndef YYCOPY
1581# if defined __GNUC__ && 1 < __GNUC__
1582# define YYCOPY(To, From, Count) \
1583 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1584# else
1585# define YYCOPY(To, From, Count) \
1586 do \
1587 { \
1588 YYSIZE_T yyi; \
1589 for (yyi = 0; yyi < (Count); yyi++) \
1590 (To)[yyi] = (From)[yyi]; \
1591 } \
1592 while (YYID (0))
1593# endif
1594# endif
1595
1596/* Relocate STACK from its old location to the new one. The
1597 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1598 elements in the stack, and YYPTR gives the new location of the
1599 stack. Advance YYPTR to a properly aligned location for the next
1600 stack. */
1601# define YYSTACK_RELOCATE(Stack) \
1602 do \
1603 { \
1604 YYSIZE_T yynewbytes; \
1605 YYCOPY (&yyptr->Stack, Stack, yysize); \
1606 Stack = &yyptr->Stack; \
1607 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1608 yyptr += yynewbytes / sizeof (*yyptr); \
1609 } \
1610 while (YYID (0))
1611
1612#endif
1613
1614/* YYFINAL -- State number of the termination state. */
1615#define YYFINAL 43
1616/* YYLAST -- Last index in YYTABLE. */
Nick Lewycky92b80c72008-03-10 05:01:34 +00001617#define YYLAST 2015
Chris Lattner59363a32008-02-19 04:36:25 +00001618
1619/* YYNTOKENS -- Number of terminals. */
Devang Patel890cc572008-03-03 18:58:47 +00001620#define YYNTOKENS 166
Chris Lattner59363a32008-02-19 04:36:25 +00001621/* YYNNTS -- Number of nonterminals. */
Devang Patelbf507402008-02-20 22:40:23 +00001622#define YYNNTS 85
Chris Lattner59363a32008-02-19 04:36:25 +00001623/* YYNRULES -- Number of rules. */
Devang Patel890cc572008-03-03 18:58:47 +00001624#define YYNRULES 324
Chris Lattner59363a32008-02-19 04:36:25 +00001625/* YYNRULES -- Number of states. */
Nick Lewycky92b80c72008-03-10 05:01:34 +00001626#define YYNSTATES 635
Chris Lattner59363a32008-02-19 04:36:25 +00001627
1628/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1629#define YYUNDEFTOK 2
Devang Patel890cc572008-03-03 18:58:47 +00001630#define YYMAXUTOK 406
Chris Lattner59363a32008-02-19 04:36:25 +00001631
1632#define YYTRANSLATE(YYX) \
1633 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1634
1635/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1636static const yytype_uint8 yytranslate[] =
1637{
1638 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel890cc572008-03-03 18:58:47 +00001642 152, 153, 156, 2, 155, 2, 2, 2, 2, 2,
Chris Lattner59363a32008-02-19 04:36:25 +00001643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel890cc572008-03-03 18:58:47 +00001644 161, 154, 162, 2, 2, 2, 2, 2, 2, 2,
Chris Lattner59363a32008-02-19 04:36:25 +00001645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel890cc572008-03-03 18:58:47 +00001647 2, 158, 157, 160, 2, 2, 2, 2, 2, 165,
Chris Lattner59363a32008-02-19 04:36:25 +00001648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Devang Patel890cc572008-03-03 18:58:47 +00001650 159, 2, 2, 163, 2, 164, 2, 2, 2, 2,
Chris Lattner59363a32008-02-19 04:36:25 +00001651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1658 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1659 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1660 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1661 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1662 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1663 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1664 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1665 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1666 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1667 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1668 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1669 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1670 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1671 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1672 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1673 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1674 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1675 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1676 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1677 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Devang Patel890cc572008-03-03 18:58:47 +00001678 145, 146, 147, 148, 149, 150, 151
Chris Lattner59363a32008-02-19 04:36:25 +00001679};
1680
1681#if YYDEBUG
1682/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1683 YYRHS. */
1684static const yytype_uint16 yyprhs[] =
1685{
1686 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1687 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1688 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1689 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1690 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1691 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1692 119, 121, 123, 125, 127, 129, 130, 135, 136, 139,
1693 140, 142, 144, 146, 147, 150, 152, 154, 156, 158,
1694 160, 162, 164, 166, 167, 169, 171, 173, 174, 176,
1695 178, 179, 181, 183, 185, 187, 188, 190, 192, 193,
1696 195, 197, 199, 201, 203, 206, 208, 210, 212, 214,
Dale Johannesena79ecf32008-02-20 21:15:43 +00001697 216, 218, 220, 222, 224, 227, 228, 231, 233, 235,
1698 237, 239, 241, 243, 244, 247, 248, 251, 252, 255,
1699 256, 260, 263, 264, 266, 267, 271, 273, 276, 278,
1700 280, 282, 284, 286, 288, 290, 292, 294, 298, 300,
1701 303, 309, 315, 321, 327, 331, 334, 340, 345, 348,
1702 350, 352, 354, 358, 360, 364, 366, 367, 369, 373,
1703 378, 382, 386, 391, 396, 400, 407, 413, 416, 419,
1704 422, 425, 428, 431, 434, 437, 440, 443, 446, 449,
1705 456, 462, 471, 478, 485, 493, 501, 508, 517, 526,
1706 530, 532, 534, 536, 538, 539, 542, 549, 551, 552,
1707 554, 557, 558, 562, 563, 567, 571, 575, 579, 580,
1708 589, 590, 600, 601, 611, 617, 620, 624, 626, 630,
1709 634, 638, 642, 644, 645, 651, 655, 657, 661, 663,
1710 664, 675, 677, 679, 684, 686, 688, 691, 695, 696,
1711 698, 700, 702, 704, 706, 708, 710, 712, 714, 718,
Devang Patelbf507402008-02-20 22:40:23 +00001712 720, 726, 728, 730, 732, 734, 736, 738, 741, 743,
Nick Lewycky92b80c72008-03-10 05:01:34 +00001713 747, 750, 753, 757, 760, 761, 765, 767, 772, 775,
1714 778, 782, 792, 802, 811, 826, 828, 830, 837, 843,
1715 846, 853, 861, 866, 871, 878, 885, 886, 887, 891,
1716 894, 896, 902, 908, 915, 922, 927, 934, 939, 944,
1717 951, 958, 961, 970, 972, 974, 975, 979, 986, 990,
1718 997, 1000, 1006, 1014, 1020
Chris Lattner59363a32008-02-19 04:36:25 +00001719};
1720
1721/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1722static const yytype_int16 yyrhs[] =
1723{
Devang Patel890cc572008-03-03 18:58:47 +00001724 212, 0, -1, 75, -1, 76, -1, 77, -1, 78,
1725 -1, 79, -1, 80, -1, 81, -1, 82, -1, 83,
1726 -1, 87, -1, 88, -1, 89, -1, 84, -1, 85,
1727 -1, 86, -1, 118, -1, 119, -1, 120, -1, 121,
1728 -1, 122, -1, 123, -1, 124, -1, 125, -1, 126,
1729 -1, 127, -1, 128, -1, 129, -1, 92, -1, 93,
1730 -1, 94, -1, 95, -1, 96, -1, 97, -1, 98,
1731 -1, 99, -1, 100, -1, 101, -1, 102, -1, 103,
1732 -1, 104, -1, 105, -1, 106, -1, 107, -1, 108,
1733 -1, 109, -1, 110, -1, 111, -1, 98, -1, 99,
1734 -1, 100, -1, 101, -1, 26, -1, 27, -1, 11,
Chris Lattner59363a32008-02-19 04:36:25 +00001735 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
Devang Patel890cc572008-03-03 18:58:47 +00001736 -1, 19, -1, 22, -1, 24, -1, 174, -1, -1,
1737 54, 152, 4, 153, -1, -1, 174, 154, -1, -1,
1738 20, -1, 23, -1, 180, -1, -1, 178, 154, -1,
Chris Lattner59363a32008-02-19 04:36:25 +00001739 42, -1, 44, -1, 43, -1, 45, -1, 47, -1,
Devang Patel890cc572008-03-03 18:58:47 +00001740 46, -1, 48, -1, 50, -1, -1, 149, -1, 150,
1741 -1, 151, -1, -1, 46, -1, 48, -1, -1, 42,
Chris Lattner59363a32008-02-19 04:36:25 +00001742 -1, 43, -1, 44, -1, 47, -1, -1, 44, -1,
1743 42, -1, -1, 62, -1, 63, -1, 64, -1, 65,
Devang Patel890cc572008-03-03 18:58:47 +00001744 -1, 66, -1, 61, 4, -1, 138, -1, 119, -1,
1745 137, -1, 120, -1, 140, -1, 141, -1, 143, -1,
1746 144, -1, 145, -1, 53, 4, -1, -1, 189, 188,
1747 -1, 139, -1, 142, -1, 138, -1, 137, -1, 146,
1748 -1, 147, -1, -1, 191, 190, -1, -1, 148, 22,
1749 -1, -1, 53, 4, -1, -1, 155, 53, 4, -1,
1750 34, 22, -1, -1, 195, -1, -1, 155, 198, 197,
1751 -1, 195, -1, 53, 4, -1, 11, -1, 12, -1,
Dale Johannesena79ecf32008-02-20 21:15:43 +00001752 13, -1, 16, -1, 15, -1, 14, -1, 17, -1,
Devang Patel890cc572008-03-03 18:58:47 +00001753 49, -1, 199, -1, 200, 176, 156, -1, 234, -1,
1754 157, 4, -1, 200, 152, 204, 153, 191, -1, 10,
1755 152, 204, 153, 191, -1, 158, 4, 159, 200, 160,
1756 -1, 161, 4, 159, 200, 162, -1, 163, 205, 164,
1757 -1, 163, 164, -1, 161, 163, 205, 164, 162, -1,
1758 161, 163, 164, 162, -1, 200, 189, -1, 200, -1,
1759 10, -1, 201, -1, 203, 155, 201, -1, 203, -1,
1760 203, 155, 39, -1, 39, -1, -1, 200, -1, 205,
1761 155, 200, -1, 200, 158, 208, 160, -1, 200, 158,
1762 160, -1, 200, 165, 22, -1, 200, 161, 208, 162,
1763 -1, 200, 163, 208, 164, -1, 200, 163, 164, -1,
1764 200, 161, 163, 208, 164, 162, -1, 200, 161, 163,
1765 164, 162, -1, 200, 40, -1, 200, 41, -1, 200,
1766 234, -1, 200, 207, -1, 200, 25, -1, 172, 3,
1767 -1, 172, 5, -1, 172, 4, -1, 172, 6, -1,
1768 11, 26, -1, 11, 27, -1, 173, 9, -1, 169,
1769 152, 206, 38, 200, 153, -1, 117, 152, 206, 246,
1770 153, -1, 131, 152, 206, 155, 206, 155, 206, 153,
1771 -1, 167, 152, 206, 155, 206, 153, -1, 168, 152,
1772 206, 155, 206, 153, -1, 90, 170, 152, 206, 155,
1773 206, 153, -1, 91, 171, 152, 206, 155, 206, 153,
1774 -1, 133, 152, 206, 155, 206, 153, -1, 134, 152,
1775 206, 155, 206, 155, 206, 153, -1, 135, 152, 206,
1776 155, 206, 155, 206, 153, -1, 208, 155, 206, -1,
1777 206, -1, 32, -1, 33, -1, 37, -1, -1, 202,
1778 234, -1, 123, 152, 211, 38, 200, 153, -1, 213,
1779 -1, -1, 214, -1, 213, 214, -1, -1, 31, 215,
1780 230, -1, -1, 30, 216, 231, -1, 59, 58, 220,
1781 -1, 177, 18, 200, -1, 177, 18, 10, -1, -1,
1782 179, 183, 210, 209, 206, 176, 217, 197, -1, -1,
1783 179, 181, 183, 210, 209, 206, 176, 218, 197, -1,
1784 -1, 179, 182, 183, 210, 209, 200, 176, 219, 197,
1785 -1, 179, 183, 35, 186, 211, -1, 51, 221, -1,
1786 55, 154, 222, -1, 22, -1, 52, 154, 22, -1,
1787 67, 154, 22, -1, 158, 223, 160, -1, 223, 155,
1788 22, -1, 22, -1, -1, 224, 155, 200, 189, 175,
1789 -1, 200, 189, 175, -1, 224, -1, 224, 155, 39,
1790 -1, 39, -1, -1, 187, 202, 178, 152, 225, 153,
1791 191, 196, 193, 192, -1, 28, -1, 163, -1, 185,
1792 183, 226, 227, -1, 29, -1, 164, -1, 238, 229,
1793 -1, 184, 183, 226, -1, -1, 60, -1, 3, -1,
Dale Johannesena79ecf32008-02-20 21:15:43 +00001794 4, -1, 9, -1, 26, -1, 27, -1, 40, -1,
Devang Patel890cc572008-03-03 18:58:47 +00001795 41, -1, 25, -1, 161, 208, 162, -1, 207, -1,
1796 58, 232, 22, 155, 22, -1, 7, -1, 8, -1,
1797 174, -1, 178, -1, 234, -1, 233, -1, 200, 235,
1798 -1, 236, -1, 237, 155, 236, -1, 238, 239, -1,
1799 228, 239, -1, 240, 177, 241, -1, 240, 243, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00001800 -1, 68, 38, 235, -1, 21, -1, 21, 68, 38,
1801 235, -1, 69, 237, -1, 69, 10, -1, 70, 17,
1802 235, -1, 70, 11, 235, 155, 17, 235, 155, 17,
1803 235, -1, 71, 172, 235, 155, 17, 235, 158, 242,
1804 160, -1, 71, 172, 235, 155, 17, 235, 158, 160,
1805 -1, 72, 187, 202, 235, 152, 245, 153, 191, 38,
1806 17, 235, 73, 17, 235, -1, 73, -1, 74, -1,
1807 242, 172, 233, 155, 17, 235, -1, 172, 233, 155,
1808 17, 235, -1, 177, 248, -1, 200, 158, 235, 155,
1809 235, 160, -1, 244, 155, 158, 235, 155, 235, 160,
1810 -1, 200, 189, 235, 189, -1, 17, 189, 235, 189,
1811 -1, 245, 155, 200, 189, 235, 189, -1, 245, 155,
1812 17, 189, 235, 189, -1, -1, -1, 246, 155, 236,
1813 -1, 57, 56, -1, 56, -1, 167, 200, 235, 155,
1814 235, -1, 168, 200, 235, 155, 235, -1, 90, 170,
1815 200, 235, 155, 235, -1, 91, 171, 200, 235, 155,
1816 235, -1, 169, 236, 38, 200, -1, 131, 236, 155,
1817 236, 155, 236, -1, 132, 236, 155, 200, -1, 133,
1818 236, 155, 236, -1, 134, 236, 155, 236, 155, 236,
1819 -1, 135, 236, 155, 236, 155, 236, -1, 130, 244,
1820 -1, 247, 187, 202, 235, 152, 245, 153, 191, -1,
1821 250, -1, 36, -1, -1, 112, 200, 194, -1, 112,
1822 200, 155, 11, 235, 194, -1, 113, 200, 194, -1,
1823 113, 200, 155, 11, 235, 194, -1, 114, 236, -1,
1824 249, 115, 200, 235, 194, -1, 249, 116, 236, 155,
1825 200, 235, 194, -1, 136, 200, 234, 155, 4, -1,
1826 117, 200, 235, 246, -1
Chris Lattner59363a32008-02-19 04:36:25 +00001827};
1828
1829/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1830static const yytype_uint16 yyrline[] =
1831{
Devang Patel890cc572008-03-03 18:58:47 +00001832 0, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
1833 1113, 1114, 1114, 1114, 1114, 1114, 1114, 1115, 1115, 1115,
1834 1115, 1115, 1115, 1116, 1116, 1116, 1116, 1116, 1116, 1119,
1835 1119, 1120, 1120, 1121, 1121, 1122, 1122, 1123, 1123, 1127,
1836 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131, 1131, 1132,
1837 1132, 1133, 1133, 1134, 1135, 1140, 1141, 1141, 1141, 1141,
1838 1141, 1143, 1143, 1143, 1144, 1144, 1146, 1147, 1151, 1155,
1839 1160, 1160, 1162, 1163, 1168, 1174, 1175, 1176, 1177, 1178,
1840 1182, 1183, 1184, 1188, 1189, 1190, 1191, 1195, 1196, 1197,
1841 1201, 1202, 1203, 1204, 1205, 1209, 1210, 1211, 1214, 1215,
1842 1216, 1217, 1218, 1219, 1220, 1227, 1228, 1229, 1230, 1231,
1843 1232, 1233, 1234, 1235, 1236, 1240, 1241, 1246, 1247, 1248,
1844 1249, 1250, 1251, 1254, 1255, 1260, 1261, 1268, 1269, 1275,
1845 1276, 1285, 1293, 1294, 1299, 1300, 1301, 1306, 1319, 1319,
1846 1319, 1319, 1319, 1319, 1319, 1322, 1326, 1330, 1337, 1342,
1847 1350, 1380, 1405, 1410, 1420, 1430, 1434, 1444, 1451, 1460,
1848 1467, 1472, 1477, 1484, 1485, 1492, 1499, 1507, 1513, 1525,
1849 1553, 1569, 1596, 1624, 1650, 1670, 1696, 1716, 1728, 1735,
1850 1801, 1811, 1821, 1827, 1837, 1843, 1853, 1858, 1863, 1876,
1851 1888, 1910, 1918, 1924, 1935, 1940, 1945, 1951, 1957, 1966,
1852 1970, 1978, 1978, 1981, 1981, 1984, 1996, 2017, 2022, 2030,
1853 2031, 2035, 2035, 2039, 2039, 2042, 2045, 2069, 2081, 2080,
1854 2092, 2091, 2101, 2100, 2111, 2151, 2154, 2160, 2170, 2174,
1855 2179, 2181, 2186, 2191, 2200, 2210, 2221, 2225, 2234, 2243,
1856 2248, 2382, 2382, 2384, 2393, 2393, 2395, 2400, 2412, 2416,
1857 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2449, 2453, 2478,
1858 2482, 2492, 2496, 2500, 2505, 2512, 2512, 2518, 2527, 2532,
1859 2537, 2541, 2550, 2559, 2568, 2572, 2576, 2581, 2588, 2595,
1860 2599, 2604, 2614, 2633, 2642, 2733, 2737, 2744, 2755, 2768,
1861 2778, 2789, 2799, 2810, 2818, 2828, 2835, 2838, 2839, 2846,
1862 2850, 2855, 2871, 2888, 2902, 2916, 2928, 2936, 2943, 2949,
1863 2955, 2961, 2976, 3074, 3079, 3083, 3090, 3097, 3105, 3112,
1864 3120, 3128, 3142, 3159, 3167
Chris Lattner59363a32008-02-19 04:36:25 +00001865};
1866#endif
1867
1868#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1869/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1870 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1871static const char *const yytname[] =
1872{
1873 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1874 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1875 "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1876 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1877 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1878 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1879 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1880 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1881 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1882 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL",
1883 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1884 "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK",
Nick Lewycky92b80c72008-03-10 05:01:34 +00001885 "DATALAYOUT", "UNWINDS", "RET", "BR", "SWITCH", "INVOKE", "UNWIND",
Devang Patel890cc572008-03-03 18:58:47 +00001886 "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM",
1887 "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP",
1888 "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE",
1889 "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ",
1890 "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1891 "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP",
1892 "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK",
1893 "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1894 "GETRESULT", "SIGNEXT", "ZEROEXT", "NORETURN", "INREG", "SRET",
1895 "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "READNONE", "READONLY", "GC",
1896 "DEFAULT", "HIDDEN", "PROTECTED", "'('", "')'", "'='", "','", "'*'",
1897 "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'",
1898 "$accept", "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates",
1899 "FPredicates", "IntType", "FPType", "LocalName", "OptLocalName",
1900 "OptAddrSpace", "OptLocalAssign", "GlobalName", "OptGlobalAssign",
1901 "GlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1902 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1903 "AliasLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1904 "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", "OptCAlign",
1905 "SectionString", "OptSection", "GlobalVarAttributes",
Chris Lattner59363a32008-02-19 04:36:25 +00001906 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1907 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1908 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1909 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1910 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1911 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1912 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Devang Patelbf507402008-02-20 22:40:23 +00001913 "SymbolicValueRef", "ValueRef", "ResolvedVal", "ReturnedVal",
1914 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1915 "JumpTable", "Inst", "PHIList", "ParamList", "IndexList", "OptTailCall",
1916 "InstVal", "OptVolatile", "MemoryInst", 0
Chris Lattner59363a32008-02-19 04:36:25 +00001917};
1918#endif
1919
1920# ifdef YYPRINT
1921/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1922 token YYLEX-NUM. */
1923static const yytype_uint16 yytoknum[] =
1924{
1925 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1926 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1927 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1928 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1929 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1930 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1931 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1932 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1933 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1934 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1935 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1936 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1937 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1938 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1939 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
Devang Patel890cc572008-03-03 18:58:47 +00001940 405, 406, 40, 41, 61, 44, 42, 92, 91, 120,
1941 93, 60, 62, 123, 125, 99
Chris Lattner59363a32008-02-19 04:36:25 +00001942};
1943# endif
1944
1945/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1946static const yytype_uint8 yyr1[] =
1947{
Devang Patel890cc572008-03-03 18:58:47 +00001948 0, 166, 167, 167, 167, 167, 167, 167, 167, 167,
1949 167, 168, 168, 168, 168, 168, 168, 169, 169, 169,
Devang Patel3b8849c2008-02-19 22:27:01 +00001950 169, 169, 169, 169, 169, 169, 169, 169, 169, 170,
Devang Patel890cc572008-03-03 18:58:47 +00001951 170, 170, 170, 170, 170, 170, 170, 170, 170, 171,
1952 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
1953 171, 171, 171, 171, 171, 172, 173, 173, 173, 173,
1954 173, 174, 174, 174, 175, 175, 176, 176, 177, 177,
1955 178, 178, 179, 179, 180, 181, 181, 181, 181, 181,
1956 182, 182, 182, 183, 183, 183, 183, 184, 184, 184,
1957 185, 185, 185, 185, 185, 186, 186, 186, 187, 187,
1958 187, 187, 187, 187, 187, 188, 188, 188, 188, 188,
1959 188, 188, 188, 188, 188, 189, 189, 190, 190, 190,
1960 190, 190, 190, 191, 191, 192, 192, 193, 193, 194,
1961 194, 195, 196, 196, 197, 197, 198, 198, 199, 199,
1962 199, 199, 199, 199, 199, 200, 200, 200, 200, 200,
1963 200, 200, 200, 200, 200, 200, 200, 200, 201, 202,
1964 202, 203, 203, 204, 204, 204, 204, 205, 205, 206,
1965 206, 206, 206, 206, 206, 206, 206, 206, 206, 206,
Dale Johannesena79ecf32008-02-20 21:15:43 +00001966 206, 206, 206, 206, 206, 206, 206, 206, 206, 207,
Devang Patel890cc572008-03-03 18:58:47 +00001967 207, 207, 207, 207, 207, 207, 207, 207, 207, 208,
1968 208, 209, 209, 210, 210, 211, 211, 212, 212, 213,
1969 213, 215, 214, 216, 214, 214, 214, 214, 217, 214,
1970 218, 214, 219, 214, 214, 214, 214, 220, 221, 221,
1971 222, 223, 223, 223, 224, 224, 225, 225, 225, 225,
1972 226, 227, 227, 228, 229, 229, 230, 231, 232, 232,
1973 233, 233, 233, 233, 233, 233, 233, 233, 233, 233,
1974 233, 234, 234, 234, 234, 235, 235, 236, 237, 237,
1975 238, 238, 239, 240, 240, 240, 240, 240, 241, 241,
1976 241, 241, 241, 241, 241, 241, 241, 242, 242, 243,
1977 244, 244, 245, 245, 245, 245, 245, 246, 246, 247,
1978 247, 248, 248, 248, 248, 248, 248, 248, 248, 248,
1979 248, 248, 248, 248, 249, 249, 250, 250, 250, 250,
1980 250, 250, 250, 250, 250
Chris Lattner59363a32008-02-19 04:36:25 +00001981};
1982
1983/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1984static const yytype_uint8 yyr2[] =
1985{
1986 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1987 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1989 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1991 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1992 1, 1, 1, 1, 1, 0, 4, 0, 2, 0,
1993 1, 1, 1, 0, 2, 1, 1, 1, 1, 1,
1994 1, 1, 1, 0, 1, 1, 1, 0, 1, 1,
1995 0, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1996 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
Dale Johannesena79ecf32008-02-20 21:15:43 +00001997 1, 1, 1, 1, 2, 0, 2, 1, 1, 1,
1998 1, 1, 1, 0, 2, 0, 2, 0, 2, 0,
1999 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
2000 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
2001 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
2002 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
2003 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
2004 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
2005 5, 8, 6, 6, 7, 7, 6, 8, 8, 3,
2006 1, 1, 1, 1, 0, 2, 6, 1, 0, 1,
2007 2, 0, 3, 0, 3, 3, 3, 3, 0, 8,
2008 0, 9, 0, 9, 5, 2, 3, 1, 3, 3,
2009 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
2010 10, 1, 1, 4, 1, 1, 2, 3, 0, 1,
2011 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
Devang Patelbf507402008-02-20 22:40:23 +00002012 5, 1, 1, 1, 1, 1, 1, 2, 1, 3,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002013 2, 2, 3, 2, 0, 3, 1, 4, 2, 2,
Devang Patel890cc572008-03-03 18:58:47 +00002014 3, 9, 9, 8, 14, 1, 1, 6, 5, 2,
2015 6, 7, 4, 4, 6, 6, 0, 0, 3, 2,
2016 1, 5, 5, 6, 6, 4, 6, 4, 4, 6,
2017 6, 2, 8, 1, 1, 0, 3, 6, 3, 6,
2018 2, 5, 7, 5, 4
Chris Lattner59363a32008-02-19 04:36:25 +00002019};
2020
2021/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2022 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2023 means the default is an error. */
2024static const yytype_uint16 yydefact[] =
2025{
Dale Johannesena79ecf32008-02-20 21:15:43 +00002026 73, 61, 70, 62, 71, 63, 213, 211, 0, 0,
2027 0, 0, 0, 0, 83, 72, 0, 73, 209, 87,
2028 90, 0, 0, 225, 0, 0, 68, 0, 74, 75,
Chris Lattner59363a32008-02-19 04:36:25 +00002029 77, 76, 78, 80, 79, 81, 82, 84, 85, 86,
Dale Johannesena79ecf32008-02-20 21:15:43 +00002030 83, 83, 204, 1, 210, 88, 89, 83, 214, 91,
Devang Patelbf507402008-02-20 22:40:23 +00002031 92, 93, 94, 83, 274, 212, 274, 0, 0, 233,
Dale Johannesena79ecf32008-02-20 21:15:43 +00002032 226, 227, 215, 261, 262, 217, 138, 139, 140, 143,
2033 142, 141, 144, 145, 0, 0, 0, 0, 263, 264,
2034 146, 216, 148, 204, 204, 95, 203, 0, 98, 98,
Devang Patel890cc572008-03-03 18:58:47 +00002035 276, 0, 271, 69, 244, 245, 246, 270, 228, 229,
2036 232, 0, 166, 149, 0, 0, 0, 0, 155, 167,
2037 0, 0, 166, 0, 0, 0, 97, 96, 0, 201,
2038 202, 0, 0, 99, 100, 101, 102, 103, 0, 247,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002039 0, 0, 0, 315, 273, 0, 230, 165, 115, 161,
Devang Patel890cc572008-03-03 18:58:47 +00002040 163, 0, 0, 0, 0, 0, 0, 154, 0, 0,
2041 147, 0, 0, 160, 0, 159, 0, 224, 138, 139,
2042 140, 143, 142, 141, 0, 0, 67, 67, 104, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002043 241, 242, 243, 0, 250, 251, 252, 257, 253, 254,
2044 255, 256, 248, 2, 3, 4, 5, 6, 7, 8,
2045 9, 10, 14, 15, 16, 11, 12, 13, 0, 0,
2046 0, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2047 26, 27, 28, 0, 0, 0, 0, 0, 0, 0,
2048 0, 259, 266, 265, 275, 314, 300, 0, 0, 0,
2049 0, 98, 285, 286, 0, 0, 0, 0, 0, 0,
2050 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2051 272, 98, 289, 0, 313, 231, 158, 0, 123, 67,
2052 67, 157, 0, 168, 0, 123, 67, 67, 0, 205,
2053 186, 187, 182, 184, 183, 185, 188, 181, 177, 178,
2054 0, 0, 0, 0, 180, 179, 218, 0, 277, 249,
2055 0, 29, 30, 31, 32, 33, 34, 35, 36, 37,
2056 38, 0, 53, 54, 49, 50, 51, 52, 39, 40,
2057 41, 42, 43, 44, 45, 46, 47, 48, 0, 0,
2058 0, 0, 0, 0, 200, 0, 0, 0, 0, 299,
2059 279, 67, 268, 278, 0, 0, 55, 0, 0, 0,
2060 0, 129, 129, 320, 67, 67, 311, 0, 0, 0,
2061 0, 0, 67, 67, 67, 0, 0, 0, 0, 0,
2062 106, 108, 107, 105, 109, 110, 111, 112, 113, 116,
2063 164, 162, 151, 152, 153, 156, 66, 150, 220, 222,
2064 0, 170, 0, 0, 0, 174, 0, 171, 134, 239,
2065 0, 0, 0, 297, 0, 0, 0, 0, 0, 258,
Devang Patel890cc572008-03-03 18:58:47 +00002066 0, 0, 0, 267, 0, 0, 280, 0, 0, 67,
2067 67, 0, 316, 0, 318, 297, 0, 0, 0, 0,
2068 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
2069 114, 120, 119, 117, 118, 121, 122, 124, 134, 134,
2070 0, 169, 155, 167, 0, 172, 173, 0, 219, 238,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002071 115, 236, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 199, 0, 0, 0, 269, 0, 0, 0, 0,
Devang Patel890cc572008-03-03 18:58:47 +00002073 0, 0, 0, 0, 324, 0, 0, 0, 307, 308,
2074 0, 0, 0, 0, 0, 305, 0, 129, 0, 221,
2075 223, 67, 176, 0, 0, 0, 136, 134, 65, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002076 123, 260, 0, 0, 190, 0, 0, 0, 0, 0,
2077 0, 0, 67, 0, 0, 296, 0, 0, 129, 130,
2078 129, 0, 0, 0, 0, 0, 323, 301, 302, 296,
2079 0, 321, 67, 206, 175, 131, 137, 135, 64, 235,
2080 237, 115, 132, 0, 0, 298, 0, 196, 0, 0,
2081 192, 193, 189, 0, 0, 115, 115, 0, 303, 304,
2082 317, 319, 0, 0, 306, 309, 310, 0, 129, 65,
2083 133, 127, 194, 195, 0, 0, 0, 0, 0, 0,
2084 0, 123, 0, 290, 0, 123, 322, 234, 0, 125,
2085 191, 197, 198, 0, 283, 0, 0, 106, 108, 115,
2086 115, 0, 115, 115, 291, 312, 128, 0, 240, 281,
2087 0, 282, 0, 293, 292, 0, 0, 0, 126, 0,
2088 0, 0, 115, 115, 0, 0, 0, 295, 294, 288,
2089 0, 0, 287, 0, 284
Chris Lattner59363a32008-02-19 04:36:25 +00002090};
2091
2092/* YYDEFGOTO[NTERM-NUM]. */
2093static const yytype_int16 yydefgoto[] =
2094{
Nick Lewycky92b80c72008-03-10 05:01:34 +00002095 -1, 218, 219, 220, 301, 318, 164, 165, 78, 539,
Devang Patel890cc572008-03-03 18:58:47 +00002096 113, 12, 79, 14, 15, 40, 41, 42, 47, 53,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002097 118, 128, 369, 256, 437, 372, 608, 589, 412, 496,
2098 571, 448, 497, 80, 166, 139, 156, 140, 141, 110,
2099 324, 221, 325, 121, 87, 157, 16, 17, 18, 20,
2100 19, 388, 438, 439, 62, 23, 60, 101, 451, 452,
2101 129, 172, 54, 96, 55, 48, 290, 222, 82, 224,
2102 332, 333, 56, 92, 93, 250, 596, 134, 346, 557,
2103 456, 251, 252, 253, 254
Chris Lattner59363a32008-02-19 04:36:25 +00002104};
2105
2106/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2107 STATE-NUM. */
Nick Lewycky92b80c72008-03-10 05:01:34 +00002108#define YYPACT_NINF -524
Chris Lattner59363a32008-02-19 04:36:25 +00002109static const yytype_int16 yypact[] =
2110{
Nick Lewycky92b80c72008-03-10 05:01:34 +00002111 369, -524, -524, -524, -524, -524, -524, -524, 46, -130,
2112 11, -89, 62, -59, 258, -524, 135, 506, -524, 227,
2113 130, -12, 26, -524, -1, 180, -524, 1572, -524, -524,
2114 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2115 119, 119, 250, -524, -524, -524, -524, 119, -524, -524,
2116 -524, -524, -524, 119, 39, -524, -2, 214, 221, 229,
2117 -524, -524, -524, -524, -524, 59, -524, -524, -524, -524,
2118 -524, -524, -524, -524, 262, 268, 8, 35, -524, -524,
2119 -524, 9, -524, 195, 195, 244, -524, 162, 233, 233,
2120 186, 238, -524, 127, -524, -524, -524, -524, -524, -524,
2121 -524, 50, 1126, -524, 133, 161, 815, 59, -524, 9,
2122 -88, 172, 1126, 181, 162, 162, -524, -524, 1372, -524,
2123 -524, 1612, 337, -524, -524, -524, -524, -524, 1652, -524,
2124 -3, 314, 906, 1867, -524, 334, -524, -524, 9, -524,
2125 205, 208, 1692, 1692, 200, -64, 1692, -524, 359, 211,
2126 -524, 1612, 1692, 59, 216, 9, 410, -524, 223, 357,
2127 361, 362, 363, 365, 275, 366, 1182, 329, -524, 97,
2128 -524, -524, -524, 906, -524, -524, -524, -524, -524, -524,
2129 -524, -524, 324, -524, -524, -524, -524, -524, -524, -524,
2130 -524, -524, -524, -524, -524, -524, -524, -524, 511, 491,
2131 234, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2132 -524, -524, -524, 252, 253, 259, 260, 1612, 263, 267,
2133 271, -524, -524, -524, -524, -524, -524, 354, 1732, 68,
2134 374, 233, -524, -524, 511, 491, 1692, 1692, 1692, 1692,
2135 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692, 1692,
2136 -524, 233, -524, 197, -524, -524, 210, 1452, -524, -31,
2137 2, -524, 264, 9, 237, -524, 329, -25, 1372, -524,
2138 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2139 1412, 1772, 855, 403, -524, -524, -524, 279, -524, -524,
2140 405, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2141 -524, 284, -524, -524, -524, -524, -524, -524, -524, -524,
2142 -524, -524, -524, -524, -524, -524, -524, -524, 285, 1612,
2143 1612, 1612, 1612, 1612, -524, -46, 1612, 1612, 1612, -524,
2144 59, 766, -524, 287, 906, 906, -524, 906, 1652, 1692,
2145 1692, 45, 51, -524, 766, 17, 290, 294, 295, 297,
2146 298, 299, 14, 766, 766, 417, 1652, 1692, 1692, 452,
2147 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2148 -524, -524, 189, -524, -524, -524, -524, 189, -524, 181,
2149 421, -524, 102, 1080, -32, -524, -49, -524, 305, 1492,
2150 306, 1612, 1612, -524, 308, 311, 315, 316, 1612, -524,
2151 317, 318, 431, -524, 1692, 319, -524, 321, 906, 766,
2152 766, 24, -524, 28, -524, -524, 906, 320, 1692, 1692,
2153 1692, 1692, 1692, 322, 325, 327, 1692, 906, 766, 328,
2154 -524, -524, -524, -524, -524, -524, -524, -524, 305, 305,
2155 1692, -524, 323, 1035, -17, -524, -524, 30, -524, -524,
2156 9, 331, 326, 462, 332, 333, 154, 1612, 1612, 1612,
2157 1612, -524, 1612, 1612, 1692, -524, 472, 473, 340, 339,
2158 341, 906, 493, 906, 347, 348, 906, 349, 9, -524,
2159 352, 353, 507, 906, 906, 9, 343, 360, 1692, -524,
2160 -524, 38, -524, 371, 494, 515, -524, 305, 115, 1532,
2161 -524, -524, 1612, 1612, -524, 1692, 367, 368, 372, 379,
2162 382, 385, 56, 906, 906, 1812, 906, 906, 360, -524,
2163 360, 906, 384, 1692, 1692, 1692, -524, -524, -524, 1812,
2164 487, -524, 766, -524, -524, -524, -524, -524, -524, -524,
2165 -524, 9, -6, 388, 389, -524, 1612, -524, 1612, 1612,
2166 -524, -524, -524, 390, 386, 33, 9, 166, -524, -524,
2167 -524, -524, 383, 906, -524, -524, -524, 170, 360, 115,
2168 -524, 495, -524, -524, 396, 397, 399, 536, 3, 623,
2169 623, -524, 1852, -524, 395, -524, -524, -524, 552, 411,
2170 -524, -524, -524, 906, -524, 1323, 7, 412, 414, -524,
2171 -524, 6, 33, 9, -524, 189, -524, 540, -524, -524,
2172 413, -524, 1323, 210, 210, 550, 623, 623, -524, 553,
2173 416, 906, -524, -524, 906, 555, 500, 210, 210, -524,
2174 906, 557, -524, 906, -524
Chris Lattner59363a32008-02-19 04:36:25 +00002175};
2176
2177/* YYPGOTO[NTERM-NUM]. */
2178static const yytype_int16 yypgoto[] =
2179{
Nick Lewycky92b80c72008-03-10 05:01:34 +00002180 -524, 443, 445, 446, 350, 346, -229, -524, 0, 16,
2181 -141, 489, 13, -524, -524, -524, -524, 61, -524, -524,
2182 -524, -190, -524, -444, -524, -263, -524, -524, -337, 41,
2183 -524, -407, -524, -524, -24, 356, -108, -524, 474, 508,
2184 -81, -150, -207, 228, 261, 351, -524, -524, 598, -524,
2185 -524, -524, -524, -524, -524, -524, -524, -524, -524, -524,
2186 527, -524, -524, -524, -524, -524, -524, -523, -70, 104,
2187 -234, -524, -524, 566, -524, -524, -524, -524, -524, 94,
2188 209, -524, -524, -524, -524
Chris Lattner59363a32008-02-19 04:36:25 +00002189};
2190
2191/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2192 positive, shift that token. If negative, reduce the rule which
2193 number is the opposite. If zero, do what YYDEFACT says.
2194 If YYTABLE_NINF, syntax error. */
Dale Johannesena79ecf32008-02-20 21:15:43 +00002195#define YYTABLE_NINF -209
Chris Lattner59363a32008-02-19 04:36:25 +00002196static const yytype_int16 yytable[] =
2197{
Nick Lewycky92b80c72008-03-10 05:01:34 +00002198 11, 337, 377, 81, 343, 414, 498, 347, 348, 349,
2199 350, 351, 105, 13, 336, 355, 284, 11, 336, 90,
2200 169, 63, 64, 111, 24, 170, 286, 94, 494, 111,
2201 13, 489, 490, 1, 2, 471, 3, 4, 5, 473,
2202 167, 338, 63, 64, 615, 107, 66, 67, 68, 69,
2203 70, 71, 72, 109, 1, 2, 111, 3, 4, 5,
2204 90, 356, 223, 111, 494, 26, 91, 146, 111, 25,
2205 266, 111, 610, 382, 384, 386, 147, 472, 138, 334,
2206 27, 472, 109, 495, 73, 335, 269, -144, 138, 620,
2207 537, 146, 111, 11, 155, 28, 285, 569, 21, 111,
2208 262, 83, 84, 223, 155, 111, 398, 91, 88, 398,
2209 111, 579, 580, 22, 89, 446, 399, 2, 259, 260,
2210 4, 112, 263, 398, 429, 378, 379, 112, 267, 373,
2211 445, 431, 432, 433, 1, 43, 434, 3, 398, 5,
2212 435, 436, 57, 431, 432, 433, 1, 493, 434, 3,
2213 531, 5, 435, 436, 112, 613, 614, 59, 616, 617,
2214 171, 112, 95, 594, 374, -67, 112, 611, 359, 112,
2215 465, 106, 49, 50, 51, 416, 444, 52, 627, 628,
2216 58, 560, 287, 561, 477, -144, 479, 480, 481, -144,
2217 112, 533, 74, 75, 119, 120, 76, 112, 77, 108,
2218 411, -67, 61, 112, 331, 135, 413, -67, 112, 552,
2219 136, 102, 341, 342, 331, 344, 345, 331, 331, 331,
2220 331, 331, 352, 353, 354, 331, -55, -55, -55, -55,
2221 408, 586, 86, 138, 360, 361, 98, 542, 393, 394,
2222 395, 396, 397, 99, 155, 400, 401, 402, 427, 270,
2223 271, 100, 362, 363, 131, 364, 365, 398, 366, 367,
2224 368, 223, 441, 359, 223, 223, 103, 223, 37, 38,
2225 39, 545, 104, 45, 223, 46, 132, 288, 272, 273,
2226 274, 275, 423, 223, 223, 85, 116, 86, 117, 564,
2227 565, 566, 142, 284, 122, 123, 124, 125, 126, 127,
2228 29, 30, 31, 32, 33, 34, 35, 504, 36, 505,
2229 454, 455, 357, 358, 155, 409, 410, 461, 601, 581,
2230 143, 582, 605, 585, 148, 582, 431, 432, 433, 360,
2231 361, 434, 155, 428, 331, 435, 436, 150, 223, 223,
2232 223, 168, 151, 152, 114, 115, 223, 362, 363, 595,
2233 364, 365, 173, 366, 367, 368, 255, 223, 223, 443,
2234 257, 258, 261, 264, 265, 450, -56, 612, 268, -208,
2235 -57, -60, -59, 285, -58, 276, 506, 507, 508, 509,
2236 331, 510, 511, 111, 289, 336, 319, -69, 1, 2,
2237 376, 3, 4, 5, 331, 478, 331, 331, 331, 6,
2238 7, 223, 485, 223, 320, 321, 223, 37, 38, 39,
2239 329, 322, 323, 223, 223, 326, 491, 63, 64, 327,
2240 8, 543, 544, 328, 9, 387, 375, 390, 10, 1,
2241 2, 389, 3, 4, 5, 403, 391, 392, 405, 406,
2242 512, 407, 404, 223, 223, 417, 223, 223, 415, 418,
2243 419, 223, 420, 421, 422, 426, 430, 424, 425, 440,
2244 447, 453, 223, 457, 532, 574, 458, 575, 576, 464,
2245 459, 460, 462, 463, 466, 541, 467, 482, 476, 500,
2246 483, 331, 484, 488, 501, 492, 499, 502, 503, 513,
2247 514, 556, 515, 223, 516, 529, 517, 519, 538, 331,
2248 331, 331, 505, 521, 523, 556, -207, 524, 525, 223,
2249 223, 526, 468, 469, 470, 530, 535, 302, 303, 536,
2250 475, 547, 546, 223, -69, 1, 2, 548, 3, 4,
2251 5, 486, 487, 534, 549, 550, 6, 7, 551, 563,
2252 472, 572, 573, 583, 578, 577, 223, 223, 588, 590,
2253 591, 223, 592, 593, 223, 604, 606, 8, 603, 607,
2254 223, 9, 618, 223, -18, 10, -19, 621, 619, 538,
2255 624, 625, 630, 631, 633, 518, 247, 520, 248, 249,
2256 522, 340, 133, 570, 339, 587, 149, 527, 528, 304,
2257 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
2258 315, 316, 317, 291, 292, 293, 294, 295, 296, 297,
2259 298, 299, 300, 371, 145, 44, 130, 553, 554, 380,
2260 558, 559, 97, 567, 474, 562, 174, 175, 0, 0,
2261 63, 64, 176, 0, 0, 0, 568, 0, 0, 0,
2262 0, 0, 1, 2, 0, 3, 4, 5, 177, 178,
2263 179, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2264 0, 0, 0, 180, 181, 0, 0, 584, 0, 0,
2265 0, 0, 0, 0, 0, 0, 359, 0, 0, 0,
2266 0, 182, 0, 599, 600, 0, 0, 0, 0, 0,
2267 0, 0, 0, 0, 0, 0, 0, 609, 183, 184,
2268 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2269 195, 196, 197, 198, 199, 0, 0, 0, 0, 0,
2270 622, 623, 0, 0, 0, 626, 0, 0, 629, 0,
2271 0, 0, 0, 0, 632, 0, 0, 634, 0, 0,
2272 200, 201, 597, 598, 204, 205, 206, 207, 208, 209,
2273 210, 211, 212, 0, 213, 0, 214, 215, 216, 0,
2274 362, 363, 0, 364, 365, 0, 366, 367, 368, 174,
2275 175, 0, 0, 63, 64, 176, 0, 0, 0, 0,
2276 0, 0, 0, 0, 217, 1, 2, 0, 3, 4,
2277 5, 177, 178, 179, 0, 0, 0, 0, 0, 0,
2278 0, 0, 0, 0, 0, 0, 180, 181, 0, 0,
Devang Patelbf507402008-02-20 22:40:23 +00002279 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002280 111, 0, 63, 64, 182, 107, 66, 67, 68, 69,
Devang Patelbf507402008-02-20 22:40:23 +00002281 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002282 0, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2283 192, 193, 194, 195, 196, 197, 198, 199, 0, 0,
2284 0, 0, 63, 64, 73, 107, 158, 159, 160, 161,
2285 162, 163, 72, 0, 1, 2, 0, 3, 4, 5,
2286 0, 0, 0, 200, 201, 202, 203, 204, 205, 206,
2287 207, 208, 209, 210, 211, 212, 0, 213, 0, 214,
2288 215, 216, 0, 0, 73, 0, 0, 0, 0, 174,
2289 175, 0, 0, 63, 64, 176, 0, 0, 112, 0,
2290 0, 0, 0, 0, 0, 1, 2, 217, 3, 4,
2291 5, 177, 178, 179, 0, 0, 0, 0, 0, 0,
2292 0, 0, 0, 0, 0, 0, 180, 181, 0, 0,
Devang Patelbf507402008-02-20 22:40:23 +00002293 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002294 0, 0, 0, 0, 182, 0, 0, 0, 0, 0,
2295 0, 0, 74, 75, 0, 0, 76, 0, 77, 144,
2296 0, 183, 184, 185, 186, 187, 188, 189, 190, 191,
2297 192, 193, 194, 195, 196, 197, 198, 199, 0, 0,
Devang Patel890cc572008-03-03 18:58:47 +00002298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002299 0, 0, 74, 75, 0, 0, 76, 0, 77, 385,
2300 0, 0, 0, 200, 201, 202, 203, 204, 205, 206,
2301 207, 208, 209, 210, 211, 212, 0, 213, 0, 214,
2302 215, 216, 63, 64, 0, 0, 0, 0, 0, 0,
2303 0, 0, 0, 0, 1, 2, 0, 3, 4, 5,
2304 277, 0, 0, 0, 0, 0, 0, 217, 0, 0,
2305 0, 0, 0, 0, 0, 278, 279, 0, 0, 0,
2306 0, 0, 0, 0, 0, 0, 0, 63, 64, 111,
2307 107, 158, 159, 160, 161, 162, 163, 72, 0, 1,
Devang Patelbf507402008-02-20 22:40:23 +00002308 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002309 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
2310 193, 194, 195, 196, 197, 198, 199, 0, 0, 73,
2311 0, 0, 0, 63, 64, 0, 107, 66, 67, 68,
2312 69, 70, 71, 72, 0, 1, 2, 0, 3, 4,
2313 5, 0, 200, 201, 202, 203, 204, 205, 206, 207,
2314 208, 209, 210, 211, 212, 137, 213, 0, 214, 215,
2315 216, 0, 0, 0, 0, 73, 0, 0, 0, 0,
2316 0, 0, 0, 0, 0, 0, 0, 112, 0, 63,
2317 64, -67, 0, 280, 0, 0, 281, 0, 282, 0,
2318 283, 1, 2, 0, 3, 4, 5, 277, 0, 0,
Devang Patelbf507402008-02-20 22:40:23 +00002319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002320 0, 0, 278, 279, 0, 0, 0, 0, 0, 0,
2321 0, 0, 0, 0, 0, 0, 111, 74, 75, 0,
2322 0, 76, 0, 77, 442, 0, 0, 0, 0, 0,
2323 0, 0, 0, 0, 0, 0, 0, 183, 184, 185,
2324 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
2325 196, 197, 198, 199, 0, 0, 0, 0, 0, 0,
2326 0, 0, 0, 74, 75, 0, 0, 76, 0, 77,
2327 0, 0, 0, 0, 0, 0, 0, 0, 0, 200,
2328 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
2329 211, 212, 0, 213, 0, 214, 215, 216, 0, 0,
2330 0, 0, 0, 0, 0, 0, 174, 175, 0, 0,
2331 0, 0, 176, 0, 112, 0, 0, 0, 0, 0,
2332 280, 0, 0, 281, 0, 282, 0, 283, 177, 178,
2333 179, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2334 0, 0, 0, 180, 181, 0, 0, 0, 0, 0,
2335 0, 0, 0, 0, 0, 0, 0, 0, 0, 63,
2336 64, 182, 153, 66, 67, 68, 69, 70, 71, 72,
2337 0, 1, 2, 0, 3, 4, 5, 0, 183, 184,
2338 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
2339 195, 196, 197, 198, 199, 0, 0, 0, 0, 63,
2340 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2341 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2342 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
2343 210, 211, 212, 0, 213, 0, 214, 215, 216, 63,
2344 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2345 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2346 0, 0, 0, 0, 217, 0, 0, 0, 0, 0,
2347 0, 370, 0, 0, 0, 154, 0, 0, 0, 63,
2348 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2349 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2350 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2351 75, 449, 0, 76, 0, 77, 0, 0, 0, 63,
2352 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2353 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2354 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2355 75, 540, 381, 76, 0, 77, 0, 0, 0, 63,
2356 64, 73, 65, 66, 67, 68, 69, 70, 71, 72,
2357 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2358 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2359 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2360 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2361 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2362 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2363 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2364 64, 73, 153, 66, 67, 68, 69, 70, 71, 72,
2365 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2366 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2367 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2368 64, 73, 107, 66, 67, 68, 69, 70, 71, 72,
2369 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2370 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2371 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2372 64, 73, 330, 66, 67, 68, 69, 70, 71, 72,
2373 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2374 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2375 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2376 64, 73, 107, 158, 159, 160, 161, 162, 163, 72,
2377 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2378 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2379 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2380 64, 73, 107, 66, 67, 68, 69, 70, 71, 555,
2381 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2382 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2383 75, 0, 0, 76, 0, 77, 0, 0, 0, 63,
2384 64, 73, 107, 66, 67, 68, 69, 70, 71, 602,
2385 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2386 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2387 75, 0, 0, 76, 0, 77, 0, 0, 0, 0,
2388 0, 73, 0, 225, 0, 0, 0, 0, 0, 0,
Devang Patel890cc572008-03-03 18:58:47 +00002389 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002390 0, 0, 0, 226, 227, 0, 0, 0, 0, 74,
2391 75, 0, 0, 76, 0, 383, 228, 229, 230, 231,
2392 232, 233, 183, 184, 185, 186, 187, 188, 189, 190,
2393 191, 192, 193, 194, 195, 196, 197, 234, 235, 0,
2394 0, 0, 0, 0, 0, 0, 0, 0, 0, 74,
2395 75, 0, 0, 76, 0, 77, 0, 0, 0, 236,
2396 237, 238, 0, 0, 239, 201, 202, 203, 204, 205,
2397 206, 207, 208, 209, 210, 211, 212, 240, 241, 242,
2398 243, 244, 245, 246, 0, 0, 0, 0, 0, 74,
2399 75, 0, 0, 76, 0, 77
Chris Lattner59363a32008-02-19 04:36:25 +00002400};
2401
2402static const yytype_int16 yycheck[] =
2403{
Nick Lewycky92b80c72008-03-10 05:01:34 +00002404 0, 230, 265, 27, 238, 342, 450, 241, 242, 243,
2405 244, 245, 4, 0, 11, 249, 166, 17, 11, 21,
2406 128, 7, 8, 54, 154, 28, 167, 29, 34, 54,
2407 17, 438, 439, 19, 20, 11, 22, 23, 24, 11,
2408 121, 231, 7, 8, 38, 10, 11, 12, 13, 14,
2409 15, 16, 17, 77, 19, 20, 54, 22, 23, 24,
2410 21, 251, 132, 54, 34, 154, 68, 155, 54, 58,
2411 151, 54, 595, 280, 281, 282, 164, 53, 102, 11,
2412 18, 53, 106, 53, 49, 17, 156, 54, 112, 612,
2413 497, 155, 54, 93, 118, 154, 166, 541, 52, 54,
2414 164, 40, 41, 173, 128, 54, 155, 68, 47, 155,
2415 54, 555, 556, 67, 53, 164, 162, 20, 142, 143,
2416 23, 152, 146, 155, 358, 266, 267, 152, 152, 160,
2417 162, 137, 138, 139, 19, 0, 142, 22, 155, 24,
2418 146, 147, 154, 137, 138, 139, 19, 164, 142, 22,
2419 487, 24, 146, 147, 152, 599, 600, 158, 602, 603,
2420 163, 152, 164, 160, 162, 156, 152, 160, 53, 152,
2421 404, 163, 42, 43, 44, 158, 383, 47, 622, 623,
2422 154, 518, 169, 520, 418, 152, 420, 421, 422, 156,
2423 152, 153, 157, 158, 32, 33, 161, 152, 163, 164,
2424 155, 156, 22, 152, 228, 155, 155, 156, 152, 153,
2425 160, 152, 236, 237, 238, 239, 240, 241, 242, 243,
2426 244, 245, 246, 247, 248, 249, 3, 4, 5, 6,
2427 338, 568, 37, 257, 119, 120, 22, 500, 319, 320,
2428 321, 322, 323, 22, 268, 326, 327, 328, 356, 26,
2429 27, 22, 137, 138, 68, 140, 141, 155, 143, 144,
2430 145, 331, 160, 53, 334, 335, 4, 337, 149, 150,
2431 151, 505, 4, 46, 344, 48, 38, 173, 3, 4,
2432 5, 6, 352, 353, 354, 35, 42, 37, 44, 523,
2433 524, 525, 159, 443, 61, 62, 63, 64, 65, 66,
2434 42, 43, 44, 45, 46, 47, 48, 153, 50, 155,
2435 391, 392, 115, 116, 338, 339, 340, 398, 581, 153,
2436 159, 155, 585, 153, 152, 155, 137, 138, 139, 119,
2437 120, 142, 356, 357, 358, 146, 147, 156, 408, 409,
2438 410, 4, 114, 115, 83, 84, 416, 137, 138, 578,
2439 140, 141, 38, 143, 144, 145, 22, 427, 428, 383,
2440 155, 153, 162, 4, 153, 389, 9, 596, 152, 0,
2441 9, 9, 9, 443, 9, 9, 457, 458, 459, 460,
2442 404, 462, 463, 54, 60, 11, 152, 18, 19, 20,
2443 153, 22, 23, 24, 418, 419, 420, 421, 422, 30,
2444 31, 471, 426, 473, 152, 152, 476, 149, 150, 151,
2445 56, 152, 152, 483, 484, 152, 440, 7, 8, 152,
2446 51, 502, 503, 152, 55, 22, 162, 22, 59, 19,
2447 20, 152, 22, 23, 24, 331, 152, 152, 334, 335,
2448 464, 337, 155, 513, 514, 155, 516, 517, 344, 155,
2449 155, 521, 155, 155, 155, 38, 4, 353, 354, 38,
2450 155, 155, 532, 155, 488, 546, 155, 548, 549, 38,
2451 155, 155, 155, 155, 155, 499, 155, 155, 158, 153,
2452 155, 505, 155, 155, 22, 162, 155, 155, 155, 17,
2453 17, 515, 152, 563, 155, 152, 155, 4, 498, 523,
2454 524, 525, 155, 155, 155, 529, 0, 155, 155, 579,
2455 580, 4, 408, 409, 410, 155, 22, 26, 27, 4,
2456 416, 153, 155, 593, 18, 19, 20, 155, 22, 23,
2457 24, 427, 428, 162, 155, 153, 30, 31, 153, 155,
2458 53, 153, 153, 160, 158, 155, 616, 617, 53, 153,
2459 153, 621, 153, 17, 624, 160, 4, 51, 582, 148,
2460 630, 55, 22, 633, 152, 59, 152, 17, 155, 569,
2461 17, 155, 17, 73, 17, 471, 133, 473, 133, 133,
2462 476, 235, 93, 542, 234, 569, 112, 483, 484, 98,
2463 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2464 109, 110, 111, 92, 93, 94, 95, 96, 97, 98,
2465 99, 100, 101, 257, 106, 17, 89, 513, 514, 268,
2466 516, 517, 56, 529, 415, 521, 3, 4, -1, -1,
2467 7, 8, 9, -1, -1, -1, 532, -1, -1, -1,
2468 -1, -1, 19, 20, -1, 22, 23, 24, 25, 26,
2469 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2470 -1, -1, -1, 40, 41, -1, -1, 563, -1, -1,
2471 -1, -1, -1, -1, -1, -1, 53, -1, -1, -1,
2472 -1, 58, -1, 579, 580, -1, -1, -1, -1, -1,
2473 -1, -1, -1, -1, -1, -1, -1, 593, 75, 76,
2474 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2475 87, 88, 89, 90, 91, -1, -1, -1, -1, -1,
2476 616, 617, -1, -1, -1, 621, -1, -1, 624, -1,
2477 -1, -1, -1, -1, 630, -1, -1, 633, -1, -1,
2478 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2479 127, 128, 129, -1, 131, -1, 133, 134, 135, -1,
2480 137, 138, -1, 140, 141, -1, 143, 144, 145, 3,
2481 4, -1, -1, 7, 8, 9, -1, -1, -1, -1,
2482 -1, -1, -1, -1, 161, 19, 20, -1, 22, 23,
2483 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2484 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Dale Johannesena79ecf32008-02-20 21:15:43 +00002485 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002486 54, -1, 7, 8, 58, 10, 11, 12, 13, 14,
Devang Patelbf507402008-02-20 22:40:23 +00002487 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002488 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2489 84, 85, 86, 87, 88, 89, 90, 91, -1, -1,
2490 -1, -1, 7, 8, 49, 10, 11, 12, 13, 14,
2491 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2492 -1, -1, -1, 117, 118, 119, 120, 121, 122, 123,
2493 124, 125, 126, 127, 128, 129, -1, 131, -1, 133,
2494 134, 135, -1, -1, 49, -1, -1, -1, -1, 3,
2495 4, -1, -1, 7, 8, 9, -1, -1, 152, -1,
2496 -1, -1, -1, -1, -1, 19, 20, 161, 22, 23,
2497 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
2498 -1, -1, -1, -1, -1, -1, 40, 41, -1, -1,
Devang Patel3b8849c2008-02-19 22:27:01 +00002499 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002500 -1, -1, -1, -1, 58, -1, -1, -1, -1, -1,
2501 -1, -1, 157, 158, -1, -1, 161, -1, 163, 164,
2502 -1, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2503 84, 85, 86, 87, 88, 89, 90, 91, -1, -1,
2504 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2505 -1, -1, 157, 158, -1, -1, 161, -1, 163, 164,
2506 -1, -1, -1, 117, 118, 119, 120, 121, 122, 123,
2507 124, 125, 126, 127, 128, 129, -1, 131, -1, 133,
2508 134, 135, 7, 8, -1, -1, -1, -1, -1, -1,
2509 -1, -1, -1, -1, 19, 20, -1, 22, 23, 24,
2510 25, -1, -1, -1, -1, -1, -1, 161, -1, -1,
2511 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2512 -1, -1, -1, -1, -1, -1, -1, 7, 8, 54,
2513 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2514 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2515 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2516 85, 86, 87, 88, 89, 90, 91, -1, -1, 49,
2517 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2518 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
2519 24, -1, 117, 118, 119, 120, 121, 122, 123, 124,
2520 125, 126, 127, 128, 129, 39, 131, -1, 133, 134,
2521 135, -1, -1, -1, -1, 49, -1, -1, -1, -1,
2522 -1, -1, -1, -1, -1, -1, -1, 152, -1, 7,
2523 8, 156, -1, 158, -1, -1, 161, -1, 163, -1,
2524 165, 19, 20, -1, 22, 23, 24, 25, -1, -1,
Devang Patel890cc572008-03-03 18:58:47 +00002525 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2526 -1, -1, 40, 41, -1, -1, -1, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002527 -1, -1, -1, -1, -1, -1, 54, 157, 158, -1,
2528 -1, 161, -1, 163, 164, -1, -1, -1, -1, -1,
Devang Patel890cc572008-03-03 18:58:47 +00002529 -1, -1, -1, -1, -1, -1, -1, 75, 76, 77,
2530 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2531 88, 89, 90, 91, -1, -1, -1, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002532 -1, -1, -1, 157, 158, -1, -1, 161, -1, 163,
2533 -1, -1, -1, -1, -1, -1, -1, -1, -1, 117,
Devang Patel890cc572008-03-03 18:58:47 +00002534 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002535 128, 129, -1, 131, -1, 133, 134, 135, -1, -1,
2536 -1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
2537 -1, -1, 9, -1, 152, -1, -1, -1, -1, -1,
2538 158, -1, -1, 161, -1, 163, -1, 165, 25, 26,
2539 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2540 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
2541 -1, -1, -1, -1, -1, -1, -1, -1, -1, 7,
2542 8, 58, 10, 11, 12, 13, 14, 15, 16, 17,
2543 -1, 19, 20, -1, 22, 23, 24, -1, 75, 76,
2544 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2545 87, 88, 89, 90, 91, -1, -1, -1, -1, 7,
Devang Patel890cc572008-03-03 18:58:47 +00002546 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2547 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002548 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2549 127, 128, 129, -1, 131, -1, 133, 134, 135, 7,
2550 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2551 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2552 -1, -1, -1, -1, 161, -1, -1, -1, -1, -1,
2553 -1, 39, -1, -1, -1, 123, -1, -1, -1, 7,
2554 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2555 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
Devang Patel890cc572008-03-03 18:58:47 +00002556 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002557 158, 39, -1, 161, -1, 163, -1, -1, -1, 7,
2558 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2559 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2560 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2561 158, 39, 160, 161, -1, 163, -1, -1, -1, 7,
2562 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2563 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2564 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2565 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2566 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2567 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2568 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2569 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2570 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2571 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2572 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2573 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2574 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2575 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2576 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2577 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2578 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2579 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2580 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2581 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2582 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2583 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2584 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2585 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2586 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2587 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2588 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2589 158, -1, -1, 161, -1, 163, -1, -1, -1, 7,
2590 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2591 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2592 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2593 158, -1, -1, 161, -1, 163, -1, -1, -1, -1,
2594 -1, 49, -1, 36, -1, -1, -1, -1, -1, -1,
Devang Patelbf507402008-02-20 22:40:23 +00002595 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002596 -1, -1, -1, 56, 57, -1, -1, -1, -1, 157,
2597 158, -1, -1, 161, -1, 163, 69, 70, 71, 72,
2598 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2599 83, 84, 85, 86, 87, 88, 89, 90, 91, -1,
2600 -1, -1, -1, -1, -1, -1, -1, -1, -1, 157,
2601 158, -1, -1, 161, -1, 163, -1, -1, -1, 112,
2602 113, 114, -1, -1, 117, 118, 119, 120, 121, 122,
2603 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
2604 133, 134, 135, 136, -1, -1, -1, -1, -1, 157,
2605 158, -1, -1, 161, -1, 163
Chris Lattner59363a32008-02-19 04:36:25 +00002606};
2607
2608/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2609 symbol of state STATE-NUM. */
2610static const yytype_uint8 yystos[] =
2611{
2612 0, 19, 20, 22, 23, 24, 30, 31, 51, 55,
Devang Patel890cc572008-03-03 18:58:47 +00002613 59, 174, 177, 178, 179, 180, 212, 213, 214, 216,
2614 215, 52, 67, 221, 154, 58, 154, 18, 154, 42,
2615 43, 44, 45, 46, 47, 48, 50, 149, 150, 151,
2616 181, 182, 183, 0, 214, 46, 48, 184, 231, 42,
2617 43, 44, 47, 185, 228, 230, 238, 154, 154, 158,
2618 222, 22, 220, 7, 8, 10, 11, 12, 13, 14,
2619 15, 16, 17, 49, 157, 158, 161, 163, 174, 178,
2620 199, 200, 234, 183, 183, 35, 37, 210, 183, 183,
2621 21, 68, 239, 240, 29, 164, 229, 239, 22, 22,
2622 22, 223, 152, 4, 4, 4, 163, 10, 164, 200,
2623 205, 54, 152, 176, 210, 210, 42, 44, 186, 32,
2624 33, 209, 61, 62, 63, 64, 65, 66, 187, 226,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002625 226, 68, 38, 177, 243, 155, 160, 39, 200, 201,
Devang Patel890cc572008-03-03 18:58:47 +00002626 203, 204, 159, 159, 164, 205, 155, 164, 152, 204,
2627 156, 209, 209, 10, 123, 200, 202, 211, 11, 12,
2628 13, 14, 15, 16, 172, 173, 200, 206, 4, 202,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002629 28, 163, 227, 38, 3, 4, 9, 25, 26, 27,
2630 40, 41, 58, 75, 76, 77, 78, 79, 80, 81,
2631 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2632 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2633 127, 128, 129, 131, 133, 134, 135, 161, 167, 168,
2634 169, 207, 233, 234, 235, 36, 56, 57, 69, 70,
2635 71, 72, 73, 74, 90, 91, 112, 113, 114, 117,
2636 130, 131, 132, 133, 134, 135, 136, 167, 168, 169,
2637 241, 247, 248, 249, 250, 22, 189, 155, 153, 200,
2638 200, 162, 164, 200, 4, 153, 206, 200, 152, 234,
2639 26, 27, 3, 4, 5, 6, 9, 25, 40, 41,
2640 158, 161, 163, 165, 207, 234, 176, 178, 235, 60,
2641 232, 92, 93, 94, 95, 96, 97, 98, 99, 100,
2642 101, 170, 26, 27, 98, 99, 100, 101, 102, 103,
2643 104, 105, 106, 107, 108, 109, 110, 111, 171, 152,
2644 152, 152, 152, 152, 206, 208, 152, 152, 152, 56,
2645 10, 200, 236, 237, 11, 17, 11, 172, 187, 170,
2646 171, 200, 200, 236, 200, 200, 244, 236, 236, 236,
2647 236, 236, 200, 200, 200, 236, 187, 115, 116, 53,
2648 119, 120, 137, 138, 140, 141, 143, 144, 145, 188,
2649 39, 201, 191, 160, 162, 162, 153, 191, 176, 176,
2650 211, 160, 208, 163, 208, 164, 208, 22, 217, 152,
2651 22, 152, 152, 206, 206, 206, 206, 206, 155, 162,
2652 206, 206, 206, 235, 155, 235, 235, 235, 202, 200,
Devang Patel890cc572008-03-03 18:58:47 +00002653 200, 155, 194, 155, 194, 235, 158, 155, 155, 155,
2654 155, 155, 155, 234, 235, 235, 38, 202, 200, 236,
2655 4, 137, 138, 139, 142, 146, 147, 190, 218, 219,
2656 38, 160, 164, 200, 208, 162, 164, 155, 197, 39,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002657 200, 224, 225, 155, 206, 206, 246, 155, 155, 155,
2658 155, 206, 155, 155, 38, 236, 155, 155, 235, 235,
Devang Patel890cc572008-03-03 18:58:47 +00002659 235, 11, 53, 11, 246, 235, 158, 236, 200, 236,
2660 236, 236, 155, 155, 155, 200, 235, 235, 155, 197,
2661 197, 200, 162, 164, 34, 53, 195, 198, 189, 155,
Nick Lewycky92b80c72008-03-10 05:01:34 +00002662 153, 22, 155, 155, 153, 155, 206, 206, 206, 206,
2663 206, 206, 200, 17, 17, 152, 155, 155, 235, 4,
2664 235, 155, 235, 155, 155, 155, 4, 235, 235, 152,
2665 155, 194, 200, 153, 162, 22, 4, 197, 174, 175,
2666 39, 200, 191, 206, 206, 236, 155, 153, 155, 155,
2667 153, 153, 153, 235, 235, 17, 200, 245, 235, 235,
2668 194, 194, 235, 155, 236, 236, 236, 245, 235, 189,
2669 195, 196, 153, 153, 206, 206, 206, 155, 158, 189,
2670 189, 153, 155, 160, 235, 153, 194, 175, 53, 193,
2671 153, 153, 153, 17, 160, 172, 242, 119, 120, 235,
2672 235, 191, 17, 200, 160, 191, 4, 148, 192, 235,
2673 233, 160, 172, 189, 189, 38, 189, 189, 22, 155,
2674 233, 17, 235, 235, 17, 155, 235, 189, 189, 235,
2675 17, 73, 235, 17, 235
Chris Lattner59363a32008-02-19 04:36:25 +00002676};
David Greene9145dd22007-08-01 03:59:32 +00002677
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678#define yyerrok (yyerrstatus = 0)
2679#define yyclearin (yychar = YYEMPTY)
Chris Lattner59363a32008-02-19 04:36:25 +00002680#define YYEMPTY (-2)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681#define YYEOF 0
Chris Lattner59363a32008-02-19 04:36:25 +00002682
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002683#define YYACCEPT goto yyacceptlab
Chris Lattner59363a32008-02-19 04:36:25 +00002684#define YYABORT goto yyabortlab
2685#define YYERROR goto yyerrorlab
2686
2687
2688/* Like YYERROR except do call yyerror. This remains here temporarily
2689 to ease the transition to the new meaning of YYERROR, for GCC.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002690 Once GCC version 2 has supplanted version 1, this can go. */
Chris Lattner59363a32008-02-19 04:36:25 +00002691
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002692#define YYFAIL goto yyerrlab
Chris Lattner59363a32008-02-19 04:36:25 +00002693
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner59363a32008-02-19 04:36:25 +00002695
2696#define YYBACKUP(Token, Value) \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697do \
2698 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner59363a32008-02-19 04:36:25 +00002699 { \
2700 yychar = (Token); \
2701 yylval = (Value); \
2702 yytoken = YYTRANSLATE (yychar); \
2703 YYPOPSTACK (1); \
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704 goto yybackup; \
2705 } \
2706 else \
Chris Lattner59363a32008-02-19 04:36:25 +00002707 { \
2708 yyerror (YY_("syntax error: cannot back up")); \
2709 YYERROR; \
2710 } \
2711while (YYID (0))
2712
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713
2714#define YYTERROR 1
2715#define YYERRCODE 256
2716
Chris Lattner59363a32008-02-19 04:36:25 +00002717
2718/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2719 If N is 0, then set CURRENT to the empty location which ends
2720 the previous symbol: RHS[0] (always defined). */
2721
2722#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2723#ifndef YYLLOC_DEFAULT
2724# define YYLLOC_DEFAULT(Current, Rhs, N) \
2725 do \
2726 if (YYID (N)) \
2727 { \
2728 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2729 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2730 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2731 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2732 } \
2733 else \
2734 { \
2735 (Current).first_line = (Current).last_line = \
2736 YYRHSLOC (Rhs, 0).last_line; \
2737 (Current).first_column = (Current).last_column = \
2738 YYRHSLOC (Rhs, 0).last_column; \
2739 } \
2740 while (YYID (0))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741#endif
2742
Chris Lattner59363a32008-02-19 04:36:25 +00002743
2744/* YY_LOCATION_PRINT -- Print the location on the stream.
2745 This macro was not mandated originally: define only if we know
2746 we won't break user code: when these are the locations we know. */
2747
2748#ifndef YY_LOCATION_PRINT
Nick Lewycky92b80c72008-03-10 05:01:34 +00002749# if YYLTYPE_IS_TRIVIAL
Chris Lattner59363a32008-02-19 04:36:25 +00002750# define YY_LOCATION_PRINT(File, Loc) \
2751 fprintf (File, "%d.%d-%d.%d", \
2752 (Loc).first_line, (Loc).first_column, \
2753 (Loc).last_line, (Loc).last_column)
2754# else
2755# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2756# endif
2757#endif
2758
2759
2760/* YYLEX -- calling `yylex' with the right arguments. */
2761
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002762#ifdef YYLEX_PARAM
Chris Lattner59363a32008-02-19 04:36:25 +00002763# define YYLEX yylex (YYLEX_PARAM)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002764#else
Chris Lattner59363a32008-02-19 04:36:25 +00002765# define YYLEX yylex ()
Scott Michel6d1aba82008-01-30 03:10:00 +00002766#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002767
2768/* Enable debugging if requested. */
2769#if YYDEBUG
2770
2771# ifndef YYFPRINTF
2772# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2773# define YYFPRINTF fprintf
2774# endif
2775
2776# define YYDPRINTF(Args) \
2777do { \
2778 if (yydebug) \
2779 YYFPRINTF Args; \
2780} while (YYID (0))
2781
2782# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2783do { \
2784 if (yydebug) \
2785 { \
2786 YYFPRINTF (stderr, "%s ", Title); \
2787 yy_symbol_print (stderr, \
2788 Type, Value); \
2789 YYFPRINTF (stderr, "\n"); \
2790 } \
2791} while (YYID (0))
2792
2793
2794/*--------------------------------.
2795| Print this symbol on YYOUTPUT. |
2796`--------------------------------*/
2797
2798/*ARGSUSED*/
2799#if (defined __STDC__ || defined __C99__FUNC__ \
2800 || defined __cplusplus || defined _MSC_VER)
2801static void
2802yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
Scott Michel6d1aba82008-01-30 03:10:00 +00002803#else
Chris Lattner59363a32008-02-19 04:36:25 +00002804static void
2805yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2806 FILE *yyoutput;
2807 int yytype;
2808 YYSTYPE const * const yyvaluep;
Scott Michel6d1aba82008-01-30 03:10:00 +00002809#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002810{
2811 if (!yyvaluep)
2812 return;
2813# ifdef YYPRINT
2814 if (yytype < YYNTOKENS)
2815 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2816# else
2817 YYUSE (yyoutput);
2818# endif
2819 switch (yytype)
2820 {
2821 default:
2822 break;
2823 }
2824}
2825
2826
2827/*--------------------------------.
2828| Print this symbol on YYOUTPUT. |
2829`--------------------------------*/
2830
2831#if (defined __STDC__ || defined __C99__FUNC__ \
2832 || defined __cplusplus || defined _MSC_VER)
2833static void
2834yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2835#else
2836static void
2837yy_symbol_print (yyoutput, yytype, yyvaluep)
2838 FILE *yyoutput;
2839 int yytype;
2840 YYSTYPE const * const yyvaluep;
Christopher Lamb0a243582007-12-11 09:02:08 +00002841#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002842{
2843 if (yytype < YYNTOKENS)
2844 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2845 else
2846 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
Scott Michel5a6f17b2008-01-30 02:55:46 +00002847
Chris Lattner59363a32008-02-19 04:36:25 +00002848 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2849 YYFPRINTF (yyoutput, ")");
2850}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002851
Chris Lattner59363a32008-02-19 04:36:25 +00002852/*------------------------------------------------------------------.
2853| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2854| TOP (included). |
2855`------------------------------------------------------------------*/
Scott Michel5a6f17b2008-01-30 02:55:46 +00002856
Chris Lattner59363a32008-02-19 04:36:25 +00002857#if (defined __STDC__ || defined __C99__FUNC__ \
2858 || defined __cplusplus || defined _MSC_VER)
2859static void
2860yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2861#else
2862static void
2863yy_stack_print (bottom, top)
2864 yytype_int16 *bottom;
2865 yytype_int16 *top;
Christopher Lamb0a243582007-12-11 09:02:08 +00002866#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002867{
2868 YYFPRINTF (stderr, "Stack now");
2869 for (; bottom <= top; ++bottom)
2870 YYFPRINTF (stderr, " %d", *bottom);
2871 YYFPRINTF (stderr, "\n");
2872}
Scott Michel5a6f17b2008-01-30 02:55:46 +00002873
Chris Lattner59363a32008-02-19 04:36:25 +00002874# define YY_STACK_PRINT(Bottom, Top) \
2875do { \
2876 if (yydebug) \
2877 yy_stack_print ((Bottom), (Top)); \
2878} while (YYID (0))
Scott Michel5a6f17b2008-01-30 02:55:46 +00002879
Chris Lattner59363a32008-02-19 04:36:25 +00002880
2881/*------------------------------------------------.
2882| Report that the YYRULE is going to be reduced. |
2883`------------------------------------------------*/
2884
2885#if (defined __STDC__ || defined __C99__FUNC__ \
2886 || defined __cplusplus || defined _MSC_VER)
2887static void
2888yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2889#else
2890static void
2891yy_reduce_print (yyvsp, yyrule)
2892 YYSTYPE *yyvsp;
2893 int yyrule;
Dale Johannesen3afee192007-09-07 21:07:57 +00002894#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002895{
2896 int yynrhs = yyr2[yyrule];
2897 int yyi;
2898 unsigned long int yylno = yyrline[yyrule];
2899 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2900 yyrule - 1, yylno);
2901 /* The symbols being reduced. */
2902 for (yyi = 0; yyi < yynrhs; yyi++)
2903 {
2904 fprintf (stderr, " $%d = ", yyi + 1);
2905 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2906 &(yyvsp[(yyi + 1) - (yynrhs)])
2907 );
2908 fprintf (stderr, "\n");
2909 }
2910}
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002911
Chris Lattner59363a32008-02-19 04:36:25 +00002912# define YY_REDUCE_PRINT(Rule) \
2913do { \
2914 if (yydebug) \
2915 yy_reduce_print (yyvsp, Rule); \
2916} while (YYID (0))
Anton Korobeynikov66e28652007-11-14 09:53:48 +00002917
Chris Lattner59363a32008-02-19 04:36:25 +00002918/* Nonzero means print parse trace. It is left uninitialized so that
2919 multiple parsers can coexist. */
2920int yydebug;
2921#else /* !YYDEBUG */
2922# define YYDPRINTF(Args)
2923# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2924# define YY_STACK_PRINT(Bottom, Top)
2925# define YY_REDUCE_PRINT(Rule)
2926#endif /* !YYDEBUG */
2927
2928
2929/* YYINITDEPTH -- initial size of the parser's stacks. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930#ifndef YYINITDEPTH
Chris Lattner59363a32008-02-19 04:36:25 +00002931# define YYINITDEPTH 200
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932#endif
2933
Chris Lattner59363a32008-02-19 04:36:25 +00002934/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2935 if the built-in stack extension method is used).
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936
Chris Lattner59363a32008-02-19 04:36:25 +00002937 Do not make this value too large; the results are undefined if
2938 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2939 evaluated with infinite-precision integer arithmetic. */
David Greene9145dd22007-08-01 03:59:32 +00002940
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941#ifndef YYMAXDEPTH
Chris Lattner59363a32008-02-19 04:36:25 +00002942# define YYMAXDEPTH 10000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943#endif
Chris Lattner59363a32008-02-19 04:36:25 +00002944
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946
Chris Lattner59363a32008-02-19 04:36:25 +00002947#if YYERROR_VERBOSE
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948
Chris Lattner59363a32008-02-19 04:36:25 +00002949# ifndef yystrlen
2950# if defined __GLIBC__ && defined _STRING_H
2951# define yystrlen strlen
2952# else
2953/* Return the length of YYSTR. */
2954#if (defined __STDC__ || defined __C99__FUNC__ \
2955 || defined __cplusplus || defined _MSC_VER)
2956static YYSIZE_T
2957yystrlen (const char *yystr)
Scott Michel5a6f17b2008-01-30 02:55:46 +00002958#else
Chris Lattner59363a32008-02-19 04:36:25 +00002959static YYSIZE_T
2960yystrlen (yystr)
2961 const char *yystr;
2962#endif
2963{
2964 YYSIZE_T yylen;
2965 for (yylen = 0; yystr[yylen]; yylen++)
2966 continue;
2967 return yylen;
2968}
2969# endif
2970# endif
2971
2972# ifndef yystpcpy
2973# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2974# define yystpcpy stpcpy
2975# else
2976/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2977 YYDEST. */
2978#if (defined __STDC__ || defined __C99__FUNC__ \
2979 || defined __cplusplus || defined _MSC_VER)
2980static char *
2981yystpcpy (char *yydest, const char *yysrc)
2982#else
2983static char *
2984yystpcpy (yydest, yysrc)
2985 char *yydest;
2986 const char *yysrc;
2987#endif
2988{
2989 char *yyd = yydest;
2990 const char *yys = yysrc;
2991
2992 while ((*yyd++ = *yys++) != '\0')
2993 continue;
2994
2995 return yyd - 1;
2996}
2997# endif
2998# endif
2999
3000# ifndef yytnamerr
3001/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3002 quotes and backslashes, so that it's suitable for yyerror. The
3003 heuristic is that double-quoting is unnecessary unless the string
3004 contains an apostrophe, a comma, or backslash (other than
3005 backslash-backslash). YYSTR is taken from yytname. If YYRES is
3006 null, do not copy; instead, return the length of what the result
3007 would have been. */
3008static YYSIZE_T
3009yytnamerr (char *yyres, const char *yystr)
3010{
3011 if (*yystr == '"')
3012 {
3013 YYSIZE_T yyn = 0;
3014 char const *yyp = yystr;
3015
3016 for (;;)
3017 switch (*++yyp)
3018 {
3019 case '\'':
3020 case ',':
3021 goto do_not_strip_quotes;
3022
3023 case '\\':
3024 if (*++yyp != '\\')
3025 goto do_not_strip_quotes;
3026 /* Fall through. */
3027 default:
3028 if (yyres)
3029 yyres[yyn] = *yyp;
3030 yyn++;
3031 break;
3032
3033 case '"':
3034 if (yyres)
3035 yyres[yyn] = '\0';
3036 return yyn;
3037 }
3038 do_not_strip_quotes: ;
3039 }
3040
3041 if (! yyres)
3042 return yystrlen (yystr);
3043
3044 return yystpcpy (yyres, yystr) - yyres;
3045}
3046# endif
3047
3048/* Copy into YYRESULT an error message about the unexpected token
3049 YYCHAR while in state YYSTATE. Return the number of bytes copied,
3050 including the terminating null byte. If YYRESULT is null, do not
3051 copy anything; just return the number of bytes that would be
3052 copied. As a special case, return 0 if an ordinary "syntax error"
3053 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3054 size calculation. */
3055static YYSIZE_T
3056yysyntax_error (char *yyresult, int yystate, int yychar)
3057{
3058 int yyn = yypact[yystate];
3059
3060 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3061 return 0;
3062 else
3063 {
3064 int yytype = YYTRANSLATE (yychar);
3065 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3066 YYSIZE_T yysize = yysize0;
3067 YYSIZE_T yysize1;
3068 int yysize_overflow = 0;
3069 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3070 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3071 int yyx;
3072
3073# if 0
3074 /* This is so xgettext sees the translatable formats that are
3075 constructed on the fly. */
3076 YY_("syntax error, unexpected %s");
3077 YY_("syntax error, unexpected %s, expecting %s");
3078 YY_("syntax error, unexpected %s, expecting %s or %s");
3079 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3080 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3081# endif
3082 char *yyfmt;
3083 char const *yyf;
3084 static char const yyunexpected[] = "syntax error, unexpected %s";
3085 static char const yyexpecting[] = ", expecting %s";
3086 static char const yyor[] = " or %s";
3087 char yyformat[sizeof yyunexpected
3088 + sizeof yyexpecting - 1
3089 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3090 * (sizeof yyor - 1))];
3091 char const *yyprefix = yyexpecting;
3092
3093 /* Start YYX at -YYN if negative to avoid negative indexes in
3094 YYCHECK. */
3095 int yyxbegin = yyn < 0 ? -yyn : 0;
3096
3097 /* Stay within bounds of both yycheck and yytname. */
3098 int yychecklim = YYLAST - yyn + 1;
3099 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3100 int yycount = 1;
3101
3102 yyarg[0] = yytname[yytype];
3103 yyfmt = yystpcpy (yyformat, yyunexpected);
3104
3105 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3106 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3107 {
3108 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3109 {
3110 yycount = 1;
3111 yysize = yysize0;
3112 yyformat[sizeof yyunexpected - 1] = '\0';
3113 break;
3114 }
3115 yyarg[yycount++] = yytname[yyx];
3116 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3117 yysize_overflow |= (yysize1 < yysize);
3118 yysize = yysize1;
3119 yyfmt = yystpcpy (yyfmt, yyprefix);
3120 yyprefix = yyor;
3121 }
3122
3123 yyf = YY_(yyformat);
3124 yysize1 = yysize + yystrlen (yyf);
3125 yysize_overflow |= (yysize1 < yysize);
3126 yysize = yysize1;
3127
3128 if (yysize_overflow)
3129 return YYSIZE_MAXIMUM;
3130
3131 if (yyresult)
3132 {
3133 /* Avoid sprintf, as that infringes on the user's name space.
3134 Don't have undefined behavior even if the translation
3135 produced a string with the wrong number of "%s"s. */
3136 char *yyp = yyresult;
3137 int yyi = 0;
3138 while ((*yyp = *yyf) != '\0')
3139 {
3140 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3141 {
3142 yyp += yytnamerr (yyp, yyarg[yyi++]);
3143 yyf += 2;
3144 }
3145 else
3146 {
3147 yyp++;
3148 yyf++;
3149 }
3150 }
3151 }
3152 return yysize;
3153 }
3154}
3155#endif /* YYERROR_VERBOSE */
3156
3157
3158/*-----------------------------------------------.
3159| Release the memory associated to this symbol. |
3160`-----------------------------------------------*/
3161
3162/*ARGSUSED*/
3163#if (defined __STDC__ || defined __C99__FUNC__ \
3164 || defined __cplusplus || defined _MSC_VER)
3165static void
3166yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
3167#else
3168static void
3169yydestruct (yymsg, yytype, yyvaluep)
3170 const char *yymsg;
3171 int yytype;
3172 YYSTYPE *yyvaluep;
3173#endif
3174{
3175 YYUSE (yyvaluep);
3176
3177 if (!yymsg)
3178 yymsg = "Deleting";
3179 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3180
3181 switch (yytype)
3182 {
3183
3184 default:
3185 break;
3186 }
3187}
3188
3189
3190/* Prevent warnings from -Wmissing-prototypes. */
3191
3192#ifdef YYPARSE_PARAM
3193#if defined __STDC__ || defined __cplusplus
3194int yyparse (void *YYPARSE_PARAM);
3195#else
3196int yyparse ();
3197#endif
3198#else /* ! YYPARSE_PARAM */
3199#if defined __STDC__ || defined __cplusplus
David Greene48556392007-09-04 18:46:50 +00003200int yyparse (void);
Scott Michel6d1aba82008-01-30 03:10:00 +00003201#else
Chris Lattner59363a32008-02-19 04:36:25 +00003202int yyparse ();
Christopher Lamb0a243582007-12-11 09:02:08 +00003203#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003204#endif /* ! YYPARSE_PARAM */
Anton Korobeynikov66e28652007-11-14 09:53:48 +00003205
Scott Michel5a6f17b2008-01-30 02:55:46 +00003206
Chris Lattner59363a32008-02-19 04:36:25 +00003207
3208/* The look-ahead symbol. */
3209int yychar;
3210
3211/* The semantic value of the look-ahead symbol. */
3212YYSTYPE yylval;
3213
3214/* Number of syntax errors so far. */
3215int yynerrs;
3216
3217
3218
3219/*----------.
3220| yyparse. |
3221`----------*/
3222
3223#ifdef YYPARSE_PARAM
3224#if (defined __STDC__ || defined __C99__FUNC__ \
3225 || defined __cplusplus || defined _MSC_VER)
3226int
3227yyparse (void *YYPARSE_PARAM)
3228#else
3229int
3230yyparse (YYPARSE_PARAM)
3231 void *YYPARSE_PARAM;
3232#endif
3233#else /* ! YYPARSE_PARAM */
3234#if (defined __STDC__ || defined __C99__FUNC__ \
3235 || defined __cplusplus || defined _MSC_VER)
3236int
3237yyparse (void)
3238#else
3239int
3240yyparse ()
3241
Scott Michel6d1aba82008-01-30 03:10:00 +00003242#endif
3243#endif
Chris Lattner59363a32008-02-19 04:36:25 +00003244{
3245
3246 int yystate;
3247 int yyn;
3248 int yyresult;
3249 /* Number of tokens to shift before error messages enabled. */
3250 int yyerrstatus;
3251 /* Look-ahead token as an internal (translated) token number. */
3252 int yytoken = 0;
3253#if YYERROR_VERBOSE
3254 /* Buffer for error messages, and its allocated size. */
3255 char yymsgbuf[128];
3256 char *yymsg = yymsgbuf;
3257 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
Scott Michel6d1aba82008-01-30 03:10:00 +00003258#endif
Scott Michel5a6f17b2008-01-30 02:55:46 +00003259
Chris Lattner59363a32008-02-19 04:36:25 +00003260 /* Three stacks and their tools:
3261 `yyss': related to states,
3262 `yyvs': related to semantic values,
3263 `yyls': related to locations.
3264
3265 Refer to the stacks thru separate pointers, to allow yyoverflow
3266 to reallocate them elsewhere. */
3267
3268 /* The state stack. */
3269 yytype_int16 yyssa[YYINITDEPTH];
3270 yytype_int16 *yyss = yyssa;
3271 yytype_int16 *yyssp;
3272
3273 /* The semantic value stack. */
3274 YYSTYPE yyvsa[YYINITDEPTH];
3275 YYSTYPE *yyvs = yyvsa;
3276 YYSTYPE *yyvsp;
3277
3278
3279
3280#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
3281
3282 YYSIZE_T yystacksize = YYINITDEPTH;
3283
3284 /* The variables used to return semantic value and location from the
3285 action routines. */
3286 YYSTYPE yyval;
3287
3288
3289 /* The number of symbols on the RHS of the reduced rule.
3290 Keep to zero when no symbol should be popped. */
3291 int yylen = 0;
3292
3293 YYDPRINTF ((stderr, "Starting parse\n"));
3294
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 yystate = 0;
3296 yyerrstatus = 0;
3297 yynerrs = 0;
3298 yychar = YYEMPTY; /* Cause a token to be read. */
3299
3300 /* Initialize stack pointers.
3301 Waste one element of value and location stack
3302 so that they stay on the same level as the state stack.
3303 The wasted elements are never initialized. */
3304
Chris Lattner59363a32008-02-19 04:36:25 +00003305 yyssp = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 yyvsp = yyvs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003307
Chris Lattner59363a32008-02-19 04:36:25 +00003308 goto yysetstate;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003309
Chris Lattner59363a32008-02-19 04:36:25 +00003310/*------------------------------------------------------------.
3311| yynewstate -- Push a new state, which is found in yystate. |
3312`------------------------------------------------------------*/
3313 yynewstate:
3314 /* In all cases, when you get here, the value and location stacks
3315 have just been pushed. So pushing a state here evens the stacks. */
3316 yyssp++;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317
Chris Lattner59363a32008-02-19 04:36:25 +00003318 yysetstate:
3319 *yyssp = yystate;
3320
3321 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003323 /* Get the current used size of the three stacks, in elements. */
Chris Lattner59363a32008-02-19 04:36:25 +00003324 YYSIZE_T yysize = yyssp - yyss + 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325
3326#ifdef yyoverflow
Chris Lattner59363a32008-02-19 04:36:25 +00003327 {
3328 /* Give user a chance to reallocate the stack. Use copies of
3329 these so that the &'s don't force the real ones into
3330 memory. */
3331 YYSTYPE *yyvs1 = yyvs;
3332 yytype_int16 *yyss1 = yyss;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003333
Chris Lattner59363a32008-02-19 04:36:25 +00003334
3335 /* Each stack pointer address is followed by the size of the
3336 data in use in that stack, in bytes. This used to be a
3337 conditional around just the two extra args, but that might
3338 be undefined if yyoverflow is a macro. */
3339 yyoverflow (YY_("memory exhausted"),
3340 &yyss1, yysize * sizeof (*yyssp),
3341 &yyvs1, yysize * sizeof (*yyvsp),
3342
3343 &yystacksize);
3344
3345 yyss = yyss1;
3346 yyvs = yyvs1;
3347 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348#else /* no yyoverflow */
Chris Lattner59363a32008-02-19 04:36:25 +00003349# ifndef YYSTACK_RELOCATE
3350 goto yyexhaustedlab;
3351# else
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003352 /* Extend the stack our own way. */
Chris Lattner59363a32008-02-19 04:36:25 +00003353 if (YYMAXDEPTH <= yystacksize)
3354 goto yyexhaustedlab;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355 yystacksize *= 2;
Chris Lattner59363a32008-02-19 04:36:25 +00003356 if (YYMAXDEPTH < yystacksize)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003357 yystacksize = YYMAXDEPTH;
Chris Lattner59363a32008-02-19 04:36:25 +00003358
3359 {
3360 yytype_int16 *yyss1 = yyss;
3361 union yyalloc *yyptr =
3362 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3363 if (! yyptr)
3364 goto yyexhaustedlab;
3365 YYSTACK_RELOCATE (yyss);
3366 YYSTACK_RELOCATE (yyvs);
3367
3368# undef YYSTACK_RELOCATE
3369 if (yyss1 != yyssa)
3370 YYSTACK_FREE (yyss1);
3371 }
3372# endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003373#endif /* no yyoverflow */
3374
Chris Lattner59363a32008-02-19 04:36:25 +00003375 yyssp = yyss + yysize - 1;
3376 yyvsp = yyvs + yysize - 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003378
Chris Lattner59363a32008-02-19 04:36:25 +00003379 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3380 (unsigned long int) yystacksize));
3381
3382 if (yyss + yystacksize - 1 <= yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 YYABORT;
3384 }
3385
Chris Lattner59363a32008-02-19 04:36:25 +00003386 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387
3388 goto yybackup;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389
Chris Lattner59363a32008-02-19 04:36:25 +00003390/*-----------.
3391| yybackup. |
3392`-----------*/
3393yybackup:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003394
Chris Lattner59363a32008-02-19 04:36:25 +00003395 /* Do appropriate processing given the current state. Read a
3396 look-ahead token if we need one and don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397
Chris Lattner59363a32008-02-19 04:36:25 +00003398 /* First try to decide what to do without reference to look-ahead token. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003399 yyn = yypact[yystate];
Chris Lattner59363a32008-02-19 04:36:25 +00003400 if (yyn == YYPACT_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003401 goto yydefault;
3402
Chris Lattner59363a32008-02-19 04:36:25 +00003403 /* Not known => get a look-ahead token if don't already have one. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404
Chris Lattner59363a32008-02-19 04:36:25 +00003405 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003406 if (yychar == YYEMPTY)
3407 {
Chris Lattner59363a32008-02-19 04:36:25 +00003408 YYDPRINTF ((stderr, "Reading a token: "));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003409 yychar = YYLEX;
3410 }
3411
Chris Lattner59363a32008-02-19 04:36:25 +00003412 if (yychar <= YYEOF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003413 {
Chris Lattner59363a32008-02-19 04:36:25 +00003414 yychar = yytoken = YYEOF;
3415 YYDPRINTF ((stderr, "Now at end of input.\n"));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003416 }
3417 else
3418 {
Chris Lattner59363a32008-02-19 04:36:25 +00003419 yytoken = YYTRANSLATE (yychar);
3420 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003421 }
3422
Chris Lattner59363a32008-02-19 04:36:25 +00003423 /* If the proper action on seeing token YYTOKEN is to reduce or to
3424 detect an error, take that action. */
3425 yyn += yytoken;
3426 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003427 goto yydefault;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003428 yyn = yytable[yyn];
Chris Lattner59363a32008-02-19 04:36:25 +00003429 if (yyn <= 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003430 {
Chris Lattner59363a32008-02-19 04:36:25 +00003431 if (yyn == 0 || yyn == YYTABLE_NINF)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432 goto yyerrlab;
3433 yyn = -yyn;
3434 goto yyreduce;
3435 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436
3437 if (yyn == YYFINAL)
3438 YYACCEPT;
3439
Chris Lattner59363a32008-02-19 04:36:25 +00003440 /* Count tokens shifted since error; after three, turn off error
3441 status. */
3442 if (yyerrstatus)
3443 yyerrstatus--;
Dale Johannesen3afee192007-09-07 21:07:57 +00003444
Chris Lattner59363a32008-02-19 04:36:25 +00003445 /* Shift the look-ahead token. */
3446 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003447
Chris Lattner59363a32008-02-19 04:36:25 +00003448 /* Discard the shifted token unless it is eof. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003449 if (yychar != YYEOF)
3450 yychar = YYEMPTY;
3451
Scott Michel6d1aba82008-01-30 03:10:00 +00003452 yystate = yyn;
Chris Lattner59363a32008-02-19 04:36:25 +00003453 *++yyvsp = yylval;
3454
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003455 goto yynewstate;
3456
Scott Michel6d1aba82008-01-30 03:10:00 +00003457
Chris Lattner59363a32008-02-19 04:36:25 +00003458/*-----------------------------------------------------------.
3459| yydefault -- do the default action for the current state. |
3460`-----------------------------------------------------------*/
3461yydefault:
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003462 yyn = yydefact[yystate];
3463 if (yyn == 0)
3464 goto yyerrlab;
Chris Lattner59363a32008-02-19 04:36:25 +00003465 goto yyreduce;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003466
Chris Lattner59363a32008-02-19 04:36:25 +00003467
3468/*-----------------------------.
3469| yyreduce -- Do a reduction. |
3470`-----------------------------*/
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003471yyreduce:
Chris Lattner59363a32008-02-19 04:36:25 +00003472 /* yyn is the number of a rule to reduce with. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003473 yylen = yyr2[yyn];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474
Chris Lattner59363a32008-02-19 04:36:25 +00003475 /* If YYLEN is nonzero, implement the default value of the action:
3476 `$$ = $1'.
3477
3478 Otherwise, the following line sets YYVAL to garbage.
3479 This behavior is undocumented and Bison
3480 users should not rely upon it. Assigning to YYVAL
3481 unconditionally makes the parser a bit smaller, and it avoids a
3482 GCC warning that YYVAL may be used uninitialized. */
3483 yyval = yyvsp[1-yylen];
3484
3485
3486 YY_REDUCE_PRINT (yyn);
3487 switch (yyn)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003488 {
Chris Lattner59363a32008-02-19 04:36:25 +00003489 case 29:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003490#line 1119 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003491 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3492 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003493
Chris Lattner59363a32008-02-19 04:36:25 +00003494 case 30:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003495#line 1119 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003496 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3497 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003498
Chris Lattner59363a32008-02-19 04:36:25 +00003499 case 31:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003500#line 1120 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003501 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3502 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003503
Chris Lattner59363a32008-02-19 04:36:25 +00003504 case 32:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003505#line 1120 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003506 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3507 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508
Chris Lattner59363a32008-02-19 04:36:25 +00003509 case 33:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003510#line 1121 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003511 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3512 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003513
Chris Lattner59363a32008-02-19 04:36:25 +00003514 case 34:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003515#line 1121 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003516 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3517 break;
3518
3519 case 35:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003520#line 1122 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003521 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3522 break;
3523
3524 case 36:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003525#line 1122 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003526 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3527 break;
3528
3529 case 37:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003530#line 1123 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003531 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3532 break;
3533
3534 case 38:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003535#line 1123 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003536 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3537 break;
3538
3539 case 39:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003540#line 1127 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003541 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3542 break;
3543
3544 case 40:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003545#line 1127 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003546 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3547 break;
3548
3549 case 41:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003550#line 1128 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003551 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3552 break;
3553
3554 case 42:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003555#line 1128 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003556 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3557 break;
3558
3559 case 43:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003560#line 1129 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003561 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3562 break;
3563
3564 case 44:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003565#line 1129 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003566 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3567 break;
3568
3569 case 45:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003570#line 1130 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003571 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3572 break;
3573
3574 case 46:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003575#line 1130 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003576 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3577 break;
3578
3579 case 47:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003580#line 1131 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003581 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3582 break;
3583
3584 case 48:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003585#line 1131 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003586 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3587 break;
3588
3589 case 49:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003590#line 1132 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003591 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3592 break;
3593
3594 case 50:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003595#line 1132 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003596 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3597 break;
3598
3599 case 51:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003600#line 1133 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003601 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3602 break;
3603
3604 case 52:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003605#line 1133 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003606 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3607 break;
3608
3609 case 53:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003610#line 1134 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003611 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3612 break;
3613
3614 case 54:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003615#line 1135 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003616 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3617 break;
3618
3619 case 65:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003620#line 1144 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003621 { (yyval.StrVal) = 0; ;}
3622 break;
3623
3624 case 66:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003625#line 1146 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003626 { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;}
3627 break;
3628
3629 case 67:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003630#line 1147 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003631 { (yyval.UIntVal)=0; ;}
3632 break;
3633
3634 case 68:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003635#line 1151 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003636 {
3637 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003638 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003639 ;}
3640 break;
3641
3642 case 69:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003643#line 1155 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003644 {
3645 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003646 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003647 ;}
3648 break;
3649
3650 case 73:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003651#line 1163 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003652 {
3653 (yyval.StrVal) = 0;
Christopher Lamb668d9a02007-12-12 08:45:45 +00003654 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003655 ;}
3656 break;
3657
3658 case 74:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003659#line 1168 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003660 {
3661 (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00003662 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003663 ;}
3664 break;
3665
3666 case 75:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003667#line 1174 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003668 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3669 break;
3670
3671 case 76:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003672#line 1175 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003673 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3674 break;
3675
3676 case 77:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003677#line 1176 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003678 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3679 break;
3680
3681 case 78:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003682#line 1177 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003683 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3684 break;
3685
3686 case 79:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003687#line 1178 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003688 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3689 break;
3690
3691 case 80:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003692#line 1182 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003693 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3694 break;
3695
3696 case 81:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003697#line 1183 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003698 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3699 break;
3700
3701 case 82:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003702#line 1184 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003703 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3704 break;
3705
3706 case 83:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003707#line 1188 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003708 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3709 break;
3710
3711 case 84:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003712#line 1189 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003713 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3714 break;
3715
3716 case 85:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003717#line 1190 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003718 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3719 break;
3720
3721 case 86:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003722#line 1191 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003723 { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;}
3724 break;
3725
3726 case 87:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003727#line 1195 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003728 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3729 break;
3730
3731 case 88:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003732#line 1196 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003733 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3734 break;
3735
3736 case 89:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003737#line 1197 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003738 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3739 break;
3740
3741 case 90:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003742#line 1201 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003743 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3744 break;
3745
3746 case 91:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003747#line 1202 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003748 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3749 break;
3750
3751 case 92:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003752#line 1203 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003753 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3754 break;
3755
3756 case 93:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003757#line 1204 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003758 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3759 break;
3760
3761 case 94:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003762#line 1205 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003763 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3764 break;
3765
3766 case 95:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003767#line 1209 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003768 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3769 break;
3770
3771 case 96:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003772#line 1210 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003773 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3774 break;
3775
3776 case 97:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003777#line 1211 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003778 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3779 break;
3780
3781 case 98:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003782#line 1214 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003783 { (yyval.UIntVal) = CallingConv::C; ;}
3784 break;
3785
3786 case 99:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003787#line 1215 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003788 { (yyval.UIntVal) = CallingConv::C; ;}
3789 break;
3790
3791 case 100:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003792#line 1216 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003793 { (yyval.UIntVal) = CallingConv::Fast; ;}
3794 break;
3795
3796 case 101:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003797#line 1217 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003798 { (yyval.UIntVal) = CallingConv::Cold; ;}
3799 break;
3800
3801 case 102:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003802#line 1218 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003803 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3804 break;
3805
3806 case 103:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003807#line 1219 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003808 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3809 break;
3810
3811 case 104:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003812#line 1220 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003813 {
3814 if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003815 GEN_ERROR("Calling conv too large");
Chris Lattner59363a32008-02-19 04:36:25 +00003816 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003817 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003818 ;}
3819 break;
3820
3821 case 105:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003822#line 1227 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003823 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3824 break;
3825
3826 case 106:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003827#line 1228 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003828 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3829 break;
3830
3831 case 107:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003832#line 1229 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003833 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3834 break;
3835
3836 case 108:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003837#line 1230 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003838 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3839 break;
3840
3841 case 109:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003842#line 1231 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003843 { (yyval.ParamAttrs) = ParamAttr::InReg; ;}
3844 break;
3845
3846 case 110:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003847#line 1232 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003848 { (yyval.ParamAttrs) = ParamAttr::StructRet; ;}
3849 break;
3850
3851 case 111:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003852#line 1233 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003853 { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;}
3854 break;
3855
3856 case 112:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003857#line 1234 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003858 { (yyval.ParamAttrs) = ParamAttr::ByVal; ;}
3859 break;
3860
3861 case 113:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003862#line 1235 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003863 { (yyval.ParamAttrs) = ParamAttr::Nest; ;}
3864 break;
3865
3866 case 114:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003867#line 1236 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesenf92f3162008-02-22 17:50:51 +00003868 { (yyval.ParamAttrs) =
3869 ParamAttr::constructAlignmentFromInt((yyvsp[(2) - (2)].UInt64Val)); ;}
Chris Lattner59363a32008-02-19 04:36:25 +00003870 break;
3871
3872 case 115:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003873#line 1240 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003874 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3875 break;
3876
Dale Johannesena79ecf32008-02-20 21:15:43 +00003877 case 116:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003878#line 1241 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003879 {
3880 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3881 ;}
3882 break;
3883
Dale Johannesena79ecf32008-02-20 21:15:43 +00003884 case 117:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003885#line 1246 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003886 { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;}
3887 break;
3888
3889 case 118:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003890#line 1247 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003891 { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;}
3892 break;
3893
3894 case 119:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003895#line 1248 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003896 { (yyval.ParamAttrs) = ParamAttr::ZExt; ;}
3897 break;
3898
3899 case 120:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003900#line 1249 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003901 { (yyval.ParamAttrs) = ParamAttr::SExt; ;}
3902 break;
3903
3904 case 121:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003905#line 1250 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003906 { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;}
3907 break;
3908
3909 case 122:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003910#line 1251 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003911 { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;}
3912 break;
3913
3914 case 123:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003915#line 1254 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003916 { (yyval.ParamAttrs) = ParamAttr::None; ;}
3917 break;
3918
Chris Lattner59363a32008-02-19 04:36:25 +00003919 case 124:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003920#line 1255 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003921 {
3922 (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs);
3923 ;}
Chris Lattner59363a32008-02-19 04:36:25 +00003924 break;
3925
3926 case 125:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003927#line 1260 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003928 { (yyval.StrVal) = 0; ;}
3929 break;
3930
3931 case 126:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003932#line 1261 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003933 {
3934 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
3935 ;}
3936 break;
3937
Dale Johannesena79ecf32008-02-20 21:15:43 +00003938 case 127:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003939#line 1268 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003940 { (yyval.UIntVal) = 0; ;}
3941 break;
3942
Dale Johannesena79ecf32008-02-20 21:15:43 +00003943 case 128:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003944#line 1269 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003945 {
3946 (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
3947 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948 GEN_ERROR("Alignment must be a power of two");
3949 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003950;}
3951 break;
3952
Dale Johannesena79ecf32008-02-20 21:15:43 +00003953 case 129:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003954#line 1275 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003955 { (yyval.UIntVal) = 0; ;}
3956 break;
3957
Dale Johannesena79ecf32008-02-20 21:15:43 +00003958 case 130:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003959#line 1276 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003960 {
3961 (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
3962 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Christopher Lamb668d9a02007-12-12 08:45:45 +00003963 GEN_ERROR("Alignment must be a power of two");
3964 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003965;}
3966 break;
3967
Dale Johannesena79ecf32008-02-20 21:15:43 +00003968 case 131:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003969#line 1285 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003970 {
3971 for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i)
3972 if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\')
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003973 GEN_ERROR("Invalid character in section name");
Chris Lattner59363a32008-02-19 04:36:25 +00003974 (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003975 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00003976;}
3977 break;
3978
Dale Johannesena79ecf32008-02-20 21:15:43 +00003979 case 132:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003980#line 1293 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003981 { (yyval.StrVal) = 0; ;}
3982 break;
3983
Dale Johannesena79ecf32008-02-20 21:15:43 +00003984 case 133:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003985#line 1294 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003986 { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
3987 break;
3988
Chris Lattner59363a32008-02-19 04:36:25 +00003989 case 134:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003990#line 1299 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00003991 {;}
3992 break;
3993
3994 case 135:
Nick Lewycky92b80c72008-03-10 05:01:34 +00003995#line 1300 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00003996 {;}
3997 break;
3998
3999 case 136:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004000#line 1301 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004001 {
4002 CurGV->setSection(*(yyvsp[(1) - (1)].StrVal));
4003 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004004 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004005 ;}
4006 break;
4007
Dale Johannesena79ecf32008-02-20 21:15:43 +00004008 case 137:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004009#line 1306 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004010 {
4011 if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004012 GEN_ERROR("Alignment must be a power of two");
Chris Lattner59363a32008-02-19 04:36:25 +00004013 CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004014 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004015 ;}
4016 break;
4017
Dale Johannesena79ecf32008-02-20 21:15:43 +00004018 case 145:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004019#line 1322 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004020 {
4021 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004022 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004023 ;}
4024 break;
4025
Dale Johannesena79ecf32008-02-20 21:15:43 +00004026 case 146:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004027#line 1326 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004028 {
4029 (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004030 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004031 ;}
4032 break;
4033
Dale Johannesena79ecf32008-02-20 21:15:43 +00004034 case 147:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004035#line 1330 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004036 { // Pointer type?
4037 if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy)
Christopher Lamb668d9a02007-12-12 08:45:45 +00004038 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner59363a32008-02-19 04:36:25 +00004039 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal))));
4040 delete (yyvsp[(1) - (3)].TypeVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00004041 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004042 ;}
4043 break;
4044
Dale Johannesena79ecf32008-02-20 21:15:43 +00004045 case 148:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004046#line 1337 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004047 { // Named types are also simple types...
4048 const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal));
Christopher Lamb0a243582007-12-11 09:02:08 +00004049 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004050 (yyval.TypeVal) = new PATypeHolder(tmp);
4051 ;}
4052 break;
4053
Dale Johannesena79ecf32008-02-20 21:15:43 +00004054 case 149:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004055#line 1342 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004056 { // Type UpReference
4057 if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004058 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner59363a32008-02-19 04:36:25 +00004059 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
4060 (yyval.TypeVal) = new PATypeHolder(OT);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004061 UR_OUT("New Upreference!\n");
4062 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004063 ;}
4064 break;
4065
Dale Johannesena79ecf32008-02-20 21:15:43 +00004066 case 150:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004067#line 1350 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004068 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004069 // Allow but ignore attributes on function types; this permits auto-upgrade.
4070 // FIXME: remove in LLVM 3.0.
Chris Lattner59363a32008-02-19 04:36:25 +00004071 const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal);
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004072 if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy ||
4073 isa<OpaqueType>(RetTy)))
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004074 GEN_ERROR("LLVM Functions cannot return aggregates");
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004075
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004076 std::vector<const Type*> Params;
Chris Lattner59363a32008-02-19 04:36:25 +00004077 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004078 for (; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004079 const Type *Ty = I->Ty->get();
4080 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004081 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004082
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004083 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4084 if (isVarArg) Params.pop_back();
4085
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004086 for (unsigned i = 0; i != Params.size(); ++i)
4087 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4088 GEN_ERROR("Function arguments must be value types!");
4089
4090 CHECK_FOR_ERROR
4091
Anton Korobeynikov0cdd2692007-12-03 19:17:47 +00004092 FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg);
Chris Lattner59363a32008-02-19 04:36:25 +00004093 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4094 delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle
4095 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004096 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004097 ;}
4098 break;
4099
Dale Johannesena79ecf32008-02-20 21:15:43 +00004100 case 151:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004101#line 1380 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004102 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004103 // Allow but ignore attributes on function types; this permits auto-upgrade.
4104 // FIXME: remove in LLVM 3.0.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004105 std::vector<const Type*> Params;
Chris Lattner59363a32008-02-19 04:36:25 +00004106 TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004107 for ( ; I != E; ++I ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004108 const Type* Ty = I->Ty->get();
4109 Params.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004110 }
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004111
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004112 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
4113 if (isVarArg) Params.pop_back();
4114
Anton Korobeynikove286f6d2007-12-03 21:01:29 +00004115 for (unsigned i = 0; i != Params.size(); ++i)
4116 if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])))
4117 GEN_ERROR("Function arguments must be value types!");
4118
4119 CHECK_FOR_ERROR
4120
Chris Lattner59363a32008-02-19 04:36:25 +00004121 FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg);
4122 delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list
4123 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004124 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004125 ;}
4126 break;
4127
Dale Johannesena79ecf32008-02-20 21:15:43 +00004128 case 152:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004129#line 1405 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004130 { // Sized array type?
4131 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4132 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004133 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004134 ;}
4135 break;
4136
Dale Johannesena79ecf32008-02-20 21:15:43 +00004137 case 153:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004138#line 1410 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004139 { // Vector type?
4140 const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get();
4141 if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004142 GEN_ERROR("Unsigned result not equal to signed result");
4143 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
4144 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner59363a32008-02-19 04:36:25 +00004145 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val))));
4146 delete (yyvsp[(4) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004147 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004148 ;}
4149 break;
4150
Dale Johannesena79ecf32008-02-20 21:15:43 +00004151 case 154:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004152#line 1420 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004153 { // Structure type?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004154 std::vector<const Type*> Elements;
Chris Lattner59363a32008-02-19 04:36:25 +00004155 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
4156 E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004157 Elements.push_back(*I);
4158
Chris Lattner59363a32008-02-19 04:36:25 +00004159 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
4160 delete (yyvsp[(2) - (3)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004161 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004162 ;}
4163 break;
4164
Dale Johannesena79ecf32008-02-20 21:15:43 +00004165 case 155:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004166#line 1430 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004167 { // Empty structure type?
4168 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004169 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004170 ;}
4171 break;
4172
Dale Johannesena79ecf32008-02-20 21:15:43 +00004173 case 156:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004174#line 1434 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004175 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004176 std::vector<const Type*> Elements;
Chris Lattner59363a32008-02-19 04:36:25 +00004177 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
4178 E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004179 Elements.push_back(*I);
4180
Chris Lattner59363a32008-02-19 04:36:25 +00004181 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
4182 delete (yyvsp[(3) - (5)].TypeList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004183 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004184 ;}
4185 break;
4186
Dale Johannesena79ecf32008-02-20 21:15:43 +00004187 case 157:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004188#line 1444 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004189 { // Empty structure type?
4190 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004191 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004192 ;}
4193 break;
4194
Dale Johannesena79ecf32008-02-20 21:15:43 +00004195 case 158:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004196#line 1451 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004197 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00004198 // Allow but ignore attributes on function types; this permits auto-upgrade.
4199 // FIXME: remove in LLVM 3.0.
Chris Lattner59363a32008-02-19 04:36:25 +00004200 (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal);
4201 (yyval.TypeWithAttrs).Attrs = ParamAttr::None;
4202 ;}
4203 break;
4204
Dale Johannesena79ecf32008-02-20 21:15:43 +00004205 case 159:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004206#line 1460 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004207 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004208 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004209 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription());
Devang Patel3d5a1e862008-02-23 01:17:37 +00004210 if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType() && !isa<StructType>((yyvsp[(1) - (1)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004211 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner59363a32008-02-19 04:36:25 +00004212 (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
4213 ;}
4214 break;
4215
Dale Johannesena79ecf32008-02-20 21:15:43 +00004216 case 160:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004217#line 1467 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004218 {
4219 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
4220 ;}
4221 break;
4222
Dale Johannesena79ecf32008-02-20 21:15:43 +00004223 case 161:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004224#line 1472 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004225 {
4226 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
4227 (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004228 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004229 ;}
4230 break;
4231
Dale Johannesena79ecf32008-02-20 21:15:43 +00004232 case 162:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004233#line 1477 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004234 {
4235 ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004236 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004237 ;}
4238 break;
4239
Dale Johannesena79ecf32008-02-20 21:15:43 +00004240 case 164:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004241#line 1485 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004242 {
4243 (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004244 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4245 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner59363a32008-02-19 04:36:25 +00004246 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004247 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004248 ;}
4249 break;
4250
Dale Johannesena79ecf32008-02-20 21:15:43 +00004251 case 165:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004252#line 1492 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004253 {
4254 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004255 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
4256 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner59363a32008-02-19 04:36:25 +00004257 (yyval.TypeWithAttrsList)->push_back(TWA);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004258 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004259 ;}
4260 break;
4261
Dale Johannesena79ecf32008-02-20 21:15:43 +00004262 case 166:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004263#line 1499 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004264 {
4265 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004266 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004267 ;}
4268 break;
4269
Dale Johannesena79ecf32008-02-20 21:15:43 +00004270 case 167:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004271#line 1507 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004272 {
4273 (yyval.TypeList) = new std::list<PATypeHolder>();
4274 (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal));
4275 delete (yyvsp[(1) - (1)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004276 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004277 ;}
4278 break;
4279
Dale Johannesena79ecf32008-02-20 21:15:43 +00004280 case 168:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004281#line 1513 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004282 {
4283 ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal));
4284 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004285 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004286 ;}
4287 break;
4288
Dale Johannesena79ecf32008-02-20 21:15:43 +00004289 case 169:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004290#line 1525 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004291 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004293 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4294 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004295 if (ATy == 0)
4296 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004297 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004298 const Type *ETy = ATy->getElementType();
4299 int NumElements = ATy->getNumElements();
4300
4301 // Verify that we have the correct size...
Chris Lattner59363a32008-02-19 04:36:25 +00004302 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004303 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner59363a32008-02-19 04:36:25 +00004304 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305 itostr(NumElements) + "");
4306
4307 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00004308 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4309 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004310 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4311 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner59363a32008-02-19 04:36:25 +00004312 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004313 }
4314
Chris Lattner59363a32008-02-19 04:36:25 +00004315 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector));
4316 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004317 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004318 ;}
4319 break;
4320
Dale Johannesena79ecf32008-02-20 21:15:43 +00004321 case 170:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004322#line 1553 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004323 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004324 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004325 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4326 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004327 if (ATy == 0)
4328 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004329 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004330
4331 int NumElements = ATy->getNumElements();
4332 if (NumElements != -1 && NumElements != 0)
4333 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
4334 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner59363a32008-02-19 04:36:25 +00004335 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
4336 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004337 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004338 ;}
4339 break;
4340
Dale Johannesena79ecf32008-02-20 21:15:43 +00004341 case 171:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004342#line 1569 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004343 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004344 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004345 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4346 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004347 if (ATy == 0)
4348 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004349 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004350
4351 int NumElements = ATy->getNumElements();
4352 const Type *ETy = ATy->getElementType();
Chris Lattner59363a32008-02-19 04:36:25 +00004353 if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004354 GEN_ERROR("Can't build string constant of size " +
Chris Lattner59363a32008-02-19 04:36:25 +00004355 itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004356 " when array has size " + itostr(NumElements) + "");
4357 std::vector<Constant*> Vals;
4358 if (ETy == Type::Int8Ty) {
Chris Lattner59363a32008-02-19 04:36:25 +00004359 for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i)
4360 Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i]));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004361 } else {
Chris Lattner59363a32008-02-19 04:36:25 +00004362 delete (yyvsp[(3) - (3)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004363 GEN_ERROR("Cannot build string arrays of non byte sized elements");
4364 }
Chris Lattner59363a32008-02-19 04:36:25 +00004365 delete (yyvsp[(3) - (3)].StrVal);
4366 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
4367 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004369 ;}
4370 break;
4371
Dale Johannesena79ecf32008-02-20 21:15:43 +00004372 case 172:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004373#line 1596 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004374 { // Nonempty unsized arr
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004375 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004376 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
4377 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004378 if (PTy == 0)
4379 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004380 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004381 const Type *ETy = PTy->getElementType();
4382 int NumElements = PTy->getNumElements();
4383
4384 // Verify that we have the correct size...
Chris Lattner59363a32008-02-19 04:36:25 +00004385 if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner59363a32008-02-19 04:36:25 +00004387 utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004388 itostr(NumElements) + "");
4389
4390 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00004391 for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
4392 if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004393 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4394 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner59363a32008-02-19 04:36:25 +00004395 (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004396 }
4397
Chris Lattner59363a32008-02-19 04:36:25 +00004398 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector));
4399 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004400 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004401 ;}
4402 break;
4403
Dale Johannesena79ecf32008-02-20 21:15:43 +00004404 case 173:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004405#line 1624 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004406 {
4407 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004408 if (STy == 0)
4409 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004410 (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004411
Chris Lattner59363a32008-02-19 04:36:25 +00004412 if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004413 GEN_ERROR("Illegal number of initializers for structure type");
4414
4415 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner59363a32008-02-19 04:36:25 +00004416 for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i)
4417 if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004418 GEN_ERROR("Expected type '" +
4419 STy->getElementType(i)->getDescription() +
4420 "' for element #" + utostr(i) +
4421 " of structure initializer");
4422
4423 // Check to ensure that Type is not packed
4424 if (STy->isPacked())
4425 GEN_ERROR("Unpacked Initializer to vector type '" +
4426 STy->getDescription() + "'");
4427
Chris Lattner59363a32008-02-19 04:36:25 +00004428 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector));
4429 delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004430 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004431 ;}
4432 break;
4433
Dale Johannesena79ecf32008-02-20 21:15:43 +00004434 case 174:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004435#line 1650 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004436 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004437 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004438 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
4439 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004440 if (STy == 0)
4441 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004442 (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004443
4444 if (STy->getNumContainedTypes() != 0)
4445 GEN_ERROR("Illegal number of initializers for structure type");
4446
4447 // Check to ensure that Type is not packed
4448 if (STy->isPacked())
4449 GEN_ERROR("Unpacked Initializer to vector type '" +
4450 STy->getDescription() + "'");
4451
Chris Lattner59363a32008-02-19 04:36:25 +00004452 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4453 delete (yyvsp[(1) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004454 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004455 ;}
4456 break;
4457
Dale Johannesena79ecf32008-02-20 21:15:43 +00004458 case 175:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004459#line 1670 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004460 {
4461 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004462 if (STy == 0)
4463 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004464 (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004465
Chris Lattner59363a32008-02-19 04:36:25 +00004466 if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004467 GEN_ERROR("Illegal number of initializers for structure type");
4468
4469 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner59363a32008-02-19 04:36:25 +00004470 for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i)
4471 if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004472 GEN_ERROR("Expected type '" +
4473 STy->getElementType(i)->getDescription() +
4474 "' for element #" + utostr(i) +
4475 " of structure initializer");
4476
4477 // Check to ensure that Type is packed
4478 if (!STy->isPacked())
4479 GEN_ERROR("Vector initializer to non-vector type '" +
4480 STy->getDescription() + "'");
4481
Chris Lattner59363a32008-02-19 04:36:25 +00004482 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector));
4483 delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004484 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004485 ;}
4486 break;
4487
Dale Johannesena79ecf32008-02-20 21:15:43 +00004488 case 176:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004489#line 1696 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004490 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004491 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004492 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription());
4493 const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004494 if (STy == 0)
4495 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004496 (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004497
4498 if (STy->getNumContainedTypes() != 0)
4499 GEN_ERROR("Illegal number of initializers for structure type");
4500
4501 // Check to ensure that Type is packed
4502 if (!STy->isPacked())
4503 GEN_ERROR("Vector initializer to non-vector type '" +
4504 STy->getDescription() + "'");
4505
Chris Lattner59363a32008-02-19 04:36:25 +00004506 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
4507 delete (yyvsp[(1) - (5)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004508 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004509 ;}
4510 break;
4511
Dale Johannesena79ecf32008-02-20 21:15:43 +00004512 case 177:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004513#line 1716 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004514 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004515 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004516 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4517 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004518 if (PTy == 0)
4519 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner59363a32008-02-19 04:36:25 +00004520 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004521
Chris Lattner59363a32008-02-19 04:36:25 +00004522 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
4523 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004524 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004525 ;}
4526 break;
4527
Dale Johannesena79ecf32008-02-20 21:15:43 +00004528 case 178:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004529#line 1728 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004530 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004531 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004532 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4533 (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get());
4534 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004535 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004536 ;}
4537 break;
4538
Dale Johannesena79ecf32008-02-20 21:15:43 +00004539 case 179:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004540#line 1735 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004541 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004542 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4544 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004545 if (Ty == 0)
Devang Patel3b8849c2008-02-19 22:27:01 +00004546 GEN_ERROR("Global const reference must be a pointer type " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004547
4548 // ConstExprs can exist in the body of a function, thus creating
4549 // GlobalValues whenever they refer to a variable. Because we are in
4550 // the context of a function, getExistingVal will search the functions
4551 // symbol table instead of the module symbol table for the global symbol,
4552 // which throws things all off. To get around this, we just tell
4553 // getExistingVal that we are at global scope here.
4554 //
4555 Function *SavedCurFn = CurFun.CurrentFunction;
4556 CurFun.CurrentFunction = 0;
4557
Chris Lattner59363a32008-02-19 04:36:25 +00004558 Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004559 CHECK_FOR_ERROR
4560
4561 CurFun.CurrentFunction = SavedCurFn;
4562
4563 // If this is an initializer for a constant pointer, which is referencing a
4564 // (currently) undefined variable, create a stub now that shall be replaced
4565 // in the future with the right type of variable.
4566 //
4567 if (V == 0) {
4568 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
4569 const PointerType *PT = cast<PointerType>(Ty);
4570
4571 // First check to see if the forward references value is already created!
4572 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner59363a32008-02-19 04:36:25 +00004573 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004574
4575 if (I != CurModule.GlobalRefs.end()) {
4576 V = I->second; // Placeholder already exists, use it...
Chris Lattner59363a32008-02-19 04:36:25 +00004577 (yyvsp[(2) - (2)].ValIDVal).destroy();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004578 } else {
4579 std::string Name;
Chris Lattner59363a32008-02-19 04:36:25 +00004580 if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName)
4581 Name = (yyvsp[(2) - (2)].ValIDVal).getName();
4582 else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004583 GEN_ERROR("Invalid reference to global");
4584
4585 // Create the forward referenced global.
4586 GlobalValue *GV;
4587 if (const FunctionType *FTy =
4588 dyn_cast<FunctionType>(PT->getElementType())) {
4589 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
4590 CurModule.CurrentModule);
4591 } else {
4592 GV = new GlobalVariable(PT->getElementType(), false,
4593 GlobalValue::ExternalWeakLinkage, 0,
4594 Name, CurModule.CurrentModule);
4595 }
4596
4597 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner59363a32008-02-19 04:36:25 +00004598 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004599 V = GV;
4600 }
4601 }
4602
Chris Lattner59363a32008-02-19 04:36:25 +00004603 (yyval.ConstVal) = cast<GlobalValue>(V);
4604 delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004605 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004606 ;}
4607 break;
4608
Dale Johannesena79ecf32008-02-20 21:15:43 +00004609 case 180:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004610#line 1801 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004611 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004612 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004613 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4614 if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004615 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner59363a32008-02-19 04:36:25 +00004616 (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription());
4617 (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
4618 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004619 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004620 ;}
4621 break;
4622
Dale Johannesena79ecf32008-02-20 21:15:43 +00004623 case 181:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004624#line 1811 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004625 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004626 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004627 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
4628 const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004629 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4630 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner59363a32008-02-19 04:36:25 +00004631 (yyval.ConstVal) = Constant::getNullValue(Ty);
4632 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004633 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004634 ;}
4635 break;
4636
Dale Johannesena79ecf32008-02-20 21:15:43 +00004637 case 182:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004638#line 1821 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004639 { // integral constants
4640 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner59363a32008-02-19 04:36:25 +00004642 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004643 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004644 ;}
4645 break;
4646
Dale Johannesena79ecf32008-02-20 21:15:43 +00004647 case 183:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004648#line 1827 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004649 { // arbitrary precision integer constants
4650 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4651 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004652 GEN_ERROR("Constant value does not fit in type");
4653 }
Chris Lattner59363a32008-02-19 04:36:25 +00004654 (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth);
4655 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4656 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004657 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004658 ;}
4659 break;
4660
Dale Johannesena79ecf32008-02-20 21:15:43 +00004661 case 184:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004662#line 1837 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004663 { // integral constants
4664 if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004665 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner59363a32008-02-19 04:36:25 +00004666 (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004667 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004668 ;}
4669 break;
4670
Dale Johannesena79ecf32008-02-20 21:15:43 +00004671 case 185:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004672#line 1843 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004673 { // arbitrary precision integer constants
4674 uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth();
4675 if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004676 GEN_ERROR("Constant value does not fit in type");
4677 }
Chris Lattner59363a32008-02-19 04:36:25 +00004678 (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth);
4679 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal));
4680 delete (yyvsp[(2) - (2)].APIntVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004681 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004682 ;}
4683 break;
4684
Dale Johannesena79ecf32008-02-20 21:15:43 +00004685 case 186:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004686#line 1853 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004687 { // Boolean constants
4688 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4689 (yyval.ConstVal) = ConstantInt::getTrue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004690 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004691 ;}
4692 break;
4693
Dale Johannesena79ecf32008-02-20 21:15:43 +00004694 case 187:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004695#line 1858 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004696 { // Boolean constants
4697 assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?");
4698 (yyval.ConstVal) = ConstantInt::getFalse();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004699 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004700 ;}
4701 break;
4702
Dale Johannesena79ecf32008-02-20 21:15:43 +00004703 case 188:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004704#line 1863 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004705 { // Floating point constants
4706 if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004707 GEN_ERROR("Floating point constant invalid for type");
Dale Johannesen255b8fe2007-09-11 18:33:39 +00004708 // Lexer has no type info, so builds all float and double FP constants
4709 // as double. Fix this here. Long double is done right.
Chris Lattner59363a32008-02-19 04:36:25 +00004710 if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy)
4711 (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4712 (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal));
4713 delete (yyvsp[(2) - (2)].FPVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004714 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004715 ;}
4716 break;
4717
Dale Johannesena79ecf32008-02-20 21:15:43 +00004718 case 189:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004719#line 1876 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004720 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004721 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004722 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription());
4723 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4724 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4725 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004726 GEN_ERROR("invalid cast opcode for cast from '" +
4727 Val->getType()->getDescription() + "' to '" +
4728 DestTy->getDescription() + "'");
Chris Lattner59363a32008-02-19 04:36:25 +00004729 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
4730 delete (yyvsp[(5) - (6)].TypeVal);
4731 ;}
4732 break;
4733
Dale Johannesena79ecf32008-02-20 21:15:43 +00004734 case 190:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004735#line 1888 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004736 {
4737 if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004738 GEN_ERROR("GetElementPtr requires a pointer operand");
4739
4740 const Type *IdxTy =
Chris Lattner59363a32008-02-19 04:36:25 +00004741 GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004742 true);
4743 if (!IdxTy)
4744 GEN_ERROR("Index list invalid for constant getelementptr");
4745
4746 SmallVector<Constant*, 8> IdxVec;
Chris Lattner59363a32008-02-19 04:36:25 +00004747 for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i)
4748 if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i]))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004749 IdxVec.push_back(C);
4750 else
4751 GEN_ERROR("Indices to constant getelementptr must be constants");
4752
Chris Lattner59363a32008-02-19 04:36:25 +00004753 delete (yyvsp[(4) - (5)].ValueList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004754
Chris Lattner59363a32008-02-19 04:36:25 +00004755 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004756 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004757 ;}
4758 break;
4759
Dale Johannesena79ecf32008-02-20 21:15:43 +00004760 case 191:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004761#line 1910 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004762 {
4763 if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004764 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner59363a32008-02-19 04:36:25 +00004765 if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004766 GEN_ERROR("Select operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004767 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004768 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004769 ;}
4770 break;
4771
Dale Johannesena79ecf32008-02-20 21:15:43 +00004772 case 192:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004773#line 1918 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004774 {
4775 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004776 GEN_ERROR("Binary operator types must match");
4777 CHECK_FOR_ERROR;
Chris Lattner59363a32008-02-19 04:36:25 +00004778 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
4779 ;}
4780 break;
4781
Dale Johannesena79ecf32008-02-20 21:15:43 +00004782 case 193:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004783#line 1924 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004784 {
4785 if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004786 GEN_ERROR("Logical operator types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004787 if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) {
4788 if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) ||
4789 !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004790 GEN_ERROR("Logical operator requires integral operands");
4791 }
Chris Lattner59363a32008-02-19 04:36:25 +00004792 (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004793 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004794 ;}
4795 break;
4796
Dale Johannesena79ecf32008-02-20 21:15:43 +00004797 case 194:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004798#line 1935 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004799 {
4800 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004801 GEN_ERROR("icmp operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004802 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4803 ;}
4804 break;
4805
Dale Johannesena79ecf32008-02-20 21:15:43 +00004806 case 195:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004807#line 1940 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004808 {
4809 if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004810 GEN_ERROR("fcmp operand types must match");
Chris Lattner59363a32008-02-19 04:36:25 +00004811 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal));
4812 ;}
4813 break;
4814
Dale Johannesena79ecf32008-02-20 21:15:43 +00004815 case 196:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004816#line 1945 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004817 {
4818 if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004819 GEN_ERROR("Invalid extractelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004820 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004821 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004822 ;}
4823 break;
4824
Dale Johannesena79ecf32008-02-20 21:15:43 +00004825 case 197:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004826#line 1951 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004827 {
4828 if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004829 GEN_ERROR("Invalid insertelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004830 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004831 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004832 ;}
4833 break;
4834
Dale Johannesena79ecf32008-02-20 21:15:43 +00004835 case 198:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004836#line 1957 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004837 {
4838 if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004839 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner59363a32008-02-19 04:36:25 +00004840 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004841 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004842 ;}
4843 break;
4844
Dale Johannesena79ecf32008-02-20 21:15:43 +00004845 case 199:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004846#line 1966 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004847 {
4848 ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004849 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004850 ;}
4851 break;
4852
Dale Johannesena79ecf32008-02-20 21:15:43 +00004853 case 200:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004854#line 1970 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004855 {
4856 (yyval.ConstVector) = new std::vector<Constant*>();
4857 (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004858 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004859 ;}
4860 break;
4861
Dale Johannesena79ecf32008-02-20 21:15:43 +00004862 case 201:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004863#line 1978 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004864 { (yyval.BoolVal) = false; ;}
4865 break;
4866
Chris Lattner59363a32008-02-19 04:36:25 +00004867 case 202:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004868#line 1978 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004869 { (yyval.BoolVal) = true; ;}
4870 break;
4871
4872 case 203:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004873#line 1981 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00004874 { (yyval.BoolVal) = true; ;}
Chris Lattner59363a32008-02-19 04:36:25 +00004875 break;
4876
4877 case 204:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004878#line 1981 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00004879 { (yyval.BoolVal) = false; ;}
4880 break;
4881
4882 case 205:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004883#line 1984 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004884 {
4885 const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get();
4886 Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal));
Chris Lattnerbb856a32007-08-06 21:00:46 +00004887 CHECK_FOR_ERROR
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004888 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4889 if (!Aliasee)
4890 GEN_ERROR("Aliases can be created only to global values");
4891
Chris Lattner59363a32008-02-19 04:36:25 +00004892 (yyval.ConstVal) = Aliasee;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004893 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004894 delete (yyvsp[(1) - (2)].TypeVal);
4895 ;}
4896 break;
4897
Dale Johannesena79ecf32008-02-20 21:15:43 +00004898 case 206:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004899#line 1996 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004900 {
4901 Constant *Val = (yyvsp[(3) - (6)].ConstVal);
4902 const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get();
4903 if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004904 GEN_ERROR("invalid cast opcode for cast from '" +
4905 Val->getType()->getDescription() + "' to '" +
4906 DestTy->getDescription() + "'");
4907
Chris Lattner59363a32008-02-19 04:36:25 +00004908 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004909 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004910 delete (yyvsp[(5) - (6)].TypeVal);
4911 ;}
4912 break;
4913
Chris Lattner59363a32008-02-19 04:36:25 +00004914 case 207:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004915#line 2017 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004916 {
4917 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Christopher Lamb668d9a02007-12-12 08:45:45 +00004918 CurModule.ModuleDone();
4919 CHECK_FOR_ERROR;
Chris Lattner59363a32008-02-19 04:36:25 +00004920 ;}
4921 break;
4922
Dale Johannesena79ecf32008-02-20 21:15:43 +00004923 case 208:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004924#line 2022 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00004925 {
4926 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4927 CurModule.ModuleDone();
4928 CHECK_FOR_ERROR;
4929 ;}
Chris Lattner59363a32008-02-19 04:36:25 +00004930 break;
4931
4932 case 211:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004933#line 2035 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00004934 { CurFun.isDeclare = false; ;}
4935 break;
4936
4937 case 212:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004938#line 2035 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004939 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004940 CurFun.FunctionDone();
4941 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004942 ;}
4943 break;
4944
Dale Johannesena79ecf32008-02-20 21:15:43 +00004945 case 213:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004946#line 2039 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004947 { CurFun.isDeclare = true; ;}
4948 break;
4949
Chris Lattner59363a32008-02-19 04:36:25 +00004950 case 214:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004951#line 2039 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004952 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00004953 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004954 ;}
4955 break;
4956
4957 case 215:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004958#line 2042 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dale Johannesena79ecf32008-02-20 21:15:43 +00004959 {
4960 CHECK_FOR_ERROR
4961 ;}
4962 break;
4963
4964 case 216:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004965#line 2045 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004966 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004967 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00004968 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004969 // Eagerly resolve types. This is not an optimization, this is a
4970 // requirement that is due to the fact that we could have this:
4971 //
4972 // %list = type { %list * }
4973 // %list = type { %list * } ; repeated type decl
4974 //
4975 // If types are not resolved eagerly, then the two types will not be
4976 // determined to be the same type!
4977 //
Chris Lattner59363a32008-02-19 04:36:25 +00004978 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004979
Chris Lattner59363a32008-02-19 04:36:25 +00004980 if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004981 CHECK_FOR_ERROR
4982 // If this is a named type that is not a redefinition, add it to the slot
4983 // table.
Chris Lattner59363a32008-02-19 04:36:25 +00004984 CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004985 }
4986
Chris Lattner59363a32008-02-19 04:36:25 +00004987 delete (yyvsp[(3) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004988 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00004989 ;}
4990 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00004991
Dale Johannesena79ecf32008-02-20 21:15:43 +00004992 case 217:
Nick Lewycky92b80c72008-03-10 05:01:34 +00004993#line 2069 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00004994 {
4995 ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType));
4996
4997 if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004998 CHECK_FOR_ERROR
4999 // If this is a named type that is not a redefinition, add it to the slot
5000 // table.
Chris Lattner59363a32008-02-19 04:36:25 +00005001 CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005002 }
5003 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005004 ;}
5005 break;
5006
Dale Johannesena79ecf32008-02-20 21:15:43 +00005007 case 218:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005008#line 2081 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005009 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005010 /* "Externally Visible" Linkage */
Chris Lattner59363a32008-02-19 04:36:25 +00005011 if ((yyvsp[(5) - (6)].ConstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005012 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner59363a32008-02-19 04:36:25 +00005013 CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage,
5014 (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 +00005015 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005016 ;}
5017 break;
5018
Dale Johannesena79ecf32008-02-20 21:15:43 +00005019 case 219:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005020#line 2088 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005021 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005022 CurGV = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005023 ;}
5024 break;
5025
Dale Johannesena79ecf32008-02-20 21:15:43 +00005026 case 220:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005027#line 2092 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005028 {
5029 if ((yyvsp[(6) - (7)].ConstVal) == 0)
Christopher Lamb668d9a02007-12-12 08:45:45 +00005030 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner59363a32008-02-19 04:36:25 +00005031 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 +00005032 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005033 ;}
5034 break;
5035
Dale Johannesena79ecf32008-02-20 21:15:43 +00005036 case 221:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005037#line 2097 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005038 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005039 CurGV = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005040 ;}
5041 break;
5042
Dale Johannesena79ecf32008-02-20 21:15:43 +00005043 case 222:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005044#line 2101 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005045 {
Christopher Lamb668d9a02007-12-12 08:45:45 +00005046 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005047 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription());
5048 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 +00005049 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005050 delete (yyvsp[(6) - (7)].TypeVal);
5051 ;}
5052 break;
5053
Dale Johannesena79ecf32008-02-20 21:15:43 +00005054 case 223:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005055#line 2107 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005056 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005057 CurGV = 0;
5058 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005059 ;}
5060 break;
5061
Dale Johannesena79ecf32008-02-20 21:15:43 +00005062 case 224:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005063#line 2111 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005064 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005065 std::string Name;
Chris Lattner59363a32008-02-19 04:36:25 +00005066 if ((yyvsp[(1) - (5)].StrVal)) {
5067 Name = *(yyvsp[(1) - (5)].StrVal);
5068 delete (yyvsp[(1) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005069 }
5070 if (Name.empty())
5071 GEN_ERROR("Alias name cannot be empty");
5072
Chris Lattner59363a32008-02-19 04:36:25 +00005073 Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005074 if (Aliasee == 0)
5075 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
5076
Chris Lattner59363a32008-02-19 04:36:25 +00005077 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005078 CurModule.CurrentModule);
Chris Lattner59363a32008-02-19 04:36:25 +00005079 GA->setVisibility((yyvsp[(2) - (5)].Visibility));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005080 InsertValue(GA, CurModule.Values);
Chris Lattner5eefce32007-09-10 23:24:14 +00005081
5082
5083 // If there was a forward reference of this alias, resolve it now.
5084
5085 ValID ID;
5086 if (!Name.empty())
5087 ID = ValID::createGlobalName(Name);
5088 else
5089 ID = ValID::createGlobalID(CurModule.Values.size()-1);
5090
5091 if (GlobalValue *FWGV =
5092 CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
5093 // Replace uses of the fwdref with the actual alias.
5094 FWGV->replaceAllUsesWith(GA);
5095 if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
5096 GV->eraseFromParent();
5097 else
5098 cast<Function>(FWGV)->eraseFromParent();
5099 }
5100 ID.destroy();
5101
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005102 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005103 ;}
5104 break;
5105
Dale Johannesena79ecf32008-02-20 21:15:43 +00005106 case 225:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005107#line 2151 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005108 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005109 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005110 ;}
5111 break;
5112
Dale Johannesena79ecf32008-02-20 21:15:43 +00005113 case 226:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005114#line 2154 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005115 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005116 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005117 ;}
5118 break;
5119
Dale Johannesena79ecf32008-02-20 21:15:43 +00005120 case 227:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005121#line 2160 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005122 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005123 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
5124 if (AsmSoFar.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005125 CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005126 else
Chris Lattner59363a32008-02-19 04:36:25 +00005127 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal));
5128 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005129 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005130;}
5131 break;
5132
Dale Johannesena79ecf32008-02-20 21:15:43 +00005133 case 228:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005134#line 2170 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005135 {
5136 CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal));
5137 delete (yyvsp[(3) - (3)].StrVal);
5138 ;}
5139 break;
5140
Dale Johannesena79ecf32008-02-20 21:15:43 +00005141 case 229:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005142#line 2174 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005143 {
5144 CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal));
5145 delete (yyvsp[(3) - (3)].StrVal);
5146 ;}
5147 break;
5148
Dale Johannesena79ecf32008-02-20 21:15:43 +00005149 case 231:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005150#line 2181 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005151 {
5152 CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal));
5153 delete (yyvsp[(3) - (3)].StrVal);
Christopher Lamb668d9a02007-12-12 08:45:45 +00005154 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005155 ;}
5156 break;
5157
Dale Johannesena79ecf32008-02-20 21:15:43 +00005158 case 232:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005159#line 2186 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005160 {
5161 CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal));
5162 delete (yyvsp[(1) - (1)].StrVal);
Reid Spencer47470022007-07-31 14:41:17 +00005163 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005164 ;}
5165 break;
5166
Dale Johannesena79ecf32008-02-20 21:15:43 +00005167 case 233:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005168#line 2191 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005169 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005170 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005171 ;}
5172 break;
5173
Dale Johannesena79ecf32008-02-20 21:15:43 +00005174 case 234:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005175#line 2200 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005176 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005177 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005178 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
5179 if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005180 GEN_ERROR("void typed arguments are invalid");
Chris Lattner59363a32008-02-19 04:36:25 +00005181 ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal);
5182 (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList);
5183 (yyvsp[(1) - (5)].ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005184 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005185 ;}
5186 break;
5187
Dale Johannesena79ecf32008-02-20 21:15:43 +00005188 case 235:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005189#line 2210 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005190 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005191 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005192 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription());
5193 if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005194 GEN_ERROR("void typed arguments are invalid");
Chris Lattner59363a32008-02-19 04:36:25 +00005195 ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal);
5196 (yyval.ArgList) = new ArgListType;
5197 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005198 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005199 ;}
5200 break;
5201
Dale Johannesena79ecf32008-02-20 21:15:43 +00005202 case 236:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005203#line 2221 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005204 {
5205 (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005206 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005207 ;}
5208 break;
5209
Dale Johannesena79ecf32008-02-20 21:15:43 +00005210 case 237:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005211#line 2225 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005212 {
5213 (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005214 struct ArgListEntry E;
5215 E.Ty = new PATypeHolder(Type::VoidTy);
5216 E.Name = 0;
5217 E.Attrs = ParamAttr::None;
Chris Lattner59363a32008-02-19 04:36:25 +00005218 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005219 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005220 ;}
5221 break;
5222
Dale Johannesena79ecf32008-02-20 21:15:43 +00005223 case 238:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005224#line 2234 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005225 {
5226 (yyval.ArgList) = new ArgListType;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005227 struct ArgListEntry E;
5228 E.Ty = new PATypeHolder(Type::VoidTy);
5229 E.Name = 0;
5230 E.Attrs = ParamAttr::None;
Chris Lattner59363a32008-02-19 04:36:25 +00005231 (yyval.ArgList)->push_back(E);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005232 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005233 ;}
5234 break;
5235
Dale Johannesena79ecf32008-02-20 21:15:43 +00005236 case 239:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005237#line 2243 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005238 {
5239 (yyval.ArgList) = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005240 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005241 ;}
5242 break;
5243
Dale Johannesena79ecf32008-02-20 21:15:43 +00005244 case 240:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005245#line 2249 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005246 {
5247 std::string FunctionName(*(yyvsp[(3) - (10)].StrVal));
5248 delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory!
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005249
5250 // Check the function result for abstractness if this is a define. We should
5251 // have no abstract types at this point
Chris Lattner59363a32008-02-19 04:36:25 +00005252 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal)))
5253 GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005254
5255 std::vector<const Type*> ParamTypeList;
5256 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00005257 if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005258 ParamAttrsWithIndex PAWI;
5259 PAWI.index = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005260 PAWI.attrs = (yyvsp[(7) - (10)].ParamAttrs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005261 Attrs.push_back(PAWI);
5262 }
Chris Lattner59363a32008-02-19 04:36:25 +00005263 if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005264 unsigned index = 1;
Chris Lattner59363a32008-02-19 04:36:25 +00005265 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005266 const Type* Ty = I->Ty->get();
5267 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
5268 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
5269 ParamTypeList.push_back(Ty);
5270 if (Ty != Type::VoidTy)
5271 if (I->Attrs != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005272 ParamAttrsWithIndex PAWI;
5273 PAWI.index = index;
5274 PAWI.attrs = I->Attrs;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005275 Attrs.push_back(PAWI);
5276 }
5277 }
5278 }
5279
5280 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
5281 if (isVarArg) ParamTypeList.pop_back();
5282
Duncan Sands637ec552007-11-28 17:07:01 +00005283 const ParamAttrsList *PAL = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005284 if (!Attrs.empty())
5285 PAL = ParamAttrsList::get(Attrs);
5286
Chris Lattner59363a32008-02-19 04:36:25 +00005287 FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg);
Christopher Lambfb623c62007-12-17 01:17:35 +00005288 const PointerType *PFT = PointerType::getUnqual(FT);
Chris Lattner59363a32008-02-19 04:36:25 +00005289 delete (yyvsp[(2) - (10)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005290
5291 ValID ID;
5292 if (!FunctionName.empty()) {
5293 ID = ValID::createGlobalName((char*)FunctionName.c_str());
5294 } else {
5295 ID = ValID::createGlobalID(CurModule.Values.size());
5296 }
5297
5298 Function *Fn = 0;
5299 // See if this function was forward referenced. If so, recycle the object.
5300 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
5301 // Move the function to the end of the list, from whereever it was
5302 // previously inserted.
5303 Fn = cast<Function>(FWRef);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005304 assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005305 CurModule.CurrentModule->getFunctionList().remove(Fn);
5306 CurModule.CurrentModule->getFunctionList().push_back(Fn);
5307 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
5308 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005309 if (Fn->getFunctionType() != FT ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005310 // The existing function doesn't have the same type. This is an overload
5311 // error.
5312 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005313 } else if (Fn->getParamAttrs() != PAL) {
5314 // The existing function doesn't have the same parameter attributes.
5315 // This is an overload error.
5316 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005317 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
5318 // Neither the existing or the current function is a declaration and they
5319 // have the same name and same type. Clearly this is a redefinition.
5320 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005321 } else if (Fn->isDeclaration()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005322 // Make sure to strip off any argument names so we can't get conflicts.
5323 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
5324 AI != AE; ++AI)
5325 AI->setName("");
5326 }
5327 } else { // Not already defined?
5328 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
5329 CurModule.CurrentModule);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005330 InsertValue(Fn, CurModule.Values);
5331 }
5332
5333 CurFun.FunctionStart(Fn);
5334
5335 if (CurFun.isDeclare) {
5336 // If we have declaration, always overwrite linkage. This will allow us to
5337 // correctly handle cases, when pointer to function is passed as argument to
5338 // another function.
5339 Fn->setLinkage(CurFun.Linkage);
5340 Fn->setVisibility(CurFun.Visibility);
5341 }
Chris Lattner59363a32008-02-19 04:36:25 +00005342 Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005343 Fn->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00005344 Fn->setAlignment((yyvsp[(9) - (10)].UIntVal));
5345 if ((yyvsp[(8) - (10)].StrVal)) {
5346 Fn->setSection(*(yyvsp[(8) - (10)].StrVal));
5347 delete (yyvsp[(8) - (10)].StrVal);
Gordon Henriksen13fe5e32007-12-10 03:18:06 +00005348 }
Chris Lattner59363a32008-02-19 04:36:25 +00005349 if ((yyvsp[(10) - (10)].StrVal)) {
5350 Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str());
5351 delete (yyvsp[(10) - (10)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005352 }
5353
5354 // Add all of the arguments we parsed to the function...
Chris Lattner59363a32008-02-19 04:36:25 +00005355 if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005356 if (isVarArg) { // Nuke the last entry
Chris Lattner59363a32008-02-19 04:36:25 +00005357 assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005358 "Not a varargs marker!");
Chris Lattner59363a32008-02-19 04:36:25 +00005359 delete (yyvsp[(5) - (10)].ArgList)->back().Ty;
5360 (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005361 }
5362 Function::arg_iterator ArgIt = Fn->arg_begin();
5363 Function::arg_iterator ArgEnd = Fn->arg_end();
5364 unsigned Idx = 1;
Chris Lattner59363a32008-02-19 04:36:25 +00005365 for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin();
5366 I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005367 delete I->Ty; // Delete the typeholder...
5368 setValueName(ArgIt, I->Name); // Insert arg into symtab...
5369 CHECK_FOR_ERROR
5370 InsertValue(ArgIt);
5371 Idx++;
5372 }
5373
Chris Lattner59363a32008-02-19 04:36:25 +00005374 delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005375 }
5376 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005377;}
5378 break;
5379
Dale Johannesena79ecf32008-02-20 21:15:43 +00005380 case 243:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005381#line 2384 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005382 {
5383 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005384
5385 // Make sure that we keep track of the linkage type even if there was a
5386 // previous "declare".
Chris Lattner59363a32008-02-19 04:36:25 +00005387 (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
5388 (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility));
5389;}
5390 break;
5391
Dale Johannesena79ecf32008-02-20 21:15:43 +00005392 case 246:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005393#line 2395 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005394 {
5395 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005396 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005397;}
5398 break;
5399
Dale Johannesena79ecf32008-02-20 21:15:43 +00005400 case 247:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005401#line 2400 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005402 {
5403 CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage));
5404 CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility));
5405 (yyval.FunctionVal) = CurFun.CurrentFunction;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005406 CurFun.FunctionDone();
5407 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005408 ;}
5409 break;
5410
Dale Johannesena79ecf32008-02-20 21:15:43 +00005411 case 248:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005412#line 2412 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005413 {
5414 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005415 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005416 ;}
5417 break;
5418
Dale Johannesena79ecf32008-02-20 21:15:43 +00005419 case 249:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005420#line 2416 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005421 {
5422 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005423 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005424 ;}
5425 break;
5426
Dale Johannesena79ecf32008-02-20 21:15:43 +00005427 case 250:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005428#line 2421 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005429 { // A reference to a direct constant
5430 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005431 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005432 ;}
5433 break;
5434
Dale Johannesena79ecf32008-02-20 21:15:43 +00005435 case 251:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005436#line 2425 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005437 {
5438 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005439 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005440 ;}
5441 break;
5442
Dale Johannesena79ecf32008-02-20 21:15:43 +00005443 case 252:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005444#line 2429 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005445 { // Perhaps it's an FP constant?
5446 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005447 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005448 ;}
5449 break;
5450
Dale Johannesena79ecf32008-02-20 21:15:43 +00005451 case 253:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005452#line 2433 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005453 {
5454 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005455 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005456 ;}
5457 break;
5458
Dale Johannesena79ecf32008-02-20 21:15:43 +00005459 case 254:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005460#line 2437 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005461 {
5462 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005463 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005464 ;}
5465 break;
5466
Dale Johannesena79ecf32008-02-20 21:15:43 +00005467 case 255:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005468#line 2441 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005469 {
5470 (yyval.ValIDVal) = ValID::createNull();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005471 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005472 ;}
5473 break;
5474
Dale Johannesena79ecf32008-02-20 21:15:43 +00005475 case 256:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005476#line 2445 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005477 {
5478 (yyval.ValIDVal) = ValID::createUndef();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005479 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005480 ;}
5481 break;
5482
Dale Johannesena79ecf32008-02-20 21:15:43 +00005483 case 257:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005484#line 2449 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005485 { // A vector zero constant.
5486 (yyval.ValIDVal) = ValID::createZeroInit();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005487 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005488 ;}
5489 break;
5490
Dale Johannesena79ecf32008-02-20 21:15:43 +00005491 case 258:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005492#line 2453 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005493 { // Nonempty unsized packed vector
5494 const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType();
5495 int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005496
5497 VectorType* pt = VectorType::get(ETy, NumElements);
5498 PATypeHolder* PTy = new PATypeHolder(
5499 HandleUpRefs(
5500 VectorType::get(
5501 ETy,
5502 NumElements)
5503 )
5504 );
5505
5506 // Verify all elements are correct type!
Chris Lattner59363a32008-02-19 04:36:25 +00005507 for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
5508 if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005509 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
5510 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner59363a32008-02-19 04:36:25 +00005511 (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'.");
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005512 }
5513
Chris Lattner59363a32008-02-19 04:36:25 +00005514 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector)));
5515 delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005516 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005517 ;}
5518 break;
5519
Dale Johannesena79ecf32008-02-20 21:15:43 +00005520 case 259:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005521#line 2478 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005522 {
5523 (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005524 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005525 ;}
5526 break;
5527
Dale Johannesena79ecf32008-02-20 21:15:43 +00005528 case 260:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005529#line 2482 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005530 {
5531 (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal));
5532 delete (yyvsp[(3) - (5)].StrVal);
5533 delete (yyvsp[(5) - (5)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005534 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005535 ;}
5536 break;
5537
Dale Johannesena79ecf32008-02-20 21:15:43 +00005538 case 261:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005539#line 2492 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005540 { // Is it an integer reference...?
5541 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005542 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005543 ;}
5544 break;
5545
Dale Johannesena79ecf32008-02-20 21:15:43 +00005546 case 262:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005547#line 2496 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005548 {
5549 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005550 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005551 ;}
5552 break;
5553
Dale Johannesena79ecf32008-02-20 21:15:43 +00005554 case 263:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005555#line 2500 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005556 { // Is it a named reference...?
5557 (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal));
5558 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005559 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005560 ;}
5561 break;
5562
Dale Johannesena79ecf32008-02-20 21:15:43 +00005563 case 264:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005564#line 2505 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005565 { // Is it a named reference...?
5566 (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal));
5567 delete (yyvsp[(1) - (1)].StrVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005568 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005569 ;}
5570 break;
5571
Dale Johannesena79ecf32008-02-20 21:15:43 +00005572 case 267:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005573#line 2518 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005574 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005575 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005576 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription());
5577 (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal));
5578 delete (yyvsp[(1) - (2)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005579 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005580 ;}
5581 break;
5582
Dale Johannesena79ecf32008-02-20 21:15:43 +00005583 case 268:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005584#line 2527 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patelbf507402008-02-20 22:40:23 +00005585 {
5586 (yyval.ValueList) = new std::vector<Value *>();
5587 (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
5588 CHECK_FOR_ERROR
5589 ;}
5590 break;
5591
5592 case 269:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005593#line 2532 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patelbf507402008-02-20 22:40:23 +00005594 {
Devang Patel087fe2b2008-02-23 00:38:56 +00005595 ((yyval.ValueList)=(yyvsp[(1) - (3)].ValueList))->push_back((yyvsp[(3) - (3)].ValueVal));
Devang Patelbf507402008-02-20 22:40:23 +00005596 CHECK_FOR_ERROR
5597 ;}
5598 break;
5599
5600 case 270:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005601#line 2537 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005602 {
5603 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005604 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005605 ;}
5606 break;
5607
Devang Patelbf507402008-02-20 22:40:23 +00005608 case 271:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005609#line 2541 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005610 { // Do not allow functions with 0 basic blocks
5611 (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005612 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005613 ;}
5614 break;
5615
Devang Patelbf507402008-02-20 22:40:23 +00005616 case 272:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005617#line 2550 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005618 {
5619 setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005620 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005621 InsertValue((yyvsp[(3) - (3)].TermInstVal));
5622 (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal));
5623 (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005624 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005625 ;}
5626 break;
5627
Devang Patelbf507402008-02-20 22:40:23 +00005628 case 273:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005629#line 2559 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005630 {
5631 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005632 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5633 if (CI2->getParent() == 0)
Chris Lattner59363a32008-02-19 04:36:25 +00005634 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2);
5635 (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal));
5636 (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005637 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005638 ;}
5639 break;
5640
Devang Patelbf507402008-02-20 22:40:23 +00005641 case 274:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005642#line 2568 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005643 { // Empty space between instruction lists
Devang Patel890cc572008-03-03 18:58:47 +00005644 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), 0);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005645 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005646 ;}
5647 break;
5648
Devang Patelbf507402008-02-20 22:40:23 +00005649 case 275:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005650#line 2572 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patel890cc572008-03-03 18:58:47 +00005651 { // Only the unwind to block
Nick Lewycky92b80c72008-03-10 05:01:34 +00005652 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum), getBBVal((yyvsp[(3) - (3)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005653 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005654 ;}
5655 break;
Reid Spenceraa8ae282007-07-31 03:50:36 +00005656
Devang Patelbf507402008-02-20 22:40:23 +00005657 case 276:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005658#line 2576 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patel890cc572008-03-03 18:58:47 +00005659 { // Labelled (named) basic block
5660 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)), 0);
5661 delete (yyvsp[(1) - (1)].StrVal);
5662 CHECK_FOR_ERROR
5663 ;}
5664 break;
5665
5666 case 277:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005667#line 2581 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patel890cc572008-03-03 18:58:47 +00005668 {
Nick Lewycky92b80c72008-03-10 05:01:34 +00005669 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (4)].StrVal)), getBBVal((yyvsp[(4) - (4)].ValIDVal)));
5670 delete (yyvsp[(1) - (4)].StrVal);
Devang Patel890cc572008-03-03 18:58:47 +00005671 CHECK_FOR_ERROR
5672 ;}
5673 break;
5674
5675 case 278:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005676#line 2588 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patelbf507402008-02-20 22:40:23 +00005677 { // Return with a result...
Devang Patelda2c8d52008-02-26 22:17:48 +00005678 ValueList &VL = *(yyvsp[(2) - (2)].ValueList);
Devang Patelb4851dc2008-02-26 23:19:08 +00005679 assert(!VL.empty() && "Invalid ret operands!");
5680 (yyval.TermInstVal) = new ReturnInst(&VL[0], VL.size());
Devang Patelbf507402008-02-20 22:40:23 +00005681 delete (yyvsp[(2) - (2)].ValueList);
Chris Lattner59363a32008-02-19 04:36:25 +00005682 CHECK_FOR_ERROR
5683 ;}
5684 break;
5685
Devang Patel890cc572008-03-03 18:58:47 +00005686 case 279:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005687#line 2595 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005688 { // Return with no result...
5689 (yyval.TermInstVal) = new ReturnInst();
5690 CHECK_FOR_ERROR
5691 ;}
5692 break;
5693
Devang Patel890cc572008-03-03 18:58:47 +00005694 case 280:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005695#line 2599 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005696 { // Unconditional Branch...
5697 BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
5698 CHECK_FOR_ERROR
5699 (yyval.TermInstVal) = new BranchInst(tmpBB);
5700 ;}
5701 break;
5702
Devang Patel890cc572008-03-03 18:58:47 +00005703 case 281:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005704#line 2604 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005705 {
5706 assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?");
5707 BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5708 CHECK_FOR_ERROR
5709 BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
5710 CHECK_FOR_ERROR
5711 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
5712 CHECK_FOR_ERROR
5713 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5714 ;}
5715 break;
5716
Devang Patel890cc572008-03-03 18:58:47 +00005717 case 282:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005718#line 2614 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005719 {
5720 Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal));
5721 CHECK_FOR_ERROR
5722 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
5723 CHECK_FOR_ERROR
5724 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
5725 (yyval.TermInstVal) = S;
5726
5727 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
5728 E = (yyvsp[(8) - (9)].JumpTable)->end();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005729 for (; I != E; ++I) {
5730 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5731 S->addCase(CI, I->second);
5732 else
5733 GEN_ERROR("Switch case is constant, but not a simple integer");
5734 }
Chris Lattner59363a32008-02-19 04:36:25 +00005735 delete (yyvsp[(8) - (9)].JumpTable);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005736 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005737 ;}
5738 break;
5739
Devang Patel890cc572008-03-03 18:58:47 +00005740 case 283:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005741#line 2633 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005742 {
5743 Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005744 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005745 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005746 CHECK_FOR_ERROR
5747 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner59363a32008-02-19 04:36:25 +00005748 (yyval.TermInstVal) = S;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005749 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005750 ;}
5751 break;
5752
Devang Patel890cc572008-03-03 18:58:47 +00005753 case 284:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005754#line 2643 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005755 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005756
5757 // Handle the short syntax
5758 const PointerType *PFTy = 0;
5759 const FunctionType *Ty = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00005760 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005761 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5762 // Pull out the types of all of the arguments...
5763 std::vector<const Type*> ParamTypes;
Chris Lattner59363a32008-02-19 04:36:25 +00005764 ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005765 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005766 const Type *Ty = I->Val->getType();
5767 if (Ty == Type::VoidTy)
5768 GEN_ERROR("Short call syntax cannot be used with varargs");
5769 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005770 }
Chris Lattner59363a32008-02-19 04:36:25 +00005771 Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00005772 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005773 }
5774
Chris Lattner59363a32008-02-19 04:36:25 +00005775 delete (yyvsp[(3) - (14)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005776
Chris Lattner59363a32008-02-19 04:36:25 +00005777 Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005778 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005779 BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005780 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005781 BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005782 CHECK_FOR_ERROR
5783
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005784 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00005785 if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) {
5786 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005787 Attrs.push_back(PAWI);
5788 }
5789
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005790 // Check the arguments
5791 ValueList Args;
Chris Lattner59363a32008-02-19 04:36:25 +00005792 if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005793 // Make sure no arguments is a good thing!
5794 if (Ty->getNumParams() != 0)
5795 GEN_ERROR("No arguments passed to a function that "
5796 "expects arguments");
5797 } else { // Has arguments?
5798 // Loop through FunctionType's arguments and ensure they are specified
5799 // correctly!
5800 FunctionType::param_iterator I = Ty->param_begin();
5801 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner59363a32008-02-19 04:36:25 +00005802 ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005803 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005804
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005805 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005806 if (ArgI->Val->getType() != *I)
5807 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
5808 (*I)->getDescription() + "'");
5809 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005810 if (ArgI->Attrs != ParamAttr::None) {
5811 ParamAttrsWithIndex PAWI;
5812 PAWI.index = index;
5813 PAWI.attrs = ArgI->Attrs;
5814 Attrs.push_back(PAWI);
5815 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005816 }
5817
5818 if (Ty->isVarArg()) {
5819 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00005820 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005821 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner59363a32008-02-19 04:36:25 +00005822 if (ArgI->Attrs != ParamAttr::None) {
5823 ParamAttrsWithIndex PAWI;
5824 PAWI.index = index;
5825 PAWI.attrs = ArgI->Attrs;
5826 Attrs.push_back(PAWI);
5827 }
5828 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005829 } else if (I != E || ArgI != ArgE)
5830 GEN_ERROR("Invalid number of parameters detected");
5831 }
5832
Duncan Sands637ec552007-11-28 17:07:01 +00005833 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005834 if (!Attrs.empty())
5835 PAL = ParamAttrsList::get(Attrs);
5836
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005837 // Create the InvokeInst
Chris Lattnerd140ada2007-08-29 16:15:23 +00005838 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattner59363a32008-02-19 04:36:25 +00005839 II->setCallingConv((yyvsp[(2) - (14)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005840 II->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00005841 (yyval.TermInstVal) = II;
5842 delete (yyvsp[(6) - (14)].ParamList);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005843 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005844 ;}
5845 break;
5846
Devang Patel890cc572008-03-03 18:58:47 +00005847 case 285:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005848#line 2733 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005849 {
5850 (yyval.TermInstVal) = new UnwindInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005851 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005852 ;}
5853 break;
5854
Devang Patel890cc572008-03-03 18:58:47 +00005855 case 286:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005856#line 2737 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005857 {
5858 (yyval.TermInstVal) = new UnreachableInst();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005859 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005860 ;}
5861 break;
5862
Devang Patel890cc572008-03-03 18:58:47 +00005863 case 287:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005864#line 2744 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005865 {
5866 (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
5867 Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005868 CHECK_FOR_ERROR
5869 if (V == 0)
5870 GEN_ERROR("May only switch on a constant pool value");
5871
Chris Lattner59363a32008-02-19 04:36:25 +00005872 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005873 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005874 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5875 ;}
5876 break;
5877
Devang Patel890cc572008-03-03 18:58:47 +00005878 case 288:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005879#line 2755 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005880 {
5881 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5882 Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal)));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005883 CHECK_FOR_ERROR
5884
5885 if (V == 0)
5886 GEN_ERROR("May only switch on a constant pool value");
5887
Chris Lattner59363a32008-02-19 04:36:25 +00005888 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005889 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005890 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5891 ;}
5892 break;
5893
Devang Patel890cc572008-03-03 18:58:47 +00005894 case 289:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005895#line 2768 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005896 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005897 // Is this definition named?? if so, assign the name...
Chris Lattner59363a32008-02-19 04:36:25 +00005898 setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005899 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005900 InsertValue((yyvsp[(2) - (2)].InstVal));
5901 (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005902 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005903 ;}
5904 break;
5905
Devang Patel890cc572008-03-03 18:58:47 +00005906 case 290:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005907#line 2778 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005908 { // Used for PHI nodes
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005909 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005910 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription());
5911 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5912 Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005913 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005914 BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005915 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005916 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5917 delete (yyvsp[(1) - (6)].TypeVal);
5918 ;}
5919 break;
5920
Devang Patel890cc572008-03-03 18:58:47 +00005921 case 291:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005922#line 2789 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005923 {
5924 (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
5925 Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005926 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005927 BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005928 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005929 (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5930 ;}
5931 break;
5932
Devang Patel890cc572008-03-03 18:58:47 +00005933 case 292:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005934#line 2799 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005935 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005936 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005937 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005938 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005939 // Used for call and invoke instructions
Chris Lattner59363a32008-02-19 04:36:25 +00005940 (yyval.ParamList) = new ParamList();
5941 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal));
5942 (yyval.ParamList)->push_back(E);
5943 delete (yyvsp[(1) - (4)].TypeVal);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005944 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005945 ;}
5946 break;
5947
Devang Patel890cc572008-03-03 18:58:47 +00005948 case 293:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005949#line 2810 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005950 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005951 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dale Johannesencfb19e62007-11-05 21:20:28 +00005952 // Labels are only valid in ASMs
Chris Lattner59363a32008-02-19 04:36:25 +00005953 (yyval.ParamList) = new ParamList();
5954 ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal));
5955 (yyval.ParamList)->push_back(E);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005956 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005957 ;}
5958 break;
5959
Devang Patel890cc572008-03-03 18:58:47 +00005960 case 294:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005961#line 2818 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005962 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005963 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005964 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00005965 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
5966 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5967 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal));
5968 (yyval.ParamList)->push_back(E);
5969 delete (yyvsp[(3) - (6)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005970 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005971 ;}
5972 break;
5973
Devang Patel890cc572008-03-03 18:58:47 +00005974 case 295:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005975#line 2828 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005976 {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00005977 // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0
Chris Lattner59363a32008-02-19 04:36:25 +00005978 (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList);
5979 ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal));
5980 (yyval.ParamList)->push_back(E);
Dale Johannesencfb19e62007-11-05 21:20:28 +00005981 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00005982 ;}
5983 break;
5984
Devang Patel890cc572008-03-03 18:58:47 +00005985 case 296:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005986#line 2835 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005987 { (yyval.ParamList) = new ParamList(); ;}
5988 break;
5989
Devang Patel890cc572008-03-03 18:58:47 +00005990 case 297:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005991#line 2838 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005992 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5993 break;
5994
Devang Patel890cc572008-03-03 18:58:47 +00005995 case 298:
Nick Lewycky92b80c72008-03-10 05:01:34 +00005996#line 2839 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00005997 {
5998 (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
5999 (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006000 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006001 ;}
6002 break;
6003
Devang Patel890cc572008-03-03 18:58:47 +00006004 case 299:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006005#line 2846 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006006 {
6007 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006008 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006009 ;}
6010 break;
6011
Devang Patel890cc572008-03-03 18:58:47 +00006012 case 300:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006013#line 2850 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006014 {
6015 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006016 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006017 ;}
6018 break;
6019
Devang Patel890cc572008-03-03 18:58:47 +00006020 case 301:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006021#line 2855 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006022 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006023 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006024 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6025 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() &&
6026 !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006027 GEN_ERROR(
6028 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006029 Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006030 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006031 Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006032 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006033 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2);
6034 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006035 GEN_ERROR("binary operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006036 delete (yyvsp[(2) - (5)].TypeVal);
6037 ;}
6038 break;
6039
Devang Patel890cc572008-03-03 18:58:47 +00006040 case 302:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006041#line 2871 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006042 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006043 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006044 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription());
6045 if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) {
6046 if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) ||
6047 !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006048 GEN_ERROR("Logical operator requires integral operands");
6049 }
Chris Lattner59363a32008-02-19 04:36:25 +00006050 Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006051 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006052 Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006053 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006054 (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2);
6055 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006056 GEN_ERROR("binary operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006057 delete (yyvsp[(2) - (5)].TypeVal);
6058 ;}
6059 break;
6060
Devang Patel890cc572008-03-03 18:58:47 +00006061 case 303:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006062#line 2888 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006063 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006064 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006065 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6066 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006067 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner59363a32008-02-19 04:36:25 +00006068 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006069 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006070 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006071 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006072 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2);
6073 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006074 GEN_ERROR("icmp operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006075 delete (yyvsp[(3) - (6)].TypeVal);
6076 ;}
6077 break;
6078
Devang Patel890cc572008-03-03 18:58:47 +00006079 case 304:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006080#line 2902 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006081 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006082 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006083 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription());
6084 if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006085 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner59363a32008-02-19 04:36:25 +00006086 Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006087 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006088 Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006089 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006090 (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2);
6091 if ((yyval.InstVal) == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006092 GEN_ERROR("fcmp operator returned null");
Chris Lattner59363a32008-02-19 04:36:25 +00006093 delete (yyvsp[(3) - (6)].TypeVal);
6094 ;}
6095 break;
6096
Devang Patel890cc572008-03-03 18:58:47 +00006097 case 305:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006098#line 2916 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006099 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006100 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006101 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6102 Value* Val = (yyvsp[(2) - (4)].ValueVal);
6103 const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get();
6104 if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006105 GEN_ERROR("invalid cast opcode for cast from '" +
6106 Val->getType()->getDescription() + "' to '" +
6107 DestTy->getDescription() + "'");
Chris Lattner59363a32008-02-19 04:36:25 +00006108 (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy);
6109 delete (yyvsp[(4) - (4)].TypeVal);
6110 ;}
6111 break;
6112
Devang Patel890cc572008-03-03 18:58:47 +00006113 case 306:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006114#line 2928 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006115 {
6116 if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006117 GEN_ERROR("select condition must be boolean");
Chris Lattner59363a32008-02-19 04:36:25 +00006118 if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006119 GEN_ERROR("select value types should match");
Chris Lattner59363a32008-02-19 04:36:25 +00006120 (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006121 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006122 ;}
6123 break;
6124
Devang Patel890cc572008-03-03 18:58:47 +00006125 case 307:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006126#line 2936 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006127 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006128 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006129 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription());
6130 (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal));
6131 delete (yyvsp[(4) - (4)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006132 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006133 ;}
6134 break;
6135
Devang Patel890cc572008-03-03 18:58:47 +00006136 case 308:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006137#line 2943 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006138 {
6139 if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006140 GEN_ERROR("Invalid extractelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006141 (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006142 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006143 ;}
6144 break;
6145
Devang Patel890cc572008-03-03 18:58:47 +00006146 case 309:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006147#line 2949 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006148 {
6149 if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006150 GEN_ERROR("Invalid insertelement operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006151 (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006152 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006153 ;}
6154 break;
6155
Devang Patel890cc572008-03-03 18:58:47 +00006156 case 310:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006157#line 2955 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006158 {
6159 if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006160 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner59363a32008-02-19 04:36:25 +00006161 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006162 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006163 ;}
6164 break;
6165
Devang Patel890cc572008-03-03 18:58:47 +00006166 case 311:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006167#line 2961 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006168 {
6169 const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006170 if (!Ty->isFirstClassType())
6171 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner59363a32008-02-19 04:36:25 +00006172 (yyval.InstVal) = new PHINode(Ty);
6173 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size());
6174 while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) {
6175 if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006176 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner59363a32008-02-19 04:36:25 +00006177 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second);
6178 (yyvsp[(2) - (2)].PHIList)->pop_front();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006179 }
Chris Lattner59363a32008-02-19 04:36:25 +00006180 delete (yyvsp[(2) - (2)].PHIList); // Free the list...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006181 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006182 ;}
6183 break;
6184
Devang Patel890cc572008-03-03 18:58:47 +00006185 case 312:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006186#line 2977 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006187 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006188
6189 // Handle the short syntax
6190 const PointerType *PFTy = 0;
6191 const FunctionType *Ty = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00006192 if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) ||
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006193 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
6194 // Pull out the types of all of the arguments...
6195 std::vector<const Type*> ParamTypes;
Chris Lattner59363a32008-02-19 04:36:25 +00006196 ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006197 for (; I != E; ++I) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006198 const Type *Ty = I->Val->getType();
6199 if (Ty == Type::VoidTy)
6200 GEN_ERROR("Short call syntax cannot be used with varargs");
6201 ParamTypes.push_back(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006202 }
Chris Lattner59363a32008-02-19 04:36:25 +00006203 Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false);
Christopher Lambfb623c62007-12-17 01:17:35 +00006204 PFTy = PointerType::getUnqual(Ty);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006205 }
6206
Chris Lattner59363a32008-02-19 04:36:25 +00006207 Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006208 CHECK_FOR_ERROR
6209
6210 // Check for call to invalid intrinsic to avoid crashing later.
6211 if (Function *theF = dyn_cast<Function>(V)) {
6212 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
6213 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
6214 !theF->getIntrinsicID(true))
6215 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
6216 theF->getName() + "'");
6217 }
6218
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006219 // Set up the ParamAttrs for the function
6220 ParamAttrsVector Attrs;
Chris Lattner59363a32008-02-19 04:36:25 +00006221 if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006222 ParamAttrsWithIndex PAWI;
6223 PAWI.index = 0;
Chris Lattner59363a32008-02-19 04:36:25 +00006224 PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006225 Attrs.push_back(PAWI);
6226 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006227 // Check the arguments
6228 ValueList Args;
Chris Lattner59363a32008-02-19 04:36:25 +00006229 if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments?
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006230 // Make sure no arguments is a good thing!
6231 if (Ty->getNumParams() != 0)
6232 GEN_ERROR("No arguments passed to a function that "
6233 "expects arguments");
6234 } else { // Has arguments?
6235 // Loop through FunctionType's arguments and ensure they are specified
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006236 // correctly. Also, gather any parameter attributes.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006237 FunctionType::param_iterator I = Ty->param_begin();
6238 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner59363a32008-02-19 04:36:25 +00006239 ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end();
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006240 unsigned index = 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006241
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006242 for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006243 if (ArgI->Val->getType() != *I)
6244 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
6245 (*I)->getDescription() + "'");
6246 Args.push_back(ArgI->Val);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006247 if (ArgI->Attrs != ParamAttr::None) {
6248 ParamAttrsWithIndex PAWI;
6249 PAWI.index = index;
6250 PAWI.attrs = ArgI->Attrs;
6251 Attrs.push_back(PAWI);
6252 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006253 }
6254 if (Ty->isVarArg()) {
6255 if (I == E)
Chris Lattner59363a32008-02-19 04:36:25 +00006256 for (; ArgI != ArgE; ++ArgI, ++index) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006257 Args.push_back(ArgI->Val); // push the remaining varargs
Chris Lattner59363a32008-02-19 04:36:25 +00006258 if (ArgI->Attrs != ParamAttr::None) {
6259 ParamAttrsWithIndex PAWI;
6260 PAWI.index = index;
6261 PAWI.attrs = ArgI->Attrs;
6262 Attrs.push_back(PAWI);
6263 }
6264 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006265 } else if (I != E || ArgI != ArgE)
6266 GEN_ERROR("Invalid number of parameters detected");
6267 }
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006268
6269 // Finish off the ParamAttrs and check them
Duncan Sands637ec552007-11-28 17:07:01 +00006270 const ParamAttrsList *PAL = 0;
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006271 if (!Attrs.empty())
6272 PAL = ParamAttrsList::get(Attrs);
6273
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006274 // Create the call node
David Greene9145dd22007-08-01 03:59:32 +00006275 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner59363a32008-02-19 04:36:25 +00006276 CI->setTailCall((yyvsp[(1) - (8)].BoolVal));
6277 CI->setCallingConv((yyvsp[(2) - (8)].UIntVal));
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006278 CI->setParamAttrs(PAL);
Chris Lattner59363a32008-02-19 04:36:25 +00006279 (yyval.InstVal) = CI;
6280 delete (yyvsp[(6) - (8)].ParamList);
6281 delete (yyvsp[(3) - (8)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006282 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006283 ;}
6284 break;
6285
Devang Patel890cc572008-03-03 18:58:47 +00006286 case 313:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006287#line 3074 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006288 {
6289 (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006290 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006291 ;}
6292 break;
6293
Devang Patel890cc572008-03-03 18:58:47 +00006294 case 314:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006295#line 3079 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006296 {
6297 (yyval.BoolVal) = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006298 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006299 ;}
6300 break;
6301
Devang Patel890cc572008-03-03 18:58:47 +00006302 case 315:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006303#line 3083 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006304 {
6305 (yyval.BoolVal) = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006306 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006307 ;}
6308 break;
6309
Devang Patel890cc572008-03-03 18:58:47 +00006310 case 316:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006311#line 3090 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006312 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006313 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006314 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6315 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6316 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006317 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006318 ;}
6319 break;
6320
Devang Patel890cc572008-03-03 18:58:47 +00006321 case 317:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006322#line 3097 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006323 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006324 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006325 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6326 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006327 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006328 (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6329 delete (yyvsp[(2) - (6)].TypeVal);
6330 ;}
6331 break;
6332
Devang Patel890cc572008-03-03 18:58:47 +00006333 case 318:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006334#line 3105 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006335 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006336 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006337 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription());
6338 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal));
6339 delete (yyvsp[(2) - (3)].TypeVal);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006340 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006341 ;}
6342 break;
6343
Devang Patel890cc572008-03-03 18:58:47 +00006344 case 319:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006345#line 3112 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006346 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006347 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006348 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription());
6349 Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006350 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006351 (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal));
6352 delete (yyvsp[(2) - (6)].TypeVal);
6353 ;}
6354 break;
6355
Devang Patel890cc572008-03-03 18:58:47 +00006356 case 320:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006357#line 3120 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006358 {
6359 if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006360 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner59363a32008-02-19 04:36:25 +00006361 (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "");
6362 (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006363 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006364 ;}
6365 break;
6366
Devang Patel890cc572008-03-03 18:58:47 +00006367 case 321:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006368#line 3128 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006369 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006370 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006371 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6372 if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006373 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006374 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6375 if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006376 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006377 (*(yyvsp[(3) - (5)].TypeVal))->getDescription());
6378 Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006379 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006380 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal));
6381 delete (yyvsp[(3) - (5)].TypeVal);
6382 ;}
6383 break;
6384
Devang Patel890cc572008-03-03 18:58:47 +00006385 case 322:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006386#line 3142 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006387 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006388 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006389 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
6390 const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006391 if (!PT)
6392 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner59363a32008-02-19 04:36:25 +00006393 (*(yyvsp[(5) - (7)].TypeVal))->getDescription());
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006394 const Type *ElTy = PT->getElementType();
Chris Lattner59363a32008-02-19 04:36:25 +00006395 if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType())
6396 GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() +
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006397 "' into space of type '" + ElTy->getDescription() + "'");
6398
Chris Lattner59363a32008-02-19 04:36:25 +00006399 Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006400 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006401 (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal));
6402 delete (yyvsp[(5) - (7)].TypeVal);
6403 ;}
6404 break;
6405
Devang Patel890cc572008-03-03 18:58:47 +00006406 case 323:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006407#line 3159 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Devang Patel3b8849c2008-02-19 22:27:01 +00006408 {
Devang Patelb52f9e72008-02-22 19:31:30 +00006409 Value *TmpVal = getVal((yyvsp[(2) - (5)].TypeVal)->get(), (yyvsp[(3) - (5)].ValIDVal));
Devang Pateleb293342008-02-20 19:13:10 +00006410 if (!GetResultInst::isValidOperands(TmpVal, (yyvsp[(5) - (5)].UInt64Val)))
Devang Patel3b8849c2008-02-19 22:27:01 +00006411 GEN_ERROR("Invalid getresult operands");
Devang Pateleb293342008-02-20 19:13:10 +00006412 (yyval.InstVal) = new GetResultInst(TmpVal, (yyvsp[(5) - (5)].UInt64Val));
Devang Patel087fe2b2008-02-23 00:38:56 +00006413 delete (yyvsp[(2) - (5)].TypeVal);
Devang Patel3b8849c2008-02-19 22:27:01 +00006414 CHECK_FOR_ERROR
6415 ;}
6416 break;
6417
Devang Patel890cc572008-03-03 18:58:47 +00006418 case 324:
Nick Lewycky92b80c72008-03-10 05:01:34 +00006419#line 3167 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Chris Lattner59363a32008-02-19 04:36:25 +00006420 {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006421 if (!UpRefs.empty())
Chris Lattner59363a32008-02-19 04:36:25 +00006422 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription());
6423 if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006424 GEN_ERROR("getelementptr insn requires pointer operand");
6425
Chris Lattner59363a32008-02-19 04:36:25 +00006426 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 +00006427 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner59363a32008-02-19 04:36:25 +00006428 (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'");
6429 Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal));
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006430 CHECK_FOR_ERROR
Chris Lattner59363a32008-02-19 04:36:25 +00006431 (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end());
6432 delete (yyvsp[(2) - (4)].TypeVal);
6433 delete (yyvsp[(4) - (4)].ValueList);
6434 ;}
6435 break;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006436
Chris Lattner59363a32008-02-19 04:36:25 +00006437
6438/* Line 1267 of yacc.c. */
Nick Lewycky92b80c72008-03-10 05:01:34 +00006439#line 6440 "llvmAsmParser.tab.c"
Chris Lattner59363a32008-02-19 04:36:25 +00006440 default: break;
Dale Johannesen3afee192007-09-07 21:07:57 +00006441 }
Chris Lattner59363a32008-02-19 04:36:25 +00006442 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
6443
6444 YYPOPSTACK (yylen);
6445 yylen = 0;
6446 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006447
6448 *++yyvsp = yyval;
6449
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006450
Chris Lattner59363a32008-02-19 04:36:25 +00006451 /* Now `shift' the result of the reduction. Determine what state
6452 that goes to, based on the state we popped back to and the rule
6453 number reduced by. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006454
6455 yyn = yyr1[yyn];
6456
Chris Lattner59363a32008-02-19 04:36:25 +00006457 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
6458 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006459 yystate = yytable[yystate];
6460 else
Chris Lattner59363a32008-02-19 04:36:25 +00006461 yystate = yydefgoto[yyn - YYNTOKENS];
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006462
6463 goto yynewstate;
6464
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006465
Chris Lattner59363a32008-02-19 04:36:25 +00006466/*------------------------------------.
6467| yyerrlab -- here on detecting error |
6468`------------------------------------*/
6469yyerrlab:
6470 /* If not already recovering from an error, report this error. */
6471 if (!yyerrstatus)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006472 {
6473 ++yynerrs;
Chris Lattner59363a32008-02-19 04:36:25 +00006474#if ! YYERROR_VERBOSE
6475 yyerror (YY_("syntax error"));
6476#else
6477 {
6478 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
6479 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
6480 {
6481 YYSIZE_T yyalloc = 2 * yysize;
6482 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
6483 yyalloc = YYSTACK_ALLOC_MAXIMUM;
6484 if (yymsg != yymsgbuf)
6485 YYSTACK_FREE (yymsg);
6486 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
6487 if (yymsg)
6488 yymsg_alloc = yyalloc;
6489 else
6490 {
6491 yymsg = yymsgbuf;
6492 yymsg_alloc = sizeof yymsgbuf;
6493 }
6494 }
Dale Johannesen3afee192007-09-07 21:07:57 +00006495
Chris Lattner59363a32008-02-19 04:36:25 +00006496 if (0 < yysize && yysize <= yymsg_alloc)
6497 {
6498 (void) yysyntax_error (yymsg, yystate, yychar);
6499 yyerror (yymsg);
6500 }
6501 else
6502 {
6503 yyerror (YY_("syntax error"));
6504 if (yysize != 0)
6505 goto yyexhaustedlab;
6506 }
6507 }
6508#endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006509 }
6510
Chris Lattner59363a32008-02-19 04:36:25 +00006511
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006512
6513 if (yyerrstatus == 3)
6514 {
Chris Lattner59363a32008-02-19 04:36:25 +00006515 /* If just tried and failed to reuse look-ahead token after an
6516 error, discard it. */
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006517
Chris Lattner59363a32008-02-19 04:36:25 +00006518 if (yychar <= YYEOF)
6519 {
6520 /* Return failure if at end of input. */
6521 if (yychar == YYEOF)
6522 YYABORT;
6523 }
6524 else
6525 {
6526 yydestruct ("Error: discarding",
6527 yytoken, &yylval);
6528 yychar = YYEMPTY;
6529 }
6530 }
6531
6532 /* Else will try to reuse look-ahead token after shifting the error
6533 token. */
6534 goto yyerrlab1;
6535
6536
6537/*---------------------------------------------------.
6538| yyerrorlab -- error raised explicitly by YYERROR. |
6539`---------------------------------------------------*/
6540yyerrorlab:
6541
6542 /* Pacify compilers like GCC when the user code never invokes
6543 YYERROR and the label yyerrorlab therefore never appears in user
6544 code. */
6545 if (/*CONSTCOND*/ 0)
6546 goto yyerrorlab;
6547
6548 /* Do not reclaim the symbols of the rule which action triggered
6549 this YYERROR. */
6550 YYPOPSTACK (yylen);
6551 yylen = 0;
6552 YY_STACK_PRINT (yyss, yyssp);
6553 yystate = *yyssp;
6554 goto yyerrlab1;
6555
6556
6557/*-------------------------------------------------------------.
6558| yyerrlab1 -- common code for both syntax error and YYERROR. |
6559`-------------------------------------------------------------*/
6560yyerrlab1:
6561 yyerrstatus = 3; /* Each real token shifted decrements this. */
6562
6563 for (;;)
6564 {
6565 yyn = yypact[yystate];
6566 if (yyn != YYPACT_NINF)
6567 {
6568 yyn += YYTERROR;
6569 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6570 {
6571 yyn = yytable[yyn];
6572 if (0 < yyn)
6573 break;
6574 }
6575 }
6576
6577 /* Pop the current state because it cannot handle the error token. */
6578 if (yyssp == yyss)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006579 YYABORT;
6580
Dale Johannesen3afee192007-09-07 21:07:57 +00006581
Chris Lattner59363a32008-02-19 04:36:25 +00006582 yydestruct ("Error: popping",
6583 yystos[yystate], yyvsp);
6584 YYPOPSTACK (1);
6585 yystate = *yyssp;
6586 YY_STACK_PRINT (yyss, yyssp);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006587 }
6588
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006589 if (yyn == YYFINAL)
6590 YYACCEPT;
6591
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006592 *++yyvsp = yylval;
Chris Lattner59363a32008-02-19 04:36:25 +00006593
6594
6595 /* Shift the error token. */
6596 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spenceraa8ae282007-07-31 03:50:36 +00006597
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006598 yystate = yyn;
6599 goto yynewstate;
6600
Scott Michel6d1aba82008-01-30 03:10:00 +00006601
Chris Lattner59363a32008-02-19 04:36:25 +00006602/*-------------------------------------.
6603| yyacceptlab -- YYACCEPT comes here. |
6604`-------------------------------------*/
6605yyacceptlab:
6606 yyresult = 0;
6607 goto yyreturn;
6608
6609/*-----------------------------------.
6610| yyabortlab -- YYABORT comes here. |
6611`-----------------------------------*/
6612yyabortlab:
6613 yyresult = 1;
6614 goto yyreturn;
6615
6616#ifndef yyoverflow
6617/*-------------------------------------------------.
6618| yyexhaustedlab -- memory exhaustion comes here. |
6619`-------------------------------------------------*/
6620yyexhaustedlab:
6621 yyerror (YY_("memory exhausted"));
6622 yyresult = 2;
6623 /* Fall through. */
Scott Michel5a6f17b2008-01-30 02:55:46 +00006624#endif
Chris Lattner59363a32008-02-19 04:36:25 +00006625
6626yyreturn:
6627 if (yychar != YYEOF && yychar != YYEMPTY)
6628 yydestruct ("Cleanup: discarding lookahead",
6629 yytoken, &yylval);
6630 /* Do not reclaim the symbols of the rule which action triggered
6631 this YYABORT or YYACCEPT. */
6632 YYPOPSTACK (yylen);
6633 YY_STACK_PRINT (yyss, yyssp);
6634 while (yyssp != yyss)
6635 {
6636 yydestruct ("Cleanup: popping",
6637 yystos[*yyssp], yyvsp);
6638 YYPOPSTACK (1);
Scott Michel6d1aba82008-01-30 03:10:00 +00006639 }
Chris Lattner59363a32008-02-19 04:36:25 +00006640#ifndef yyoverflow
6641 if (yyss != yyssa)
6642 YYSTACK_FREE (yyss);
6643#endif
6644#if YYERROR_VERBOSE
6645 if (yymsg != yymsgbuf)
6646 YYSTACK_FREE (yymsg);
6647#endif
6648 /* Make sure YYID is used. */
6649 return YYID (yyresult);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006650}
Chris Lattner59363a32008-02-19 04:36:25 +00006651
6652
Nick Lewycky92b80c72008-03-10 05:01:34 +00006653#line 3184 "/home/nicholas/llvm-commit/lib/AsmParser/llvmAsmParser.y"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006654
6655
6656// common code from the two 'RunVMAsmParser' functions
6657static Module* RunParser(Module * M) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006658 CurModule.CurrentModule = M;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006659 // Check to make sure the parser succeeded
6660 if (yyparse()) {
6661 if (ParserResult)
6662 delete ParserResult;
6663 return 0;
6664 }
6665
6666 // Emit an error if there are any unresolved types left.
6667 if (!CurModule.LateResolveTypes.empty()) {
6668 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6669 if (DID.Type == ValID::LocalName) {
6670 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6671 } else {
6672 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6673 }
6674 if (ParserResult)
6675 delete ParserResult;
6676 return 0;
6677 }
6678
6679 // Emit an error if there are any unresolved values left.
6680 if (!CurModule.LateResolveValues.empty()) {
6681 Value *V = CurModule.LateResolveValues.back();
6682 std::map<Value*, std::pair<ValID, int> >::iterator I =
6683 CurModule.PlaceHolderInfo.find(V);
6684
6685 if (I != CurModule.PlaceHolderInfo.end()) {
6686 ValID &DID = I->second.first;
6687 if (DID.Type == ValID::LocalName) {
6688 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6689 } else {
6690 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6691 }
6692 if (ParserResult)
6693 delete ParserResult;
6694 return 0;
6695 }
6696 }
6697
6698 // Check to make sure that parsing produced a result
6699 if (!ParserResult)
6700 return 0;
6701
6702 // Reset ParserResult variable while saving its value for the result.
6703 Module *Result = ParserResult;
6704 ParserResult = 0;
6705
6706 return Result;
6707}
6708
6709void llvm::GenerateError(const std::string &message, int LineNo) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006710 if (LineNo == -1) LineNo = LLLgetLineNo();
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006711 // TODO: column number in exception
6712 if (TheParseError)
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006713 TheParseError->setError(LLLgetFilename(), message, LineNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006714 TriggerError = 1;
6715}
6716
6717int yyerror(const char *ErrorMsg) {
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006718 std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": ";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006719 std::string errMsg = where + "error: " + std::string(ErrorMsg);
Duncan Sandsf5588dc2007-11-27 13:23:08 +00006720 if (yychar != YYEMPTY && yychar != 0) {
6721 errMsg += " while reading token: '";
6722 errMsg += std::string(LLLgetTokenStart(),
6723 LLLgetTokenStart()+LLLgetTokenLength()) + "'";
6724 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006725 GenerateError(errMsg);
6726 return 0;
6727}
Chris Lattner59363a32008-02-19 04:36:25 +00006728